mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #2 from katzj/non-root-mktemp
Use a mktemp'd path for uploading modules
This commit is contained in:
commit
0ac8e565c2
1 changed files with 7 additions and 4 deletions
|
@ -120,6 +120,7 @@ class Runner(object):
|
||||||
self._exec_command(conn, "chmod +x %s" % outpath)
|
self._exec_command(conn, "chmod +x %s" % outpath)
|
||||||
cmd = self._command(outpath)
|
cmd = self._command(outpath)
|
||||||
result = self._exec_command(conn, cmd)
|
result = self._exec_command(conn, cmd)
|
||||||
|
self._exec_command(conn, "rm -f %s" % outpath)
|
||||||
conn.close()
|
conn.close()
|
||||||
return [ host, True, json.loads(result) ]
|
return [ host, True, json.loads(result) ]
|
||||||
else:
|
else:
|
||||||
|
@ -142,15 +143,17 @@ class Runner(object):
|
||||||
results = "\n".join(stdout.readlines())
|
results = "\n".join(stdout.readlines())
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def _get_tmp_path(self, conn, file_name):
|
||||||
|
output = self._exec_command(conn, "mktemp /tmp/%s.XXXXXX" % file_name)
|
||||||
|
return output.split("\n")[0]
|
||||||
|
|
||||||
def _copy_module(self, conn):
|
def _copy_module(self, conn):
|
||||||
''' transfer a module over SFTP '''
|
''' transfer a module over SFTP '''
|
||||||
in_path = os.path.expanduser(
|
in_path = os.path.expanduser(
|
||||||
os.path.join(self.module_path, self.module_name)
|
os.path.join(self.module_path, self.module_name)
|
||||||
)
|
)
|
||||||
out_path = os.path.join(
|
out_path = self._get_tmp_path(conn, "ansible_%s" % self.module_name)
|
||||||
"/var/spool/",
|
|
||||||
"ansible_%s" % self.module_name
|
|
||||||
)
|
|
||||||
sftp = conn.open_sftp()
|
sftp = conn.open_sftp()
|
||||||
sftp.put(in_path, out_path)
|
sftp.put(in_path, out_path)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
|
|
Loading…
Reference in a new issue