Skip to content

Commit

Permalink
Move complex_args templating to be with module_args
Browse files Browse the repository at this point in the history
Keeps every action plugin from having to do the same thing.
  • Loading branch information
dhozac committed Mar 7, 2013
1 parent ffbd4b5 commit 76f3351
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/ansible/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def _executor_internal(self, host):
# 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
Expand All @@ -362,7 +362,7 @@ def _executor_internal(self, host):
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
Expand All @@ -387,7 +387,7 @@ def _executor_internal(self, host):

# *****************************************************

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 '''


Expand All @@ -401,7 +401,7 @@ def _executor_internal_inner(self, host, module_name, module_args, inject, port,

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:
Expand Down Expand Up @@ -479,7 +479,7 @@ def _executor_internal_inner(self, host, module_name, module_args, inject, port,
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()

Expand Down
2 changes: 0 additions & 2 deletions lib/ansible/runner/action_plugins/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **
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")
Expand Down
1 change: 0 additions & 1 deletion lib/ansible/runner/action_plugins/normal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(self, runner):
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:
Expand Down
2 changes: 0 additions & 2 deletions lib/ansible/runner/action_plugins/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **
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)
Expand Down

0 comments on commit 76f3351

Please sign in to comment.