@ -535,7 +535,7 @@ class TaskExecutor:
# update the local copy of vars with the registered value, if specified,
# update the local copy of vars with the registered value, if specified,
# or any facts which may have been generated by the module execution
# or any facts which may have been generated by the module execution
if self . _task . register :
if self . _task . register :
vars_copy [ self . _task . register ] = wrap_var ( result . copy ( ) )
vars_copy [ self . _task . register ] = wrap_var ( result )
if self . _task . async_val > 0 :
if self . _task . async_val > 0 :
if self . _task . poll > 0 and not result . get ( ' skipped ' ) and not result . get ( ' failed ' ) :
if self . _task . poll > 0 and not result . get ( ' skipped ' ) and not result . get ( ' failed ' ) :
@ -575,10 +575,20 @@ class TaskExecutor:
else :
else :
result [ ' failed ' ] = False
result [ ' failed ' ] = False
# Make attempts and retries available early to allow their use in changed/failed_when
result [ ' attempts ' ] = attempt
# set the changed property if it was missing.
# set the changed property if it was missing.
if ' changed ' not in result :
if ' changed ' not in result :
result [ ' changed ' ] = False
result [ ' changed ' ] = False
# re-update the local copy of vars with the registered value, if specified,
# or any facts which may have been generated by the module execution
# This gives changed/failed_when access to additional recently modified
# attributes of result
if self . _task . register :
vars_copy [ self . _task . register ] = wrap_var ( result )
# if we didn't skip this task, use the helpers to evaluate the changed/
# if we didn't skip this task, use the helpers to evaluate the changed/
# failed_when properties
# failed_when properties
if ' skipped ' not in result :
if ' skipped ' not in result :
@ -588,7 +598,6 @@ class TaskExecutor:
if retries > 1 :
if retries > 1 :
cond = Conditional ( loader = self . _loader )
cond = Conditional ( loader = self . _loader )
cond . when = self . _task . until
cond . when = self . _task . until
result [ ' attempts ' ] = attempt
if cond . evaluate_conditional ( templar , vars_copy ) :
if cond . evaluate_conditional ( templar , vars_copy ) :
break
break
else :
else :