mirror of https://github.com/ansible/ansible.git
Register handlers immediately if currently iterating handlers (#80898)
This fixes the issue where handlers notifying other handlers are not properly run because the notification is not registered unless another flush_handlers occurs. Instead, if the current host state is iterating handlers we immediately register the handler to be run so the notification is not lost. Fixes #80880pull/81063/head
parent
73e04ef2d6
commit
660f1726c8
@ -0,0 +1,4 @@
|
||||
bugfixes:
|
||||
- "From issue https://github.com/ansible/ansible/issues/80880, when notifying a
|
||||
handler from another handler, handler notifications must be registered
|
||||
immediately as the flush_handler call is not recursive."
|
@ -0,0 +1,34 @@
|
||||
---
|
||||
- name: Test notification of handlers from other handlers
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
handlers:
|
||||
- name: Handler 1
|
||||
debug:
|
||||
msg: Handler 1
|
||||
changed_when: true
|
||||
notify: Handler 2
|
||||
register: handler1_res
|
||||
- name: Handler 2
|
||||
debug:
|
||||
msg: Handler 2
|
||||
changed_when: true
|
||||
notify: Handler 3
|
||||
register: handler2_res
|
||||
- name: Handler 3
|
||||
debug:
|
||||
msg: Handler 3
|
||||
register: handler3_res
|
||||
tasks:
|
||||
- name: Trigger handlers
|
||||
ansible.builtin.debug:
|
||||
msg: Task 1
|
||||
changed_when: true
|
||||
notify: Handler 1
|
||||
post_tasks:
|
||||
- name: Assert results
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "handler1_res is defined and handler1_res is success"
|
||||
- "handler2_res is defined and handler2_res is success"
|
||||
- "handler3_res is defined and handler3_res is success"
|
Loading…
Reference in New Issue