Using variables with handlers
You may want your Ansible handlers to use variables. For example, if the name of a service varies slightly by distribution, you want your output to show the exact name of the restarted service for each target machine. Avoid placing variables in the name of the handler. Since handler names are templated early on, Ansible may not have a value available for a handler name like this:
If the variable used in the handler name is not available, the entire play fails. Changing that variable mid-playwill notresult in newly created handler.
Instead, place variables in the task parameters of your handler. You can load the values usinginclude_varslike this:
While handler names can contain a template,listentopics cannot.