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:
parent
fb2c1d4577
commit
aea52c67d6
1 changed files with 12 additions and 0 deletions
|
@ -25,6 +25,7 @@ __metaclass__ = type
|
||||||
__requires__ = ['ansible']
|
__requires__ = ['ansible']
|
||||||
|
|
||||||
|
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
@ -100,6 +101,17 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
raise
|
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:
|
try:
|
||||||
args = [to_text(a, errors='surrogate_or_strict') for a in sys.argv]
|
args = [to_text(a, errors='surrogate_or_strict') for a in sys.argv]
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
|
|
Loading…
Reference in a new issue