cross-posted from: https://lemmy.ml/post/4593804
Originally discussed on Matrix.
TLDR; Ansible handlers are added to the global namespace.
Suppose you’ve got a role which defines a handler
MyHandler
:
- name: MyHandler ... listen: "some-topic"
Each time you
import
/include
your role, a new reference toMyHandler
is added to the global namespace.As a result, when you
notify
your handler via the topics itlisten
s to (ienotify: "some-topic"
), all the references toMyHandler
will be executed by Ansible.If that’s not what you want, you should
notify
the handler by name (ienotify: MyHandler
) in which case Ansible will stop searching for other references as soon as it finds the first occurrence ofMyHandler
. That meansMyHandler
will be executed only once.
You must log in or # to comment.