Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of mktemp dependency to support AIX #437

Merged
merged 1 commit into from
Jun 1, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 10 additions & 12 deletions lib/ansible/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def _executor_internal(self, host):
cache = self.setup_cache.get(host, {})
module_name = utils.template(self.module_name, cache, self.setup_cache)

tmp = self._get_tmp_path(conn)
tmp = self._make_tmp_path(conn)
result = None

if self.module_name == 'copy':
Expand Down Expand Up @@ -691,22 +691,20 @@ def _low_level_exec_command(self, conn, cmd, tmp, sudoable=False):

# *****************************************************

def _get_tmp_path(self, conn):
''' gets a temporary path on a remote box '''
def _make_tmp_path(self, conn):
''' make and return a temporary path on a remote box '''

basetmp = C.DEFAULT_REMOTE_TMP
if self.remote_user == 'root':
basetmp ="/var/tmp"
cmd = "mktemp -d %s/ansible.XXXXXX" % basetmp
basetmp = "/var/tmp"
basetmp = os.path.join(basetmp, 'ansible-%s-%s' % (time.time(), random.randint(0, 2**48)))

cmd = "mkdir -p %s" % basetmp
if self.remote_user != 'root':
cmd = "mkdir -p %s && %s" % (basetmp, cmd)
cmd += " && chmod a+x %s" % basetmp

result = self._low_level_exec_command(conn, cmd, None, sudoable=False)
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
return basetmp


# *****************************************************
Expand All @@ -720,7 +718,7 @@ def _copy_module(self, conn, tmp, module):
if not os.path.exists(in_path):
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)

out_path = tmp + module
out_path = os.path.join(tmp, module)
conn.put_file(in_path, out_path)
return out_path

Expand Down