# handler + include

**URL:** <https://forum.ansible.com/t/handler-include/16462>\
**Category:** Ansible Project\
**Created:** [October 8, 2014, 10:48am UTC](https://forum.ansible.com/t/handler-include/16462 "2014-10-08T10:48:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![profhase85](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@profhase85](https://forum.ansible.com/u/profhase85)\
**Post date:** [October 8, 2014, 10:48am UTC](https://forum.ansible.com/t/handler-include/16462/1 "2014-10-08T10:48:54Z")

</div>

Hi,

having the following task in my main.yml in a role (tasks/main.yml):

`

- name: mytask  
copy:  
src=/source  
dest=/destination  
notify: redeploy

`

with the following handler ( handlers/main.yml):

`

- name: redeploy  
include: redeploy.yml

`

I am getting:

> ERROR: change handler (redeploy) is not defined

Is this behaviour intended?

I thought of this as the most concise way to consolidate multiple handler tasks.  
(I know, there was already a mail [here](https://groups.google.com/forum/#!topic/ansible-project/pOm5zIYpngI) with the suggestion to notify other handlers in handler which does not seem semantically appropriate)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 8, 2014, 12:41pm UTC](https://forum.ansible.com/t/handler-include/16462/2 "2014-10-08T12:41:02Z")

</div>

What’s defined in handlers/redeploy.yml?

---

<div class="post-metadata">

**Author:** ![profhase85](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@profhase85](https://forum.ansible.com/u/profhase85)\
**Post date:** [October 8, 2014, 12:48pm UTC](https://forum.ansible.com/t/handler-include/16462/3 "2014-10-08T12:48:29Z")

</div>

In the handlers/redeploy.yml there are several tasks:

`

- name: copy installation files  
copy:  
…

- name: run install script  
command:  
…

- name: restart myservice  
service:  
…

`

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 8, 2014, 12:50pm UTC](https://forum.ansible.com/t/handler-include/16462/4 "2014-10-08T12:50:13Z")

</div>

Yeah, handlers don’t work like that, with a “name” on the include like that.

Each handler must have a name and you must notify the names of the handlers specifically.

---

<div class="post-metadata">

**Author:** ![profhase85](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@profhase85](https://forum.ansible.com/u/profhase85)\
**Post date:** [October 8, 2014, 1:17pm UTC](https://forum.ansible.com/t/handler-include/16462/5 "2014-10-08T13:17:51Z")

</div>

Would that be a possible feature request?  
It seems quite logical to me that (like in my case) a handler could consist of multiple related tasks.

Or do I oversee anything?

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [October 12, 2014, 8:30am UTC](https://forum.ansible.com/t/handler-include/16462/6 "2014-10-12T08:30:20Z")

</div>

Hi,

you can call more, than one handler:  
`- name: mytask`  
`copy:`  
`src=/source`  
`dest=/destination`  
`notify:`  
`- copy installation files`

`- run install script`

`- restart myservice`

`David`

---

<div class="post-metadata">

**Author:** ![profhase85](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@profhase85](https://forum.ansible.com/u/profhase85)\
**Post date:** [November 18, 2014, 12:24pm UTC](https://forum.ansible.com/t/handler-include/16462/7 "2014-11-18T12:24:16Z")

</div>

Thanks, that is the way I did it. I just think that logically those three (in my case those are 7) operations are just one handler.  
(To explain that: if one file has changed, the whole application needs to be rebuilt)  
So none of the 7 handlers will ever be called alone and it would require less copy-paste (as the application needs to be rebuilt on change of multiple files)

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [November 18, 2014, 8:48pm UTC](https://forum.ansible.com/t/handler-include/16462/8 "2014-11-18T20:48:44Z")

</div>

This does make sense logically. However, since it's possible to  
invoke all the handler tasks in a fairly straightforward way this  
would probably be fairly low priority. Perhaps in the future the v2  
refactoring will make it easier for us to look into making this  
change. At the moment we're just not in a good position to see this  
implemented now.

-Toshio
