mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 08:03:05 +02:00
Fixes #82307
(cherry picked from commit a3cdd831b3)
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- Fix handlers not being executed in lockstep using the linear strategy in some cases (https://github.com/ansible/ansible/issues/82307)
|
||||||
@@ -429,13 +429,13 @@ class PlayIterator:
|
|||||||
# might be there from previous flush
|
# might be there from previous flush
|
||||||
state.handlers = self.handlers[:]
|
state.handlers = self.handlers[:]
|
||||||
state.update_handlers = False
|
state.update_handlers = False
|
||||||
state.cur_handlers_task = 0
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
task = state.handlers[state.cur_handlers_task]
|
task = state.handlers[state.cur_handlers_task]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
task = None
|
task = None
|
||||||
|
state.cur_handlers_task = 0
|
||||||
state.run_state = state.pre_flushing_run_state
|
state.run_state = state.pre_flushing_run_state
|
||||||
state.update_handlers = True
|
state.update_handlers = True
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
- hosts: A,B
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- command: echo
|
||||||
|
notify:
|
||||||
|
- handler1
|
||||||
|
- handler2
|
||||||
|
|
||||||
|
- fail:
|
||||||
|
when: inventory_hostname == "B"
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
always:
|
||||||
|
- name: always
|
||||||
|
debug:
|
||||||
|
msg: always
|
||||||
|
handlers:
|
||||||
|
- name: handler1
|
||||||
|
debug:
|
||||||
|
msg: handler1
|
||||||
|
|
||||||
|
- name: handler2
|
||||||
|
debug:
|
||||||
|
msg: handler2
|
||||||
@@ -208,3 +208,6 @@ ansible-playbook 82241.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
|
|||||||
ansible-playbook nested_flush_handlers_failure_force.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
|
ansible-playbook nested_flush_handlers_failure_force.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
|
||||||
[ "$(grep out.txt -ce 'flush_handlers_rescued')" = "1" ]
|
[ "$(grep out.txt -ce 'flush_handlers_rescued')" = "1" ]
|
||||||
[ "$(grep out.txt -ce 'flush_handlers_always')" = "2" ]
|
[ "$(grep out.txt -ce 'flush_handlers_always')" = "2" ]
|
||||||
|
|
||||||
|
ansible-playbook handlers_lockstep_82307.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
|
||||||
|
[ "$(grep out.txt -ce 'TASK \[handler2\]')" = "0" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user