# stacking delegated handlers

**URL:** <https://forum.ansible.com/t/stacking-delegated-handlers/14359>\
**Category:** Ansible Project\
**Created:** [January 16, 2014, 11:24am UTC](https://forum.ansible.com/t/stacking-delegated-handlers/14359 "2014-01-16T11:24:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timur\_Batyrshin](https://avatars.discourse-cdn.com/v4/letter/t/919ad9/32.png) [@Timur\_Batyrshin](https://forum.ansible.com/u/Timur_Batyrshin)\
**Post date:** [January 16, 2014, 11:24am UTC](https://forum.ansible.com/t/stacking-delegated-handlers/14359/1 "2014-01-16T11:24:37Z")

</div>

Hi,

(This is a followup to [https://github.com/ansible/ansible/issues/5634](https://github.com/ansible/ansible/issues/5634))

Is there a way to “stack” delegated handlers?

When the handler is delegated to some host and several hosts kick that handler it is triggered several times instead of once.  
It is perfectly valid when the handler in its rendered form is different a bit for each remote host (say you are sending some event notifying that  
the server has got up) but if the handler in its rendered form is completely the same it should be triggered only once.

Consider the generic example:

- hosts: all
- tasks:
- name: do some configuration stuff  
…  
notify:
- restart server
- handlers:
- name: restart server  
service: name=myservice state=restarted  
delegate\_to: “{{ server\_ip }}”

The natural way would be to have the central server (the one to which we delegate the action) restarted only once instead of restarting it for every processed host.  
Of course if we run several servers (i.e. use several server\_ip’s here) the action should be triggered for each of them.  
That’s why I’m talking about “rendered form” of action (i.e. after all variable substitutions are done).

Or is there a parameter to handler that would make it behave like that? I have not found any in [http://docs.ansible.com/playbooks\_intro.html](http://docs.ansible.com/playbooks_intro.html)

Thanks,

Timur
