Is it possible to define one notify
block for several tasks?
In next code snippet notify: restart tomcat
defined 3 times, but I want to define it only one time and "apply" to list of tasks
- name : template context.xml
template:
src: context.xml.j2
dest: /usr/share/tomcat/conf/context.xml
group: tomcat
mode: 0664
notify: restart tomcat
- name : copy server.xml
copy:
src: server.xml
dest: /etc/tomcat/server.xml
group: tomcat
mode: 0664
notify: restart tomcat
- name : copy atomikos-integration-extension
copy:
src: atomikos-integration-extension-3.7.1-20120529.jar
dest: /usr/share/tomcat/ext-libs/
group: tomcat
mode: 0664
notify: restart tomcat
No, you cannot.
Notify sets a trigger to run the specified handler based on the status of the task. There is no "status for a block of tasks" in Ansible hence you cannot define notify
for a block.
Besides, it wouldn't change anything functionally, only influence the visual appeal (and I would claim by obscuring things rather than simplifying). The handler is run only once regardless of how many tasks triggered it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With