The handler in my code fails in some cases which then causes the whole playbook run to crash and I would like to catch those failures in the handler and do some sort of clean up.
Here's my playbook where I would ideally like the Rescue when handler fails task to run:
- hosts: localhost
tasks:
- name: something something
block:
- name: Print a message
debug: msg='I execute normally'
changed_when: yes
notify: failing handler
rescue:
- name: Rescue when handler fails
debug:
msg: 'Rescue'
handlers:
- name: failing handler
command: /bin/false
How can I catch the failure from this failing handler and run some tasks for cleanup?