summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2016-06-10 14:03:05 -0400
committerBrian Coca <brian.coca+git@gmail.com>2016-06-10 14:03:22 -0400
commit734bbcb1d3c9ecdbd8bd7e500b2f4881f73aa90b (patch)
tree6dab01b1097966b9e19cc179f8dcae77be583dc0
parentde185668829a95fb531d81761d1e36d4427b216b (diff)
downloadansible-734bbcb1d3c9ecdbd8bd7e500b2f4881f73aa90b.tar.gz
better handling of retry files
-rw-r--r--lib/ansible/executor/playbook_executor.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py
index 8e02441ba0..fed9ba5d52 100644
--- a/lib/ansible/executor/playbook_executor.py
+++ b/lib/ansible/executor/playbook_executor.py
@@ -28,7 +28,7 @@ from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.playbook import Playbook
from ansible.template import Templar
from ansible.utils.path import makedirs_safe
-from ansible.utils.unicode import to_unicode
+from ansible.utils.unicode import to_unicode, to_str
try:
from __main__ import display
@@ -185,8 +185,10 @@ class PlaybookExecutor:
if len(retries) > 0:
if C.RETRY_FILES_SAVE_PATH:
basedir = C.shell_expand(C.RETRY_FILES_SAVE_PATH)
- else:
+ elif playbook_path:
basedir = os.path.dirname(playbook_path)
+ else:
+ basedir = '~/'
(retry_name, _) = os.path.splitext(os.path.basename(playbook_path))
filename = os.path.join(basedir, "%s.retry" % retry_name)
@@ -258,14 +260,13 @@ class PlaybookExecutor:
re-running on ONLY the failed hosts. This may duplicate some variable
information in group_vars/host_vars but that is ok, and expected.
'''
- makedirs_safe(os.path.dirname(retry_path))
-
try:
+ makedirs_safe(os.path.dirname(retry_path))
with open(retry_path, 'w') as fd:
for x in replay_hosts:
fd.write("%s\n" % x)
except Exception as e:
- display.error("Could not create retry file '%s'. The error was: %s" % (retry_path, e))
+ display.warning("Could not create retry file '%s'.\n\t%s" % (retry_path, to_str(e)))
return False
return True