# handler invoked from role is not called

**URL:** <https://forum.ansible.com/t/handler-invoked-from-role-is-not-called/21973>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [July 9, 2016, 10:11pm UTC](https://forum.ansible.com/t/handler-invoked-from-role-is-not-called/21973 "2016-07-09T22:11:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Szabolcs\_Szallar](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Szabolcs\_Szallar](https://forum.ansible.com/u/Szabolcs_Szallar)\
**Post date:** [July 9, 2016, 10:11pm UTC](https://forum.ansible.com/t/handler-invoked-from-role-is-not-called/21973/1 "2016-07-09T22:11:42Z")

</div>

hi,

If I use the handler incorrectly, please let me know.

I’m using Ansible a quiet while and recently migrated from 1.9 to 2.1.0.0.  
My target host is CentOS 6.5  
I try to follow the documentation, but can’t make the handlers work.

The playbook structure is generated by ansible-galaxy init projectname,  
and I use the following logic:  
site.yml has lines something like:

- name: single node setup of projectname  
vars\_files:
- vars/main.yml  
hosts: node01  
become: true  
roles:
- base

Logical structure:

site.yml  
└── roles  
└── base  
└── tasks  
└── main.yml

Example line in main.yml:

- name: configure iptables rules  
template: src=iptables\_config.j2 dest=/etc/sysconfig/iptables owner=root group=root mode=0600  
notify:
- iptables restart

In roles directory I have a task with main.yml, and from that main.yml I add package configuration with template.  
When the template is updated, I have a handler called, but for some reason it’s not executed.

Handlers are in same level as site.yml:

└── handlers  
└── main.yml

Example line in handlers/main.yml:

- name: iptables restart  
service: name=iptables state=restarted

I expect the handler take action when the template updates the iptables configuration file, but it’s never called.  
This issue is not specific to the above example.

Regards,  
Szabolcs

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 11, 2016, 1:38pm UTC](https://forum.ansible.com/t/handler-invoked-from-role-is-not-called/21973/2 "2016-07-11T13:38:23Z")

</div>

Try moving your handlers folder into the role, same level as your tasks under base.

&nbsp;&nbsp;roles  
&nbsp;&nbsp;&nbsp;└── base  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── tasks  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│ └── main.yml  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── handlers  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── main.yml
