From 657506cddd1921b349d6ec593135bc39395fc006 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Sun, 2 Oct 2016 01:05:36 -0500 Subject: [PATCH] Ensure the "attempts" key is set in the final result for do/until loops Fixes #17258 --- lib/ansible/executor/task_executor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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