mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-14 04:09:11 -07:00
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:
parent
75cff7129c
commit
2e87c1f74e
27 changed files with 387 additions and 179 deletions
|
@ -23,20 +23,27 @@ import os
|
|||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.boolean import boolean
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
def run(self, tmp=None, task_vars=dict()):
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
if task_vars is None:
|
||||
task_vars = dict()
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
src = self._task.args.get('src', None)
|
||||
dest = self._task.args.get('dest', None)
|
||||
remote_src = boolean(self._task.args.get('remote_src', 'no'))
|
||||
|
||||
if src is None:
|
||||
return dict(failed=True, msg="src is required")
|
||||
result['failed'] = True
|
||||
result['msg'] = "src is required"
|
||||
return result
|
||||
elif remote_src:
|
||||
# everything is remote, so we just execute the module
|
||||
# without changing any of the module arguments
|
||||
return self._execute_module(task_vars=task_vars)
|
||||
result.update(self._execute_module(task_vars=task_vars))
|
||||
return result
|
||||
|
||||
if self._task._role is not None:
|
||||
src = self._loader.path_dwim_relative(self._task._role._role_path, 'files', src)
|
||||
|
@ -61,4 +68,5 @@ class ActionModule(ActionBase):
|
|||
)
|
||||
)
|
||||
|
||||
return self._execute_module('patch', module_args=new_module_args, task_vars=task_vars)
|
||||
result.update(self._execute_module('patch', module_args=new_module_args, task_vars=task_vars))
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue