# delegate\_to and notify handler to run once

**URL:** <https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533>\
**Category:** Ansible Project\
**Created:** [September 23, 2013, 12:48pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533 "2013-09-23T12:48:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Hawley](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@Tom\_Hawley](https://forum.ansible.com/u/Tom_Hawley)\
**Post date:** [September 23, 2013, 12:48pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533/1 "2013-09-23T12:48:20Z")

</div>

Hello,

I use ansible to configure several servers and use “delegate\_to” to write out their nagios configs on the nagios server. If the config is changed a notify handler is fired like below:

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 23, 2013, 1:30pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533/2 "2013-09-23T13:30:12Z")

</div>

That may be a bug, as handlers are only supposed to trigger once of course despite the number of notifications sent to it. Could you open an issue on github for this?

Thanks!

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [September 23, 2013, 1:36pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533/3 "2013-09-23T13:36:44Z")

</div>

​Are you repeating this task among several plays? Handlers will fire once  
per play, not per playbook.  
​

---

<div class="post-metadata">

**Author:** ![Tom\_Hawley](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@Tom\_Hawley](https://forum.ansible.com/u/Tom_Hawley)\
**Post date:** [September 23, 2013, 2:48pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533/4 "2013-09-23T14:48:05Z")

</div>

It’s called once in one play in the “common” role i.e. once for each server that matches the “–limit” option when I run ansible-playbook.

e.g.

“ansible-playbook -i production site.yml -l [myserver.example.com](http://myserver.example.com) -sK” will restart nagios once.

“ansible-playbook -i production site.yml -l webservers -sK” will restart nagios once for each server in the webserver group.

Tom

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [September 23, 2013, 3:16pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533/5 "2013-09-23T15:16:33Z")

</div>

​Oh, I see, it's still called once for every host in that play.  
That's how it currently works I'm afraid.​

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 23, 2013, 6:10pm UTC](https://forum.ansible.com/t/delegate-to-and-notify-handler-to-run-once/13533/6 "2013-09-23T18:10:42Z")

</div>

Slight correction –

Handlers run for each host that notified them, not for every host.

There has been some interest in a “global notify” but you may want to just do a “trailing play” that restarts the remote nagios config every time.
