diff options
Diffstat (limited to 'lib/ansible/runner/action_plugins')
-rw-r--r-- | lib/ansible/runner/action_plugins/assemble.py | 2 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/async.py | 2 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/copy.py | 14 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/fetch.py | 9 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/script.py | 14 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/template.py | 4 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/unarchive.py | 4 |
7 files changed, 27 insertions, 22 deletions
diff --git a/lib/ansible/runner/action_plugins/assemble.py b/lib/ansible/runner/action_plugins/assemble.py index d99d202e24..1a980c1df4 100644 --- a/lib/ansible/runner/action_plugins/assemble.py +++ b/lib/ansible/runner/action_plugins/assemble.py @@ -119,7 +119,7 @@ class ActionModule(object): # fix file permissions when the copy is done as a different user if self.runner.sudo and self.runner.sudo_user != 'root': - self.runner._low_level_exec_command(conn, "chmod a+r %s" % xfered, tmp) + self.runner._remote_chmod(conn, 'a+r', xfered, tmp) # run the copy module module_args = "%s src=%s dest=%s original_basename=%s" % (module_args, pipes.quote(xfered), pipes.quote(dest), pipes.quote(os.path.basename(src))) diff --git a/lib/ansible/runner/action_plugins/async.py b/lib/ansible/runner/action_plugins/async.py index ac0d6e8492..dc53d6fa6c 100644 --- a/lib/ansible/runner/action_plugins/async.py +++ b/lib/ansible/runner/action_plugins/async.py @@ -37,7 +37,7 @@ class ActionModule(object): tmp = self.runner._make_tmp_path(conn) (module_path, is_new_style, shebang) = self.runner._copy_module(conn, tmp, module_name, module_args, inject, complex_args=complex_args) - self.runner._low_level_exec_command(conn, "chmod a+rx %s" % module_path, tmp) + self.runner._remote_chmod(conn, 'a+rx', module_path, tmp) return self.runner._execute_module(conn, tmp, 'async_wrapper', module_args, async_module=module_path, diff --git a/lib/ansible/runner/action_plugins/copy.py b/lib/ansible/runner/action_plugins/copy.py index df5266c4c0..c59042fb2b 100644 --- a/lib/ansible/runner/action_plugins/copy.py +++ b/lib/ansible/runner/action_plugins/copy.py @@ -136,8 +136,8 @@ class ActionModule(object): # If it's recursive copy, destination is always a dir, # explicitly mark it so (note - copy module relies on this). - if not dest.endswith("/"): - dest += "/" + if not conn.shell.path_has_trailing_slash(dest): + dest = conn.shell.join_path(dest, '') else: source_files.append((source, os.path.basename(source))) @@ -169,10 +169,10 @@ class ActionModule(object): # This is kind of optimization - if user told us destination is # dir, do path manipulation right away, otherwise we still check # for dest being a dir via remote call below. - if dest.endswith("/"): - dest_file = os.path.join(dest, source_rel) + if conn.shell.path_has_trailing_slash(dest): + dest_file = conn.shell.join_path(dest, source_rel) else: - dest_file = dest + dest_file = conn.shell.join_path(dest) # Attempt to get the remote MD5 Hash. remote_md5 = self.runner._remote_md5(conn, tmp_path, dest_file) @@ -186,7 +186,7 @@ class ActionModule(object): return ReturnData(conn=conn, result=result) else: # Append the relative source location to the destination and retry remote_md5. - dest_file = os.path.join(dest, source_rel) + dest_file = conn.shell.join_path(dest, source_rel) remote_md5 = self.runner._remote_md5(conn, tmp_path, dest_file) if remote_md5 != '1' and not force: @@ -228,7 +228,7 @@ class ActionModule(object): # fix file permissions when the copy is done as a different user if self.runner.sudo and self.runner.sudo_user != 'root' and not raw: - self.runner._low_level_exec_command(conn, "chmod a+r %s" % tmp_src, tmp_path) + self.runner._remote_chmod(conn, 'a+r', tmp_src, tmp_path) if raw: # Continue to next iteration if raw is defined. diff --git a/lib/ansible/runner/action_plugins/fetch.py b/lib/ansible/runner/action_plugins/fetch.py index 205023fad9..00622f1282 100644 --- a/lib/ansible/runner/action_plugins/fetch.py +++ b/lib/ansible/runner/action_plugins/fetch.py @@ -57,19 +57,24 @@ class ActionModule(object): return ReturnData(conn=conn, result=results) source = os.path.expanduser(source) + source = conn.shell.join_path(source) + if os.path.sep not in conn.shell.join_path('a', ''): + source_local = source.replace('\\', '/') + else: + source_local = source if flat: if dest.endswith("/"): # if the path ends with "/", we'll use the source filename as the # destination filename - base = os.path.basename(source) + base = os.path.basename(source_local) dest = os.path.join(dest, base) if not dest.startswith("/"): # if dest does not start with "/", we'll assume a relative path dest = utils.path_dwim(self.runner.basedir, dest) else: # files are saved in dest dir, with a subdir for each host, then the filename - dest = "%s/%s/%s" % (utils.path_dwim(self.runner.basedir, dest), conn.host, source) + dest = "%s/%s/%s" % (utils.path_dwim(self.runner.basedir, dest), conn.host, source_local) dest = os.path.expanduser(dest.replace("//","/")) diff --git a/lib/ansible/runner/action_plugins/script.py b/lib/ansible/runner/action_plugins/script.py index 6951d6154a..593a42d2f4 100644 --- a/lib/ansible/runner/action_plugins/script.py +++ b/lib/ansible/runner/action_plugins/script.py @@ -106,7 +106,7 @@ class ActionModule(object): # transfer the file to a remote tmp location source = source.replace('\x00', '') # why does this happen here? args = args.replace('\x00', '') # why does this happen here? - tmp_src = os.path.join(tmp, os.path.basename(source)) + tmp_src = conn.shell.join_path(tmp, os.path.basename(source)) tmp_src = tmp_src.replace('\x00', '') conn.put_file(source, tmp_src) @@ -115,22 +115,22 @@ class ActionModule(object): # set file permissions, more permisive when the copy is done as a different user if ((self.runner.sudo and self.runner.sudo_user != 'root') or (self.runner.su and self.runner.su_user != 'root')): - cmd_args_chmod = "chmod a+rx %s" % tmp_src + chmod_mode = 'a+rx' sudoable = False else: - cmd_args_chmod = "chmod +rx %s" % tmp_src - self.runner._low_level_exec_command(conn, cmd_args_chmod, tmp, sudoable=sudoable, su=self.runner.su) + chmod_mode = '+rx' + self.runner._remote_chmod(conn, chmod_mode, tmp_src, tmp, sudoable=sudoable, su=self.runner.su) # add preparation steps to one ssh roundtrip executing the script - env_string = self.runner._compute_environment_string(inject) - module_args = env_string + tmp_src + ' ' + args + env_string = self.runner._compute_environment_string(conn, inject) + module_args = ' '.join([env_string, tmp_src, args]) handler = utils.plugins.action_loader.get('raw', self.runner) result = handler.run(conn, tmp, 'raw', module_args, inject) # clean up after if "tmp" in tmp and not C.DEFAULT_KEEP_REMOTE_FILES: - self.runner._low_level_exec_command(conn, 'rm -rf %s >/dev/null 2>&1' % tmp, tmp) + self.runner._remove_tmp_path(conn, tmp) result.result['changed'] = True diff --git a/lib/ansible/runner/action_plugins/template.py b/lib/ansible/runner/action_plugins/template.py index 96d8f97a3a..623d173c09 100644 --- a/lib/ansible/runner/action_plugins/template.py +++ b/lib/ansible/runner/action_plugins/template.py @@ -79,7 +79,7 @@ class ActionModule(object): source = utils.path_dwim(self.runner.basedir, source) - if dest.endswith("/"): + if dest.endswith("/"): # CCTODO: Fix path for Windows hosts. base = os.path.basename(source) dest = os.path.join(dest, base) @@ -114,7 +114,7 @@ class ActionModule(object): # fix file permissions when the copy is done as a different user if self.runner.sudo and self.runner.sudo_user != 'root': - self.runner._low_level_exec_command(conn, "chmod a+r %s" % xfered, tmp) + self.runner._remote_chmod(conn, 'a+r', xfered, tmp) # run the copy module module_args = "%s src=%s dest=%s original_basename=%s" % (module_args, pipes.quote(xfered), pipes.quote(dest), pipes.quote(os.path.basename(source))) diff --git a/lib/ansible/runner/action_plugins/unarchive.py b/lib/ansible/runner/action_plugins/unarchive.py index c943cab514..16c0bc8117 100644 --- a/lib/ansible/runner/action_plugins/unarchive.py +++ b/lib/ansible/runner/action_plugins/unarchive.py @@ -54,7 +54,7 @@ class ActionModule(object): result = dict(failed=True, msg="src (or content) and dest are required") return ReturnData(conn=conn, result=result) - dest = os.path.expanduser(dest) + dest = os.path.expanduser(dest) # CCTODO: Fix path for Windows hosts. source = template.template(self.runner.basedir, os.path.expanduser(source), inject) if copy: if '_original_file' in inject: @@ -77,7 +77,7 @@ class ActionModule(object): # fix file permissions when the copy is done as a different user if copy: if self.runner.sudo and self.runner.sudo_user != 'root': - self.runner._low_level_exec_command(conn, "chmod a+r %s" % tmp_src, tmp) + self.runner._remote_chmod(conn, 'a+r', tmp_src, tmp) module_args = "%s src=%s original_basename=%s" % (module_args, pipes.quote(tmp_src), pipes.quote(os.path.basename(source))) else: module_args = "%s original_basename=%s" % (module_args, pipes.quote(os.path.basename(source))) |