Move complex_args templating to be with module_args

Keeps every action plugin from having to do the same thing.
pull/2335/head
Daniel Hokka Zakrisson 12 years ago
parent ffbd4b5a2c
commit 76f3351b02

@ -351,7 +351,7 @@ class Runner(object):
# logic to decide how to run things depends on whether with_items is used # logic to decide how to run things depends on whether with_items is used
if items is None: if items is None:
return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port) return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=self.complex_args)
elif len(items) > 0: elif len(items) > 0:
# executing using with_items, so make multiple calls # executing using with_items, so make multiple calls
# TODO: refactor # TODO: refactor
@ -362,7 +362,7 @@ class Runner(object):
results = [] results = []
for x in items: for x in items:
inject['item'] = x inject['item'] = x
result = self._executor_internal_inner(host, self.module_name, self.module_args, inject, port) result = self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=self.complex_args)
results.append(result.result) results.append(result.result)
if result.comm_ok == False: if result.comm_ok == False:
all_comm_ok = False all_comm_ok = False
@ -387,7 +387,7 @@ class Runner(object):
# ***************************************************** # *****************************************************
def _executor_internal_inner(self, host, module_name, module_args, inject, port, is_chained=False): def _executor_internal_inner(self, host, module_name, module_args, inject, port, is_chained=False, complex_args=None):
''' decides how to invoke a module ''' ''' decides how to invoke a module '''
@ -401,7 +401,7 @@ class Runner(object):
module_name = utils.template(self.basedir, module_name, inject) module_name = utils.template(self.basedir, module_name, inject)
module_args = utils.template(self.basedir, module_args, inject) module_args = utils.template(self.basedir, module_args, inject)
complex_args = utils.template(self.basedir, complex_args, inject)
if module_name in utils.plugins.action_loader: if module_name in utils.plugins.action_loader:
if self.background != 0: if self.background != 0:
@ -479,7 +479,7 @@ class Runner(object):
if getattr(handler, 'NEEDS_TMPPATH', True): if getattr(handler, 'NEEDS_TMPPATH', True):
tmp = self._make_tmp_path(conn) tmp = self._make_tmp_path(conn)
result = handler.run(conn, tmp, module_name, module_args, inject, self.complex_args) result = handler.run(conn, tmp, module_name, module_args, inject, complex_args)
conn.close() conn.close()

@ -36,10 +36,8 @@ class ActionModule(object):
if complex_args: if complex_args:
options.update(complex_args) options.update(complex_args)
options.update(utils.parse_kv(module_args)) options.update(utils.parse_kv(module_args))
options = utils.template(self.runner.basedir, options, inject)
source = options.get('src', None) source = options.get('src', None)
dest = options.get('dest', None) dest = options.get('dest', None)
module_args = self.runner._complex_args_hack(options, '')
if (source is None and not 'first_available_file' in inject) or dest is None: if (source is None and not 'first_available_file' in inject) or dest is None:
result=dict(failed=True, msg="src and dest are required") result=dict(failed=True, msg="src and dest are required")

@ -36,7 +36,6 @@ class ActionModule(object):
def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs): def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs):
''' transfer & execute a module that is not 'copy' or 'template' ''' ''' transfer & execute a module that is not 'copy' or 'template' '''
complex_args = utils.template(self.runner.basedir, complex_args, inject)
module_args = self.runner._complex_args_hack(complex_args, module_args) module_args = self.runner._complex_args_hack(complex_args, module_args)
if self.runner.check: if self.runner.check:

@ -41,8 +41,6 @@ class ActionModule(object):
if complex_args: if complex_args:
options.update(complex_args) options.update(complex_args)
options.update(utils.parse_kv(module_args)) options.update(utils.parse_kv(module_args))
options = utils.template(self.runner.basedir, options, inject)
module_args = self.runner._complex_args_hack(options, '')
source = options.get('src', None) source = options.get('src', None)
dest = options.get('dest', None) dest = options.get('dest', None)

Loading…
Cancel
Save