Pass module arguments as argument instead of keeping it in runner

This commit is contained in:
Daniel Hokka Zakrisson
2012-09-21 10:42:27 +02:00
parent 3939f7a812
commit 34f7e6ffa0
9 changed files with 48 additions and 66 deletions

View File

@@ -32,12 +32,12 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject=None):
def run(self, conn, tmp, module_name, module_args, inject=None):
''' handler for assemble operations '''
# FIXME: since assemble is ported over to the use the new common logic, this method
# is actually unneccessary as it can decide to daisychain via it's own module returns.
# make assemble return daisychain_args and this will go away.
return self.runner._execute_module(conn, tmp, 'assemble', self.runner.module_args, inject=inject).daisychain('file')
return self.runner._execute_module(conn, tmp, 'assemble', module_args, inject=inject).daisychain('file', module_args)

View File

@@ -32,16 +32,15 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject):
def run(self, conn, tmp, module_name, module_args, inject):
''' transfer the given module name, plus the async module, then run it '''
# shell and command module are the same
module_args = self.runner.module_args
if module_name == 'shell':
module_name = 'command'
module_args += " #USE_SHELL"
(module_path, is_new_style) = self.runner._copy_module(conn, tmp, module_name, inject)
(module_path, is_new_style) = self.runner._copy_module(conn, tmp, module_name, module_args, inject)
self.runner._low_level_exec_command(conn, "chmod a+rx %s" % module_path, tmp)
return self.runner._execute_module(conn, tmp, 'async_wrapper', module_args,

View File

@@ -32,11 +32,11 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject):
def run(self, conn, tmp, module_name, module_args, inject):
''' handler for file transfer operations '''
# load up options
options = utils.parse_kv(self.runner.module_args)
options = utils.parse_kv(module_args)
source = options.get('src', None)
dest = options.get('dest', None)
if (source is None and not 'first_available_file' in inject) or dest is None:
@@ -77,11 +77,11 @@ class ActionModule(object):
self.runner._low_level_exec_command(conn, "chmod a+r %s" % tmp_src, tmp)
# run the copy module
self.runner.module_args = "%s src=%s" % (self.runner.module_args, tmp_src)
return self.runner._execute_module(conn, tmp, 'copy', self.runner.module_args, inject=inject).daisychain('file')
module_args = "%s src=%s" % (module_args, tmp_src)
return self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject).daisychain('file', module_args)
else:
# no need to transfer the file, already correct md5
result = dict(changed=False, md5sum=remote_md5, transferred=False)
return ReturnData(conn=conn, result=result).daisychain('file')
return ReturnData(conn=conn, result=result).daisychain('file', module_args)

View File

@@ -32,11 +32,11 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject):
def run(self, conn, tmp, module_name, module_args, inject):
''' handler for fetch operations '''
# load up options
options = utils.parse_kv(self.runner.module_args)
options = utils.parse_kv(module_args)
source = options.get('src', None)
dest = options.get('dest', None)
if source is None or dest is None:

View File

@@ -33,15 +33,15 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject):
def run(self, conn, tmp, module_name, module_args, inject):
''' transfer & execute a module that is not 'copy' or 'template' '''
# shell and command are the same module
if module_name == 'shell':
module_name = 'command'
self.runner.module_args += " #USE_SHELL"
module_args += " #USE_SHELL"
vv("REMOTE_MODULE %s %s" % (module_name, self.runner.module_args), host=conn.host)
return self.runner._execute_module(conn, tmp, module_name, self.runner.module_args, inject=inject)
vv("REMOTE_MODULE %s %s" % (module_name, module_args), host=conn.host)
return self.runner._execute_module(conn, tmp, module_name, module_args, inject=inject)

View File

@@ -32,8 +32,8 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject):
def run(self, conn, tmp, module_name, module_args, inject):
return ReturnData(conn=conn, result=dict(
stdout=self.runner._low_level_exec_command(conn, self.runner.module_args.encode('utf-8'), tmp, sudoable=True)
stdout=self.runner._low_level_exec_command(conn, module_args.encode('utf-8'), tmp, sudoable=True)
))

View File

@@ -32,14 +32,14 @@ class ActionModule(object):
def __init__(self, runner):
self.runner = runner
def run(self, conn, tmp, module_name, inject):
def run(self, conn, tmp, module_name, module_args, inject):
''' handler for template operations '''
if not self.runner.is_playbook:
raise errors.AnsibleError("in current versions of ansible, templates are only usable in playbooks")
# load up options
options = utils.parse_kv(self.runner.module_args)
options = utils.parse_kv(module_args)
source = options.get('src', None)
dest = options.get('dest', None)
if (source is None and 'first_available_file' not in inject) or dest is None:
@@ -75,7 +75,7 @@ class ActionModule(object):
self.runner._low_level_exec_command(conn, "chmod a+r %s" % xfered,
tmp)
# run the copy module, queue the file module
self.runner.module_args = "%s src=%s dest=%s" % (self.runner.module_args, xfered, dest)
return self.runner._execute_module(conn, tmp, 'copy', self.runner.module_args, inject=inject).daisychain('file')
module_args = "%s src=%s dest=%s" % (module_args, xfered, dest)
return self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject).daisychain('file', module_args)