Normalize usage of temp and tmp on tmp (#36221)

* Normalize usage of temp and tmp on tmp
* Rename system_tmps system_tmpdirs
* Add ANSIBLE_REMOTE_TMP spelling of environment variables
This commit is contained in:
Toshio Kuratomi 2018-02-15 09:01:02 -08:00 committed by GitHub
parent 2678508d42
commit 06f73ad578
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 99 additions and 92 deletions

View file

@ -47,7 +47,7 @@ PASS_VARS = {
'shell_executable': '_shell',
'socket': '_socket_path',
'syslog_facility': '_syslog_facility',
'tempdir': 'tempdir',
'tmpdir': 'tmpdir',
'verbosity': '_verbosity',
'version': 'ansible_version',
}
@ -2199,7 +2199,7 @@ class AnsibleModule(object):
except:
# we don't have access to the cwd, probably because of sudo.
# Try and move to a neutral location to prevent errors
for cwd in [self.tempdir, os.path.expandvars('$HOME'), tempfile.gettempdir()]:
for cwd in [self.tmpdir, os.path.expandvars('$HOME'), tempfile.gettempdir()]:
try:
if os.access(cwd, os.F_OK | os.R_OK):
os.chdir(cwd)
@ -2511,7 +2511,7 @@ class AnsibleModule(object):
# would end in something like:
# file = _os.path.join(dir, pre + name + suf)
# TypeError: can't concat bytes to str
error_msg = ('Failed creating temp file for atomic move. This usually happens when using Python3 less than Python3.5. '
error_msg = ('Failed creating tmp file for atomic move. This usually happens when using Python3 less than Python3.5. '
'Please use Python2.x or Python3.5 or greater.')
finally:
if error_msg:
@ -2531,7 +2531,7 @@ class AnsibleModule(object):
try:
shutil.move(b_src, b_tmp_dest_name)
except OSError:
# cleanup will happen by 'rm' of tempdir
# cleanup will happen by 'rm' of tmpdir
# copy2 will preserve some metadata
shutil.copy2(b_src, b_tmp_dest_name)