@ -409,10 +409,6 @@ class TaskExecutor:
display . debug ( " starting attempt loop " )
display . debug ( " starting attempt loop " )
result = None
result = None
for attempt in range ( retries ) :
for attempt in range ( retries ) :
if attempt > 0 :
display . display ( " FAILED - RETRYING: %s ( %d retries left). Result was: %s " % ( self . _task , retries - attempt , result ) , color = " dark gray " )
result [ ' attempts ' ] = attempt + 1
display . debug ( " running the handler " )
display . debug ( " running the handler " )
try :
try :
result = self . _handler . run ( task_vars = variables )
result = self . _handler . run ( task_vars = variables )
@ -469,16 +465,21 @@ class TaskExecutor:
_evaluate_failed_when_result ( result )
_evaluate_failed_when_result ( result )
if attempt < retries - 1 :
if attempt < retries - 1 :
if retries > 1 :
result [ ' attempts ' ] = attempt + 1
cond = Conditional ( loader = self . _loader )
cond = Conditional ( loader = self . _loader )
cond . when = [ self . _task . until ]
cond . when = [ self . _task . until ]
if cond . evaluate_conditional ( templar , vars_copy ) :
if cond . evaluate_conditional ( templar , vars_copy ) :
break
break
# no conditional check, or it failed, so sleep for the specified time
# no conditional check, or it failed, so sleep for the specified time
display . display ( " FAILED - RETRYING: %s ( %d retries left). Result was: %s " % ( self . _task , retries - ( attempt + 1 ) , result ) , color = C . COLOR_DEBUG )
time . sleep ( delay )
time . sleep ( delay )
else :
elif ' failed ' not in result :
if retries > 1 :
break
# we ran out of attempts, so mark the result as failed
result [ ' attempts ' ] = retries
result [ ' failed ' ] = True
# do the final update of the local variables here, for both registered
# do the final update of the local variables here, for both registered
# values and any facts which may have been created
# values and any facts which may have been created