diff options
author | James Cammarata <jimi@sngx.net> | 2016-10-02 01:05:36 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2016-10-02 01:06:13 -0500 |
commit | 657506cddd1921b349d6ec593135bc39395fc006 (patch) | |
tree | c44e596ad3dbf048e60fe707634aea964c90c20b | |
parent | 7e0074263dcc7f804693c5d2a7ff16dd9f716f7f (diff) | |
download | ansible-657506cddd1921b349d6ec593135bc39395fc006.tar.gz |
Ensure the "attempts" key is set in the final result for do/until loops
Fixes #17258
-rw-r--r-- | lib/ansible/executor/task_executor.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index e7e781106f..640a54f4d6 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -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 |