1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
- hosts: A,B gather_facts: false tasks: - block: - command: echo notify: sometimes_fail - meta: flush_handlers rescue: - debug: msg: 'rescue ran' always: - debug: msg: 'always ran' - debug: msg: 'should run for both hosts' handlers: - name: sometimes_fail fail: when: inventory_hostname == 'A'