We have one Ansible role that needs to run three tasks in the handlers/main.yml
task file, but it only runs the first task. How do I force it to run the other two tasks? I do have the ignore
flag on for if the first task fails.
The tasks/main.yml
file looks like:
- name: openfire | Copy plugins into openfire/plugins
copy: src={{ srcdir }}/xmpp/{{ item }} dest=${bindir}/openfire/plugins/{{ item }}
with_items:
- x.jar
- y.jar
sudo: yes
sudo_user: ${tomcat_user}
notify: restart openfire
- name: openfire | Copy jars into openfire/lib
copy: src={{ srcdir }}/xmpp/{{ item }} dest=${bindir}/openfire/lib/{{ item }}
with_items:
- a.jar
- b.jar
sudo: yes
sudo_user: ${tomcat_user}
notify: restart openfire
The handlers/main.yml
file looks like:
- name: restart openfire
service: name=openfire state=stopped
ignore_errors: true
sudo: yes
- name: restart openfire
file: path=/var/run/openfire.pid state=absent
sudo: yes
- name: restart openfire
service: name=openfire state=restarted enabled=yes
sudo: yes
Only the first handler task (shut down openfire) runs.
Its possible for handler to call another notify. Multiple notify calls are also allowed:
---
- name: restart something
command: shutdown.sh
notify:
- wait for stop
- start something
- wait for start
- name: wait for stop
wait_for: port={{port}} state=stopped
- name: start something
command: startup.sh
- name: wait for start
wait_for: port={{port}} state=started