From 948682dbe20a693c011f4fde5604debeafd3a524 Mon Sep 17 00:00:00 2001
From: James Cammarata <jimi@sngx.net>
Date: Thu, 23 Jun 2016 18:07:11 -0500
Subject: [PATCH] Fix off-by-one error with retries

Fixes #16408
---
 lib/ansible/executor/task_executor.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py
index f45b56af85..fb6e1908a7 100644
--- a/lib/ansible/executor/task_executor.py
+++ b/lib/ansible/executor/task_executor.py
@@ -423,9 +423,11 @@ class TaskExecutor:
 
         # Read some values from the task, so that we can modify them if need be
         if self._task.until:
-            retries = self._task.retries
+            retries = self._task.retries + 1
             if retries is None:
                 retries = 3
+            elif retries <= 0:
+                retries = 1
         else:
             retries = 1