mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
Configure retry file usage and location
Adds new settings for managing retry files: * retry_files_enabled, defaults to True * retry_files_save_path, defaults to ~/.ansible-retry This change was adapted from PR #5515.
This commit is contained in:
parent
34129a223d
commit
c15b47fb7b
3 changed files with 18 additions and 6 deletions
|
@ -636,19 +636,28 @@ class PlayBook(object):
|
|||
buf = StringIO.StringIO()
|
||||
for x in replay_hosts:
|
||||
buf.write("%s\n" % x)
|
||||
basedir = self.inventory.basedir()
|
||||
basedir = C.shell_expand_path(C.RETRY_FILES_SAVE_PATH)
|
||||
filename = "%s.retry" % os.path.basename(self.filename)
|
||||
filename = filename.replace(".yml","")
|
||||
filename = os.path.join(os.path.expandvars('$HOME/'), filename)
|
||||
filename = os.path.join(basedir, filename)
|
||||
|
||||
try:
|
||||
if not os.path.exists(basedir):
|
||||
os.makedirs(basedir)
|
||||
|
||||
fd = open(filename, 'w')
|
||||
fd.write(buf.getvalue())
|
||||
fd.close()
|
||||
return filename
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
ansible.callbacks.display(
|
||||
"\nERROR: could not create retry file. Check the value of \n"
|
||||
+ "the configuration variable 'retry_files_save_path' or set \n"
|
||||
+ "'retry_files_enabled' to False to avoid this message.\n",
|
||||
color='red'
|
||||
)
|
||||
return None
|
||||
|
||||
return filename
|
||||
|
||||
# *****************************************************
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue