# Trigger task sequences in handlers

**URL:** <https://forum.ansible.com/t/trigger-task-sequences-in-handlers/12640>\
**Category:** Ansible Project\
**Created:** [April 6, 2013, 3:28pm UTC](https://forum.ansible.com/t/trigger-task-sequences-in-handlers/12640 "2013-04-06T15:28:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [April 6, 2013, 3:28pm UTC](https://forum.ansible.com/t/trigger-task-sequences-in-handlers/12640/1 "2013-04-06T15:28:48Z")

</div>

You can come close to this by doing something like the following:

- name: Initiate notification here  
action: …  
notify: reinstall

Then write the hander:

handlers:

- name: Handler task 1 : Notification handler starting point  
action: Whatever …  
register: reinstall\_notification\_received

- name: Handler task 2  
action: Whatever  
when\_changed: reinstall\_notification\_received

and so on and so forth. Handler tasks 1… n can be included in a handler task as well to shorten the parent playbook

Yes, annotating an include to indicate all contained actions should run as part of a handler would be nice. That’s in similar vein to a number of other desirables of attaching various stuff to includes. But the above has been sufficient for me as a workaround.

---

<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:** [April 6, 2013, 4:14pm UTC](https://forum.ansible.com/t/trigger-task-sequences-in-handlers/12640/2 "2013-04-06T16:14:02Z")

</div>

I just tested this:

- hosts: localhost  
tasks:
- command: echo t  
notify: do

handlers:

- name: do  
command: echo h1  
notify: do1
- name: do1  
command: echo h2

Which works as expected. So its eems to be possible to notiy a handler from a handler!

---

<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:** [April 7, 2013, 11:35pm UTC](https://forum.ansible.com/t/trigger-task-sequences-in-handlers/12640/3 "2013-04-07T23:35:17Z")

</div>

That surprises even me! 🙂

Good deal!

---

<div class="post-metadata">

**Author:** ![Asad\_Khan](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@Asad\_Khan](https://forum.ansible.com/u/Asad_Khan)\
**Post date:** [April 12, 2013, 5:47pm UTC](https://forum.ansible.com/t/trigger-task-sequences-in-handlers/12640/4 "2013-04-12T17:47:11Z")

</div>

This implementation of handlers is really elegant  
By this I mean the multiple actions per handler, the ability to encapsulate in include files - i.e. multiple handlers per included file -, the ability to have both inline & included handler actions (seems obvious but has really nice uses), the “as written” order of handlers, and finally the re-notification to downstream handlers from within handlers.
