How to force handler to run before executing a task in Ansible?

If you want to force the handler to run in between the two tasks instead of at the end of the play, you need to put this between the two tasks:

- meta: flush_handlers

Example taken from the ansible documentation :

tasks:
   - shell: some tasks go here
   - meta: flush_handlers
   - shell: some other tasks

Note that this will cause all pending handlers to run at that point, not just that specific one.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)