0

How do handlers behave when they are part of an included playbook ? I am using 3 playbooks and per my understanding ansible runs them in sequence. I have a handler which is configured as part of the second playbook ( checks if the newly created VM is up before proceeding ) however this is running after the third playbook which is yum update.

Main task file in role


# tasks file for baseline
- include: vmbuild.yml
- include: vmconfig.yml
- include: yum-update.yml

handler is configured in handlers/main.yml, shouldnt the third playbook run after the second has completed its tasks ?

2
  • It's not possible to "include a playbook". There is no such thing as include_playbook. There is only import_playbook. You must have seen an error if you included a playbook. Mar 8, 2020 at 15:32
  • Thank you for the prompt response, i am able to run the playbooks from another yml file which calls for this role. The problem is handlers in the second play are running after the third which is breaking the flow.
    – Atul
    Mar 8, 2020 at 15:40

1 Answer 1

0

Managed to get this working by defining a post_tasks along with the role, this way once all other tasks in playbooks run, last step (yum update) runs fine inheriting the VM's hostname from last steps

Hope this helps someone..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.