From 734bbcb1d3c9ecdbd8bd7e500b2f4881f73aa90b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 10 Jun 2016 14:03:05 -0400 Subject: [PATCH] better handling of retry files --- lib/ansible/executor/playbook_executor.py | 11 ++++++----- 1 file 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