handler + include

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 with the suggestion to notify other handlers in handler which does not seem semantically appropriate)

What’s defined in handlers/redeploy.yml?

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

`

  • name: copy installation files
    copy:

  • name: run install script
    command:

  • name: restart myservice
    service:

`

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.

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?

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

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)

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