From c476ed93cab130740addadba7c93348f84339c4f Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 18 Oct 2013 16:52:15 -0400 Subject: [PATCH] now correctly changes script permission in all cases Signed-off-by: Brian Coca --- lib/ansible/runner/action_plugins/script.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/runner/action_plugins/script.py b/lib/ansible/runner/action_plugins/script.py index c0b96d3ee04..c65e8cc8d18 100644 --- a/lib/ansible/runner/action_plugins/script.py +++ b/lib/ansible/runner/action_plugins/script.py @@ -58,15 +58,18 @@ class ActionModule(object): conn.put_file(source, tmp_src) - # fix file permissions when the copy is done as a different user + sudoable=True + # set file permissions, more permisive when the copy is done as a different user if self.runner.sudo and self.runner.sudo_user != 'root': - prepcmd = 'chmod a+rx %s' % tmp_src + cmd_args_chmod = "chmod a+rx %s" % tmp_src + sudoable=False else: - prepcmd = 'chmod +x %s' % tmp_src + cmd_args_chmod = "chmod +rx %s" % tmp_src + self.runner._low_level_exec_command(conn, cmd_args_chmod, tmp, sudoable=sudoable) # add preparation steps to one ssh roundtrip executing the script env_string = self.runner._compute_environment_string(inject) - module_args = prepcmd + '; ' + env_string + tmp_src + ' ' + args + module_args = env_string + tmp_src + ' ' + args handler = utils.plugins.action_loader.get('raw', self.runner) result = handler.run(conn, tmp, 'raw', module_args, inject)