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