OK, let me answer my own question. Despite what I read on Google (don't
trust Google too much), one can use certain variables in a handler name. So
it is pretty easy! Just add the variable in the notify section and the name
of the handler.



On Thu, Aug 24, 2017 at 3:32 PM, Tom De Blende <[email protected]>
wrote:

> Hi all,
>
> I have a playbook with different role sections. Each section runs the same
> role, but with different variables. Now if one role signals a handler to
> restart a service with a variable name, only the first service is restarted.
>
> Let me explain:
>
> This is the handler:
>
> - name: restart service
>   service:
>     name: "{{ service_name}}"
>     state: restarted
>
>
> So the service name differs per role. So only one service is restarted,
> the first one. Which makes sense, as the handler was already signaled for
> the first occurrence.
>
> So I was reading and ran into meta: flush_handlers. So I added this at the
> end of a role-run, thinking that Ansible would restart the service, and
> flush the handlers. Well, it did run the handler, but it did not flush it.
> So when the second call was made to the handler, with a different service
> name, it was still just restarting the first service, as it was still in
> the handler.
>
> How can this behavior be changed? I want to restart the service through a
> handler, and then clean the handler before the subsequent roles are
> executed.
>
> Thanks!
> Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/0jjVccORjbA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/2ebf4236-b64f-4635-aa9e-790bbf1e67f5%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/2ebf4236-b64f-4635-aa9e-790bbf1e67f5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGV-88Ebz9GL1-ysfyhhZ6ReqZYGc%2Bz_smKqPM01LP9Z5UXcjA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to