[stable-2.19] Expose ansible_failed_task in rescue for explicit flush_handlers (#85687) (#85707)

Fixes #85682

(cherry picked from commit c5ddc93767)
This commit is contained in:
Martin Krizek
2025-09-02 16:20:30 -07:00
committed by GitHub
parent 9aea625f63
commit 764070de69
4 changed files with 21 additions and 1 deletions
@@ -0,0 +1,16 @@
- hosts: localhost
gather_facts: false
tasks:
- block:
- debug:
changed_when: true
notify: h1
- meta: flush_handlers
rescue:
- assert:
that:
- ansible_failed_task is defined
handlers:
- name: h1
fail:
@@ -230,3 +230,5 @@ ansible-playbook handler_notify_earlier_handler.yml "$@" 2>&1 | tee out.txt
ANSIBLE_DEBUG=1 ansible-playbook tagged_play.yml --skip-tags the_whole_play "$@" 2>&1 | tee out.txt
[ "$(grep out.txt -ce 'META: triggered running handlers')" = "0" ]
[ "$(grep out.txt -ce 'handler_ran')" = "0" ]
ansible-playbook rescue_flush_handlers.yml "$@"