Ensure the "attempts" key is set in the final result for do/until loops
Fixes #17258
This commit is contained in:
parent
7e0074263d
commit
657506cddd
1 changed files with 2 additions and 1 deletions
|
@ -539,12 +539,12 @@ class TaskExecutor:
|
|||
if retries > 1:
|
||||
cond = Conditional(loader=self._loader)
|
||||
cond.when = self._task.until
|
||||
result['attempts'] = attempt
|
||||
if cond.evaluate_conditional(templar, vars_copy):
|
||||
break
|
||||
else:
|
||||
# no conditional check, or it failed, so sleep for the specified time
|
||||
if attempt < retries:
|
||||
result['attempts'] = attempt
|
||||
result['_ansible_retry'] = True
|
||||
result['retries'] = retries
|
||||
display.debug('Retrying task, attempt %d of %d' % (attempt, retries))
|
||||
|
@ -553,6 +553,7 @@ class TaskExecutor:
|
|||
else:
|
||||
if retries > 1:
|
||||
# we ran out of attempts, so mark the result as failed
|
||||
result['attempts'] = retries - 1
|
||||
result['failed'] = True
|
||||
|
||||
# do the final update of the local variables here, for both registered
|
||||
|
|
Loading…
Add table
Reference in a new issue