Is it possible to have truly global handlers in Ansible so that I can "notify" the handler from any task of any role of any playbook? And without explicitly importing.
I just want to define a handler once (say "restart httpd") and have it available to any "notify" directive anywhere.
Thanks!
Best Answer
You could define your handlers within your play instead of within roles. Handlers defined in a play would be available to all tasks/roles under that play.
You are able to use import if you wanted in the handlers section too.
Note that you need a 'static include' (per https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html#handlers-running-operations-on-change), so
import_tasks
must be used instead ofinclude_tasks
: