Reputation: 21
I have an ansible playbook for some init services that are broadly similar with a few tweaks. In the top-level playbook, I include the role twice, like
roles:
- {role: "my-service", service: webserver}
- {role: "my-service", service: scheduler}
the my-service role has tasks, which write init scripts, and handlers, which (re)start the service. tasks/main.yml
looks like this:
- name: setup init scripts
template: src=../../service-common/templates/my-service.conf dest=/etc/init/my-{{ service }}.conf
notify:
- restart my service
and handlers/main.yml
has this content:
- name: restart my services
service: name=my-{{ service }} state=restarted
But after the playbook runs, we're left with only the webserver
service running, and the scheduler is stop/waiting
. How can I make the handler see these as two separate notifications to be handled?
Upvotes: 2
Views: 411
Reputation: 20719
The Ansible documentation states:
Handlers are lists of tasks, not really any different from regular tasks, that are referenced by a globally unique name.
So it doesn't make use of any parameters, variables, etc. when determining when/how to invoke a handler. Only the name is used.
Upvotes: 1