diff options
author | Sloane Hertel <shertel@redhat.com> | 2020-06-09 18:38:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 15:38:57 -0700 |
commit | 51f6d129cbb30f42c445f7e2fecba68fe02d6f85 (patch) | |
tree | 11ff79f7cc1ef9fa8ac1134ccdc65d0217b6f297 /lib/ansible/parsing | |
parent | a862ff2d4324f871565ef5b749c6a96ad0ad767e (diff) | |
download | ansible-51f6d129cbb30f42c445f7e2fecba68fe02d6f85.tar.gz |
support hard coded module_defaults.yml groups for collections (#69919)
* Only allow groups which were hardcoded in module_defaults.yml
only load action groups from the collection if module_defaults contains a potential group for the action
* Fix tests using modules that override those whitelisted in lib/ansible/config/module_defaults.yml
Third party modules should not be using group/ - use the action name instead
* add externalized module_defaults tests
add the missing group and collections
ci_complete
Co-authored-by: Matt Davis <mrd@redhat.com>
* changelog
ci_complete
* Fix import in tests
ci_complete
* Update with requested changes
ci_complete
* don't traceback since we don't validate the contents of module_defaults
ci_complete
Co-authored-by: Matt Davis <mrd@redhat.com>
Diffstat (limited to 'lib/ansible/parsing')
-rw-r--r-- | lib/ansible/parsing/mod_args.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/ansible/parsing/mod_args.py b/lib/ansible/parsing/mod_args.py index 929d1add9e..a6906b909c 100644 --- a/lib/ansible/parsing/mod_args.py +++ b/lib/ansible/parsing/mod_args.py @@ -119,6 +119,8 @@ class ModuleArgsParser: self._task_attrs.update(['local_action', 'static']) self._task_attrs = frozenset(self._task_attrs) + self.internal_redirect_list = [] + def _split_module_string(self, module_string): ''' when module names are expressed like: @@ -266,6 +268,8 @@ class ModuleArgsParser: delegate_to = self._task_ds.get('delegate_to', Sentinel) args = dict() + self.internal_redirect_list = [] + # This is the standard YAML form for command-type modules. We grab # the args and pass them in as additional arguments, which can/will # be overwritten via dict updates from the other arg sources below @@ -294,8 +298,24 @@ class ModuleArgsParser: # walk the filtered input dictionary to see if we recognize a module name for item, value in iteritems(non_task_ds): - if item in BUILTIN_TASKS or skip_action_validation or action_loader.has_plugin(item, collection_list=self._collection_list) or \ - module_loader.has_plugin(item, collection_list=self._collection_list): + is_action_candidate = False + if item in BUILTIN_TASKS: + is_action_candidate = True + elif skip_action_validation: + is_action_candidate = True + else: + # If the plugin is resolved and redirected smuggle the list of candidate names via the task attribute 'internal_redirect_list' + context = action_loader.find_plugin_with_context(item, collection_list=self._collection_list) + if not context.resolved: + context = module_loader.find_plugin_with_context(item, collection_list=self._collection_list) + if context.resolved and context.redirect_list: + self.internal_redirect_list = context.redirect_list + elif context.redirect_list: + self.internal_redirect_list = context.redirect_list + + is_action_candidate = bool(self.internal_redirect_list) + + if is_action_candidate: # finding more than one module name is a problem if action is not None: raise AnsibleParserError("conflicting action statements: %s, %s" % (action, item), obj=self._task_ds) |