1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Use a mktemp'd path for uploading modules

This commit is contained in:
Jeremy Katz 2012-02-23 21:01:02 -05:00
parent bd37864242
commit 25df80ff58

View file

@ -120,6 +120,7 @@ class Runner(object):
self._exec_command(conn, "chmod +x %s" % outpath)
cmd = self._command(outpath)
result = self._exec_command(conn, cmd)
self._exec_command(conn, "rm -f %s" % outpath)
conn.close()
return [ host, True, json.loads(result) ]
else:
@ -142,15 +143,17 @@ class Runner(object):
results = "\n".join(stdout.readlines())
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):
''' transfer a module over SFTP '''
in_path = os.path.expanduser(
os.path.join(self.module_path, self.module_name)
)
out_path = os.path.join(
"/var/spool/",
"ansible_%s" % self.module_name
)
out_path = self._get_tmp_path(conn, "ansible_%s" % self.module_name)
sftp = conn.open_sftp()
sftp.put(in_path, out_path)
sftp.close()