Why are my Ansible handlers not firing? -


i have playbook installs tomcat , deploys web applications. web application deploy task(s) notifies handler restart tomcat. handler never fires. using handler manage tomcat service because understand docs handlers should fire once if called multiple times. missing obvious?

this playbook:

--- - hosts:   become: true   become_user: root   roles:   - role: common   - role: nginx   - role: tomcat   - role: launchpad   - role: manager   - role: reporting   handlers:   - include: /tomcat/handlers/etitomcat_service_ctrl.yml 

this 1 of roles deploys web app:

--- - name: remove current installation of launchpad   file: path={{etitomcat_path}}/webapps/{{launchpad_module}} state=absent  - name: remove current war file {{launchpad_module}}   file: path={{etitomcat_path}}/webapps/{{launchpad_module}}.war state=absent       - name: download latest snapshot of launchpad , deploy {{etitomcat_path}}   get_url: url={{launchpad_source_url}} dest={{etitomcat_path}}/webapps/{{launchpad_module}}.war mode=0744 owner={{etitomcat_user}} group={{etitomcat_group}} force=yes   notify: "restart_eti_tomcat" 

this handler:

  - name: "restart eti tomcat"     service: name=etitomcat state=restarted     become: true     become_user: root     listen: "restart_eti_tomcat"    - name: "start eti tomcat"     service: name=etitomcat state=started     become: true     become_user: root     listen: "start_eti_tomcat"    - name: "stop eti tomcat"     service: name=etitomcat state=stopped     become: true     become_user: root     listen: "stop_eti_tomcat"  

adding static: yes should resolve issue when using ansible >= 2.1.

handlers: - include: /tomcat/handlers/etitomcat_service_ctrl.yml   static: yes 

take @ github issue, linked google groups thread might contain valuable information well.

edit

as pointed out @rhythmicdevil documentation notes:

you cannot notify handler defined inside of include. of ansible 2.1, work, include must static.


Comments