Multiple handler notifications with same handler name, only one is executed

Hello Ansible devs,

I seem to have hit a regression in Ansible 1.4.3. I have a very simple ansible playbook with one role and a handler file that contains two notification. The role calls notify against the name of the handlers (same name for both) but only the first handler is called. In Ansible 1.4.1 all handlers with the same name would be called. Could this be a bug?

Simple ansible playbook contents below:

playbook file: test_handler_problem.yml

So my original response was:

So this is completely and totally a real thing, because the handlers are stored in a giant dictionary, by name.

We don’t make that a failure because if two roles define “restart apache” that shouldn’t be a conflict someone has to resolve, nor should Apache restart twice.

Then I read what you said about it being a regression. I’m not so sure, was it a regression, or was the behavior you suggested happened in 1.4.1 actually a bug? I’d argue it was, and it got fixed.

(That being said, if you do want multiple handlers and they are slightly different, you can in fact parameterize the name of the handler, and that will work – but it can’t use an inventory-scoped variable to do it. That’s also rarely done.)

Hi Michael,

Could you give me an example of how I could accomplish this using parameterization? I basically just need to be able to have a role task call multiple notifications which in 1.4.1 was just one notify call to the same named handlers :slight_smile: I tried specifying multiple notify’s in the role task as well but it looks like only one is called there too.

This is what is available:

tasks:

  • shell: foo {{ my_port }}

notify:

  • “some handler {{ my_port }}”

handlers:

  • name: “some handler 22”
    shell: bar
  • name: “some handler 50”
    shell: baz

You can notify more than one handler

notify:
   - handler 1
   - handler 2

-jlk

thanks Jesse. I see where I went wrong.