Two fixes to action plugins

* Fix the task_vars parameter to not default to a mutable type (dict)
* Implement invocation in the base class's run() method have each action
  module call the run() method's implemention in the base class.
* Return values from the action plugins' run() method takes the return
  value from the base class run() method into account so that invocation
  makes its way to the output.

Fixes #12869
This commit is contained in:
Toshio Kuratomi 2015-10-22 16:07:26 -07:00
parent 75cff7129c
commit 2e87c1f74e
27 changed files with 387 additions and 179 deletions

View file

@ -101,8 +101,12 @@ class ActionModule(ActionBase):
if key.startswith("ansible_") and key.endswith("_interpreter"):
task_vars[key] = localhost[key]
def run(self, tmp=None, task_vars=dict()):
def run(self, tmp=None, task_vars=None):
''' generates params and passes them on to the rsync module '''
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars)
original_transport = task_vars.get('ansible_connection') or self._play_context.connection
remote_transport = False
@ -124,7 +128,7 @@ class ActionModule(ActionBase):
# ansible's delegate_to mechanism to determine which host rsync is
# running on so localhost could be a non-controller machine if
# delegate_to is used)
src_host = '127.0.0.1'
src_host = '127.0.0.1'
inventory_hostname = task_vars.get('inventory_hostname')
dest_host_inventory_vars = task_vars['hostvars'].get(inventory_hostname)
dest_host = dest_host_inventory_vars.get('ansible_ssh_host', inventory_hostname)
@ -236,7 +240,7 @@ class ActionModule(ActionBase):
self._task.args['ssh_args'] = C.ANSIBLE_SSH_ARGS
# run the module and store the result
result = self._execute_module('synchronize', task_vars=task_vars)
result.update(self._execute_module('synchronize', task_vars=task_vars))
if 'SyntaxError' in result['msg']:
# Emit a warning about using python3 because synchronize is