Make script module use raw module so it does not require python

This commit is contained in:
Dag Wieers 2012-12-23 22:20:34 +01:00
parent 3d3deb9797
commit eb36ff45b9
3 changed files with 26 additions and 15 deletions

View file

@ -34,9 +34,6 @@ class ActionModule(object):
def run(self, conn, tmp, module_name, module_args, inject):
''' handler for file transfer operations '''
# load up options
options = utils.parse_kv(module_args)
tokens = shlex.split(module_args)
source = tokens[0]
# FIXME: error handling
@ -44,8 +41,6 @@ class ActionModule(object):
source = utils.template(self.runner.basedir, source, inject)
source = utils.path_dwim(self.runner.basedir, source)
exec_rc = None
# 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?
@ -56,12 +51,18 @@ 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" % tmp_src, tmp)
prepcmd = 'chmod a+rx %s' % tmp_src
else:
prepcmd = 'chmod +x %s' % tmp_src
# make executable
self.runner._low_level_exec_command(conn, "chmod +x %s" % tmp_src, tmp)
# add preparation steps to one ssh roundtrip executing the script
module_args = prepcmd + '; ' + tmp_src + ' ' + args
# run it through the command module
module_args = tmp_src + " " + args + " #USE_SHELL"
return self.runner._execute_module(conn, tmp, 'command', module_args, inject=inject)
handler = utils.plugins.action_loader.get('raw', self.runner)
result = handler.run(conn, tmp, 'raw', module_args, inject)
# clean up after
if tmp.find("tmp") != -1 and C.DEFAULT_KEEP_REMOTE_FILES != '1':
self.runner._low_level_exec_command(conn, 'rm -rf %s >/dev/null 2>&1' % tmp, tmp)
return result