mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
better handling of retry files
This commit is contained in:
parent
de18566882
commit
734bbcb1d3
1 changed files with 6 additions and 5 deletions
|
@ -28,7 +28,7 @@ from ansible.executor.task_queue_manager import TaskQueueManager
|
||||||
from ansible.playbook import Playbook
|
from ansible.playbook import Playbook
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
from ansible.utils.path import makedirs_safe
|
from ansible.utils.path import makedirs_safe
|
||||||
from ansible.utils.unicode import to_unicode
|
from ansible.utils.unicode import to_unicode, to_str
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from __main__ import display
|
from __main__ import display
|
||||||
|
@ -185,8 +185,10 @@ class PlaybookExecutor:
|
||||||
if len(retries) > 0:
|
if len(retries) > 0:
|
||||||
if C.RETRY_FILES_SAVE_PATH:
|
if C.RETRY_FILES_SAVE_PATH:
|
||||||
basedir = C.shell_expand(C.RETRY_FILES_SAVE_PATH)
|
basedir = C.shell_expand(C.RETRY_FILES_SAVE_PATH)
|
||||||
else:
|
elif playbook_path:
|
||||||
basedir = os.path.dirname(playbook_path)
|
basedir = os.path.dirname(playbook_path)
|
||||||
|
else:
|
||||||
|
basedir = '~/'
|
||||||
|
|
||||||
(retry_name, _) = os.path.splitext(os.path.basename(playbook_path))
|
(retry_name, _) = os.path.splitext(os.path.basename(playbook_path))
|
||||||
filename = os.path.join(basedir, "%s.retry" % retry_name)
|
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
|
re-running on ONLY the failed hosts. This may duplicate some variable
|
||||||
information in group_vars/host_vars but that is ok, and expected.
|
information in group_vars/host_vars but that is ok, and expected.
|
||||||
'''
|
'''
|
||||||
makedirs_safe(os.path.dirname(retry_path))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
makedirs_safe(os.path.dirname(retry_path))
|
||||||
with open(retry_path, 'w') as fd:
|
with open(retry_path, 'w') as fd:
|
||||||
for x in replay_hosts:
|
for x in replay_hosts:
|
||||||
fd.write("%s\n" % x)
|
fd.write("%s\n" % x)
|
||||||
except Exception as e:
|
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 False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue