mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Revert "Get rid of mktemp dependency to support AIX"
This reverts commit 4ad1b57b52d735393f6c6bcbd5524b947134fbf9.
This commit is contained in:
parent
4886b26ea9
commit
16f0d7b333
1 changed files with 12 additions and 10 deletions
|
@ -639,7 +639,7 @@ class Runner(object):
|
||||||
cache = self.setup_cache.get(host, {})
|
cache = self.setup_cache.get(host, {})
|
||||||
module_name = utils.template(self.module_name, cache, self.setup_cache)
|
module_name = utils.template(self.module_name, cache, self.setup_cache)
|
||||||
|
|
||||||
tmp = self._make_tmp_path(conn)
|
tmp = self._get_tmp_path(conn)
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
if self.module_name == 'copy':
|
if self.module_name == 'copy':
|
||||||
|
@ -691,20 +691,22 @@ class Runner(object):
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
|
||||||
def _make_tmp_path(self, conn):
|
def _get_tmp_path(self, conn):
|
||||||
''' make and return a temporary path on a remote box '''
|
''' gets a temporary path on a remote box '''
|
||||||
|
|
||||||
basetmp = C.DEFAULT_REMOTE_TMP
|
basetmp = C.DEFAULT_REMOTE_TMP
|
||||||
if self.remote_user == 'root':
|
if self.remote_user == 'root':
|
||||||
basetmp = "/var/tmp"
|
basetmp ="/var/tmp"
|
||||||
basetmp = os.path.join(basetmp, 'ansible-%s-%s' % (time.time(), random.randint(0, 2**48)))
|
cmd = "mktemp -d %s/ansible.XXXXXX" % basetmp
|
||||||
|
|
||||||
cmd = "mkdir -p %s" % basetmp
|
|
||||||
if self.remote_user != 'root':
|
if self.remote_user != 'root':
|
||||||
cmd += " && chmod a+x %s" % basetmp
|
cmd = "mkdir -p %s && %s" % (basetmp, cmd)
|
||||||
|
|
||||||
result = self._low_level_exec_command(conn, cmd, None, sudoable=False)
|
result = self._low_level_exec_command(conn, cmd, None, sudoable=False)
|
||||||
return basetmp
|
cleaned = result.split("\n")[0].strip() + '/'
|
||||||
|
if self.remote_user != 'root':
|
||||||
|
cmd = 'chmod a+x %s' % cleaned
|
||||||
|
self._low_level_exec_command(conn, cmd, None, sudoable=False)
|
||||||
|
return cleaned
|
||||||
|
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
@ -718,7 +720,7 @@ class Runner(object):
|
||||||
if not os.path.exists(in_path):
|
if not os.path.exists(in_path):
|
||||||
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)
|
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)
|
||||||
|
|
||||||
out_path = os.path.join(tmp, module)
|
out_path = tmp + module
|
||||||
conn.put_file(in_path, out_path)
|
conn.put_file(in_path, out_path)
|
||||||
return out_path
|
return out_path
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue