ansible-galaxy: create parent dir for token file (#60615)

* ansible-galaxy: create parent dir for token file

* The path unfrack is already done by config

* Move common dir creation to ansible cli

* Add warning if dir failed to be created

* remove testing path

* Make mode a position arg not kwarg
This commit is contained in:
Jordan Borean 2019-08-19 06:21:47 +10:00 committed by GitHub
parent fb2c1d4577
commit aea52c67d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ __metaclass__ = type
__requires__ = ['ansible']
import errno
import os
import shutil
import sys
@ -100,6 +101,17 @@ if __name__ == '__main__':
else:
raise
b_ansible_dir = os.path.expanduser(os.path.expandvars(b"~/.ansible"))
try:
os.mkdir(b_ansible_dir, 0o700)
except OSError as exc:
if exc.errno != errno.EEXIST:
display.warning("Failed to create the directory '%s': %s"
% (to_text(b_ansible_dir, errors='surrogate_or_replace'),
to_text(exc, errors='surrogate_or_replace')))
else:
display.debug("Created the '%s' directory" % to_text(b_ansible_dir, errors='surrogate_or_replace'))
try:
args = [to_text(a, errors='surrogate_or_strict') for a in sys.argv]
except UnicodeError: