In ansible playbooks, handlers (such as to restart a service) normally happen at the end of a run. If you need ansible to run a handler between two tasks, there is “flush_handlers”.
- name: flush handlers meta: flush_handlers