Help with force-handlers

I’m running a health-check with ansible and need to be able to clean up some processes after if the tests fail.

It seemed like a good use for handlers, but i’m having troubles getting it to work.

Gist is here
https://gist.github.com/darKoram/0a38cce21a607dacb338

For those to lazy to click :slight_smile:


 
 - name: Step1.  notify on this step

   shell: echo "Step1"
   notify: Run handler

 
 - name: Fail by force 

   fail: msg="failing"
 
 - name: Next step

   shell: echo "next step"

Not sure what’s up wih the HTML copy/paste, but it’s hard to collapse and skim over.

If you called a fail task, and that group is reduced to size=0, Ansible is done.

You should avoid calling a fail task if you want a handler to run later on that host, or make sure those tasks have a “failed_when: False” or “ignore_errors: True” on them, if you want to make sure the handlers continue to run.

Force handlers will force the handlers to fire as if changed events occured, but it will not make failed tasks appear successful or skip over the failure parts.