mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -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
|
@ -19,19 +19,27 @@ __metaclass__ = type
|
|||
|
||||
from ansible.plugins.action import ActionBase
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
''' Create inventory groups based on variables '''
|
||||
|
||||
### We need to be able to modify the inventory
|
||||
TRANSFERS_FILES = False
|
||||
|
||||
def run(self, tmp=None, task_vars=dict()):
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
if task_vars is None:
|
||||
task_vars = dict()
|
||||
|
||||
if not 'key' in self._task.args:
|
||||
return dict(failed=True, msg="the 'key' param is required when using group_by")
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if 'key' not in self._task.args:
|
||||
result['failed'] = True
|
||||
result['msg'] = "the 'key' param is required when using group_by"
|
||||
return result
|
||||
|
||||
group_name = self._task.args.get('key')
|
||||
group_name = group_name.replace(' ','-')
|
||||
|
||||
return dict(changed=True, add_group=group_name)
|
||||
|
||||
result['changed'] = True
|
||||
result['add_group'] = group_name
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue