In response to a change, I have multiple related tasks that should run. How do I write an Ansible handler with multiple tasks?
For example, I would like a handler that r
In your handler file, chain the different steps together using notify.
- name: Restart conditionally
debug: msg=Step1
changed_when: True
notify: Restart conditionally step 2
- name: Restart conditionally step 2
debug: msg=Step2
changed_when: True
notify: Restart conditionally step 3
- name: Restart conditionally step 3
debug: msg=Step3
Then refer to it from a task with notify: Restart conditionally
.
Note that you can only notify to handlers below the current one. So for example, Restart conditionally step 2
can't notify Restart conditionally
.
Source: #ansible at irc.freenode.net. I'm unsure whether this will continue to work in the future as it's not mentioned as a feature in the official documentation.