mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Move complex_args templating to be with module_args
Keeps every action plugin from having to do the same thing.
This commit is contained in:
parent
ffbd4b5a2c
commit
76f3351b02
4 changed files with 5 additions and 10 deletions
|
@ -351,7 +351,7 @@ class Runner(object):
|
|||
# logic to decide how to run things depends on whether with_items is used
|
||||
|
||||
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:
|
||||
# executing using with_items, so make multiple calls
|
||||
# TODO: refactor
|
||||
|
@ -362,7 +362,7 @@ class Runner(object):
|
|||
results = []
|
||||
for x in items:
|
||||
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)
|
||||
if result.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 '''
|
||||
|
||||
|
||||
|
@ -401,7 +401,7 @@ class Runner(object):
|
|||
|
||||
module_name = utils.template(self.basedir, module_name, 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 self.background != 0:
|
||||
|
@ -479,7 +479,7 @@ class Runner(object):
|
|||
if getattr(handler, 'NEEDS_TMPPATH', True):
|
||||
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()
|
||||
|
||||
|
|
|
@ -36,10 +36,8 @@ class ActionModule(object):
|
|||
if complex_args:
|
||||
options.update(complex_args)
|
||||
options.update(utils.parse_kv(module_args))
|
||||
options = utils.template(self.runner.basedir, options, inject)
|
||||
source = options.get('src', 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:
|
||||
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):
|
||||
''' 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)
|
||||
|
||||
if self.runner.check:
|
||||
|
|
|
@ -41,8 +41,6 @@ class ActionModule(object):
|
|||
if complex_args:
|
||||
options.update(complex_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)
|
||||
dest = options.get('dest', None)
|
||||
|
|
Loading…
Reference in a new issue