# Notify handler only one in the same role

**URL:** <https://forum.ansible.com/t/notify-handler-only-one-in-the-same-role/18339>\
**Category:** Ansible Project\
**Created:** [May 28, 2015, 11:38pm UTC](https://forum.ansible.com/t/notify-handler-only-one-in-the-same-role/18339 "2015-05-28T23:38:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Truong](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Steven\_Truong](https://forum.ansible.com/u/Steven_Truong)\
**Post date:** [May 28, 2015, 11:38pm UTC](https://forum.ansible.com/t/notify-handler-only-one-in-the-same-role/18339/1 "2015-05-28T23:38:58Z")

</div>

Hi all,

I am using ansible 1.9.1 and in the same role I have a couple of notify to the same service to be restarted.

Apparently, ansible tries to restart 3-4 times for each notify and that is undesirable.

I could do without notify and create register for each task and then at the end I can have another task that would do when: any of the register variable changed and restart but that is a hack.

Please let me know if there is the right way to do this.

Thank you very much in advance.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 29, 2015, 12:09am UTC](https://forum.ansible.com/t/notify-handler-only-one-in-the-same-role/18339/2 "2015-05-29T00:09:59Z")

</div>

I think you are going to need to show an example of the playbook/role and the output of this happening.

---

<div class="post-metadata">

**Author:** ![Steven\_Truong](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Steven\_Truong](https://forum.ansible.com/u/Steven_Truong)\
**Post date:** [May 29, 2015, 1:05am UTC](https://forum.ansible.com/t/notify-handler-only-one-in-the-same-role/18339/3 "2015-05-29T01:05:35Z")

</div>

Hi Matt,

Here are some tasks that call the same notify and it happened that these files might got changed during the same run.

- name: creates hadoop .sh config files  
template: src={{ item }}.j2 dest=/etc/hadoop/conf.{{ nameservice\_id }}/{{ item }} owner=hdfs group=hadoop mode=0755  
with\_items:

- hadoop-env.sh

- yarn-env.sh  
tags:

- cdh5\_datanode

- cdh5\_datanode\_conf

- cdh5\_datanode\_conf\_sh

- cdh5\_mrv1\_slave  
notify: reload datanode

- name: create /etc/default/hadoop-hdfs-datanode  
template: src=hadoop-hdfs-datanode.j2 dest=/etc/default/hadoop-hdfs-datanode owner=root group=root mode=0644  
tags:

- cdh5\_datanode

- cdh5\_datanode\_conf

- cdh5\_mrv1\_slave  
notify: reload datanode

Currently, I already finished my setup and I just do not have the outputs around but please trust me on this one or you can simply experiment with something similar to this situation.

Thank you very much,  
Steven.

---

<div class="post-metadata">

**Author:** ![Steven\_Truong](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Steven\_Truong](https://forum.ansible.com/u/Steven_Truong)\
**Post date:** [May 29, 2015, 1:06am UTC](https://forum.ansible.com/t/notify-handler-only-one-in-the-same-role/18339/4 "2015-05-29T01:06:40Z")

</div>

Note: these tasks are in the same role.
