{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/13485","labels_url":"https://api.github.com/repos/ansible/ansible/issues/13485/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/13485/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/13485/events","html_url":"https://github.com/ansible/ansible/issues/13485","id":121228758,"number":13485,"title":"Handlers don't execute handlers in included","user":{"login":"galiev","id":5677321,"avatar_url":"https://avatars.githubusercontent.com/u/5677321?v=3","gravatar_id":"","url":"https://api.github.com/users/galiev","html_url":"https://github.com/galiev","followers_url":"https://api.github.com/users/galiev/followers","following_url":"https://api.github.com/users/galiev/following{/other_user}","gists_url":"https://api.github.com/users/galiev/gists{/gist_id}","starred_url":"https://api.github.com/users/galiev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galiev/subscriptions","organizations_url":"https://api.github.com/users/galiev/orgs","repos_url":"https://api.github.com/users/galiev/repos","events_url":"https://api.github.com/users/galiev/events{/privacy}","received_events_url":"https://api.github.com/users/galiev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible/labels/P2","name":"P2","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ansible/ansible/milestones/5","html_url":"https://github.com/ansible/ansible/milestones/v2","labels_url":"https://api.github.com/repos/ansible/ansible/milestones/5/labels","id":975800,"number":5,"title":"v2","description":null,"creator":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"open_issues":41,"closed_issues":648,"state":"open","created_at":"2015-02-11T19:43:06Z","updated_at":"2016-01-06T20:35:36Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-12-09T12:42:25Z","updated_at":"2016-01-06T22:13:28Z","closed_at":null,"body":"When I include a file in a handler, the tasks in the included file are not executed in ansible 2.0.\r\nPlaybook redis.yml:\r\n```yaml\r\n---\r\n- hosts: redis\r\n  gather_facts: true\r\n  vars:\r\n    os_firewall_use_firewalld: false\r\n    port_open: \"{{ redis_port|default(6379) }}\"\r\n  tasks:\r\n    - include: roles/firewall/tasks/firewall_open_port.yml\r\n  handlers:\r\n    - include: roles/firewall/handlers/main.yml\r\n```\r\nroles/firewall/handlers/main.yml\r\n```yaml\r\n- name: save iptables\r\n  shell: service iptables save\r\n```\r\nroles/firewall/tasks/firewall_open_port.yml\r\n```yaml\r\n- include: iptables/iptables_open_port.yml\r\n  when: not os_firewall_use_firewalld\r\n```\r\nFor ansible 1.9.4:\r\nroles/firewall/tasks/iptables/iptables_open_port.yml\r\n```yaml\r\n- name: Open port\r\n  shell: iptables -A INPUT -m conntrack --ctstate NEW -p tcp --dport \"{{ port_open }}\" -j ACCEPT\r\n  notify:\r\n    - save iptables\r\n```\r\nFor ansible 2.0:\r\nroles/firewall/tasks/iptables/iptables_open_port.yml\r\n```yaml\r\n- name: Open port \r\n  iptables:\r\n    chain: INPUT\r\n    ctstate: NEW\r\n    protocol: tcp\r\n    destination_port: \"{{ port_open }}\"\r\n    jump: ACCEPT\r\n  notify:\r\n    - save iptables\r\n```\r\nResult:\r\n```bash\r\nansible --version\r\nansible 1.9.4\r\n  configured module search path = None\r\n```\r\n```bash\r\nPLAY [redis] ****************************************************************** \r\n\r\nGATHERING FACTS *************************************************************** \r\nok: [redis-01-transport.shire.local]\r\nok: [redis-02-transport.shire.local]\r\n\r\nTASK: [Open port] ********************************************* \r\nchanged: [redis-01-transport.shire.local]\r\nchanged: [redis-02-transport.shire.local]\r\n\r\nNOTIFIED: [save iptables] ***************************************************** \r\nchanged: [redis-01-transport.shire.local]\r\nchanged: [redis-02-transport.shire.local]\r\n\r\nPLAY RECAP ******************************************************************** \r\nredis-01-transport.shire.local : ok=3    changed=2    unreachable=0    failed=0   \r\nredis-02-transport.shire.local : ok=3    changed=2    unreachable=0    failed=0   \r\n```\r\n\r\n```bash\r\n ansible --version\r\nansible 2.0.0\r\n  config file = /home/rino/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n```bash\r\nPLAY ***************************************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [redis-01-transport.shire.local]\r\nok: [redis-02-transport.shire.local]\r\n\r\nTASK [include] *****************************************************************\r\nincluded: /home/rino/ansible/roles/firewall/tasks/firewall_open_port.yml for redis-01-transport.shire.local, redis-02-transport.shire.local\r\n\r\nTASK [include] *****************************************************************\r\nincluded: /home/rino/ansible/playbooks/../roles/firewall/tasks/iptables/iptables_open_port.yml for redis-02-transport.shire.local, redis-01-transport.shire.local\r\n\r\nTASK [Open port] **********************************************************\r\nchanged: [redis-01-transport.shire.local]\r\nchanged: [redis-02-transport.shire.local]\r\n\r\nPLAY RECAP *********************************************************************\r\nredis-01-transport.shire.local : ok=4    changed=1    unreachable=0    failed=0   \r\nredis-02-transport.shire.local : ok=4    changed=1    unreachable=0    failed=0\r\n```\r\nWhen I replace in playbook:\r\n```yaml\r\n  handlers:\r\n    - include: roles/firewall/handlers/main.yml\r\n```\r\nto\r\n```yaml\r\nhandlers:\r\n  - name: save iptables\r\n    shell: /usr/libexec/iptables/iptables.init save\r\n```\r\nit's work well. It's bug or my mistake?"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/169479169","html_url":"https://github.com/ansible/ansible/issues/13485#issuecomment-169479169","issue_url":"https://api.github.com/repos/ansible/ansible/issues/13485","id":169479169,"user":{"login":"jimi-c","id":26403,"avatar_url":"https://avatars.githubusercontent.com/u/26403?v=3","gravatar_id":"","url":"https://api.github.com/users/jimi-c","html_url":"https://github.com/jimi-c","followers_url":"https://api.github.com/users/jimi-c/followers","following_url":"https://api.github.com/users/jimi-c/following{/other_user}","gists_url":"https://api.github.com/users/jimi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/jimi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimi-c/subscriptions","organizations_url":"https://api.github.com/users/jimi-c/orgs","repos_url":"https://api.github.com/users/jimi-c/repos","events_url":"https://api.github.com/users/jimi-c/events{/privacy}","received_events_url":"https://api.github.com/users/jimi-c/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T22:13:28Z","updated_at":"2016-01-06T22:13:28Z","body":"This is currently documented in the 2.0 known issues. This is a consequence of the fact that includes are now dynamic and not processed ahead of time, so Ansible doesn't know about tasks inside an include it hasn't processed yet."}}