mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Add a helper to PlayIterator to recursively find the active state (#40847)
Also fixes a discovered bug in block rescue detection related to inserting
the ansible_failed_{result|task} variables when the rescue is in a nested
block.
This commit is contained in:
@@ -514,6 +514,18 @@ class PlayIterator:
|
||||
s = self.get_host_state(host)
|
||||
return self._check_failed_state(s)
|
||||
|
||||
def get_active_state(self, state):
|
||||
'''
|
||||
Finds the active state, recursively if necessary when there are child states.
|
||||
'''
|
||||
if state.run_state == self.ITERATING_TASKS and state.tasks_child_state is not None:
|
||||
return self.get_active_state(state.tasks_child_state)
|
||||
elif state.run_state == self.ITERATING_RESCUE and state.rescue_child_state is not None:
|
||||
return self.get_active_state(state.rescue_child_state)
|
||||
elif state.run_state == self.ITERATING_ALWAYS and state.always_child_state is not None:
|
||||
return self.get_active_state(state.always_child_state)
|
||||
return state
|
||||
|
||||
def get_original_task(self, host, task):
|
||||
# now a noop because we've changed the way we do caching
|
||||
return (None, None)
|
||||
|
||||
Reference in New Issue
Block a user