@ -275,7 +275,7 @@ class PlayIterator:
if state . pending_setup :
state . pending_setup = False
if state . fail_state & self . FAILED_TASKS == self . FAILED_TASKS :
if self . _check_failed_state ( state ) :
state . run_state = self . ITERATING_RESCUE
elif state . cur_regular_task > = len ( block . block ) :
state . run_state = self . ITERATING_ALWAYS
@ -335,7 +335,9 @@ class PlayIterator:
state . cur_rescue_task = 0
state . cur_always_task = 0
state . run_state = self . ITERATING_TASKS
state . child_state = None
state . tasks_child_state = None
state . rescue_child_state = None
state . always_child_state = None
else :
task = block . always [ state . cur_always_task ]
if isinstance ( task , Block ) or state . always_child_state is not None :
@ -365,7 +367,7 @@ class PlayIterator:
return ( state , task )
def _set_failed_state ( self , state ) :
if state . pending_setup :
if state . run_state == self . ITERATING_SETUP :
state . fail_state | = self . FAILED_SETUP
state . run_state = self . ITERATING_COMPLETE
elif state . run_state == self . ITERATING_TASKS :
@ -407,19 +409,18 @@ class PlayIterator:
def _check_failed_state ( self , state ) :
if state is None :
return False
elif state . fail_state != self . FAILED_NONE :
if state . run_state == self . ITERATING_RESCUE and state . fail_state & self . FAILED_RESCUE == 0 or \
state . run_state == self . ITERATING_ALWAYS and state . fail_state & self . FAILED_ALWAYS == 0 :
return False
else :
return True
elif state . run_state == self . ITERATING_TASKS and self . _check_failed_state ( state . tasks_child_state ) :
return True
elif state . run_state == self . ITERATING_RESCUE and self . _check_failed_state ( state . rescue_child_state ) :
return True
elif state . run_state == self . ITERATING_ALWAYS and self . _check_failed_state ( state . always_child_state ) :
return True
elif state . run_state == self . ITERATING_COMPLETE and state . fail_state != self . FAILED_NONE :
if state . run_state == self . ITERATING_RESCUE and state . fail_state & self . FAILED_RESCUE == 0 :
return False
elif state . run_state == self . ITERATING_ALWAYS and state . fail_state & self . FAILED_ALWAYS == 0 :
return False
else :
return True
return False
def is_failed ( self , host ) :