diff options
author | Sloane Hertel <19572925+s-hertel@users.noreply.github.com> | 2021-03-18 22:53:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 22:53:57 +0100 |
commit | 48c0fbd1cb92943b992b8a522e40ae6fe668e648 (patch) | |
tree | 86415d1484f6cc234e3fcdb0c02767cee3cc9769 /test/integration/targets/collections/collection_root_user | |
parent | fix typo (diff) | |
download | ansible-48c0fbd1cb92943b992b8a522e40ae6fe668e648.tar.xz ansible-48c0fbd1cb92943b992b8a522e40ae6fe668e648.zip |
Fix a bug adding unrelated candidates to the plugin loader redirect_list (#73863)
* Fix a bug adding unrelated candidates to the plugin loader redirect_list
* Add tests for the redirect list
* test redirect list for builtin module
* test redirect list for redirected builtin module
* test redirect list for collection module
* test redirect list for redirected collection module
* test redirect list for legacy module
* changelog
Diffstat (limited to 'test/integration/targets/collections/collection_root_user')
2 files changed, 16 insertions, 5 deletions
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py index 1b882810da..3fa41e8f5f 100644 --- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py +++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py @@ -15,19 +15,26 @@ class ActionModule(ActionBase): result = super(ActionModule, self).run(None, task_vars) - type = self._task.args.get('type') + plugin_type = self._task.args.get('type') name = self._task.args.get('name') result = dict(changed=False, collection_list=self._task.collections) - if all([type, name]): - attr_name = '{0}_loader'.format(type) + if all([plugin_type, name]): + attr_name = '{0}_loader'.format(plugin_type) typed_loader = getattr(loader, attr_name, None) if not typed_loader: - return (dict(failed=True, msg='invalid plugin type {0}'.format(type))) + return (dict(failed=True, msg='invalid plugin type {0}'.format(plugin_type))) - result['plugin_path'] = typed_loader.find_plugin(name, collection_list=self._task.collections) + context = typed_loader.find_plugin_with_context(name, collection_list=self._task.collections) + + if not context.resolved: + result['plugin_path'] = None + result['redirect_list'] = [] + else: + result['plugin_path'] = context.plugin_resolved_path + result['redirect_list'] = context.redirect_list return result diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml new file mode 100644 index 0000000000..da8e4901ce --- /dev/null +++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml @@ -0,0 +1,4 @@ +plugin_routing: + modules: + ping: + redirect: testns.testcoll.ping |