mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -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
|
@ -25,11 +25,13 @@ class ActionModule(ActionBase):
|
|||
|
||||
TRANSFERS_FILES = False
|
||||
|
||||
def run(self, tmp=None, task_vars=dict()):
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
''' handler for package operations '''
|
||||
if task_vars is None:
|
||||
task_vars = dict()
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
name = self._task.args.get('name', None)
|
||||
state = self._task.args.get('state', None)
|
||||
module = self._task.args.get('use', 'auto')
|
||||
|
||||
if module == 'auto':
|
||||
|
@ -41,7 +43,7 @@ class ActionModule(ActionBase):
|
|||
if module == 'auto':
|
||||
facts = self._execute_module(module_name='setup', module_args=dict(filter='ansible_service_mgr'), task_vars=task_vars)
|
||||
self._display.debug("Facts %s" % facts)
|
||||
if not 'failed' in facts:
|
||||
if 'failed' not in facts:
|
||||
module = getattr(facts['ansible_facts'], 'ansible_service_mgr', 'auto')
|
||||
|
||||
if not module or module == 'auto' or module not in self._shared_loader_obj.module_loader:
|
||||
|
@ -54,8 +56,9 @@ class ActionModule(ActionBase):
|
|||
del new_module_args['use']
|
||||
|
||||
self._display.vvvv("Running %s" % module)
|
||||
return self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars)
|
||||
|
||||
result.update(self._execute_module(module_name=module, module_args=new_module_args, task_vars=task_vars))
|
||||
else:
|
||||
result['failed'] = True
|
||||
result['msg'] = 'Could not detect which service manager to use. Try gathering facts or setting the "use" option.'
|
||||
|
||||
return {'failed': True, 'msg': 'Could not detect which service manager to use. Try gathering facts or setting the "use" option.'}
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue