summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2022-05-11 11:54:50 -0400
committerGitHub <noreply@github.com>2022-05-11 10:54:50 -0500
commit67f06ed83c73da996a2824803979b49863cd1497 (patch)
treebb95fdee41f446f317f92f25ce5ec642392893eb /lib/ansible/plugins
parentd5e5bd34d6249b3b0c66c3423fa09a9f3b032467 (diff)
downloadansible-67f06ed83c73da996a2824803979b49863cd1497.tar.gz
dont rely on path to set config defs for plugins (#77659) (#77696)
(cherry picked from commit a3cc6a581ef191faf1c9ec102d1c116c4c2a8778)
Diffstat (limited to 'lib/ansible/plugins')
-rw-r--r--lib/ansible/plugins/loader.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py
index 33dc10c2a3..d7089b96af 100644
--- a/lib/ansible/plugins/loader.py
+++ b/lib/ansible/plugins/loader.py
@@ -379,7 +379,7 @@ class PluginLoader:
type_name = get_plugin_class(self.class_name)
# if type name != 'module_doc_fragment':
- if type_name in C.CONFIGURABLE_PLUGINS:
+ if type_name in C.CONFIGURABLE_PLUGINS and not C.config.get_configuration_definition(type_name, name):
dstring = AnsibleLoader(getattr(module, 'DOCUMENTATION', ''), file_name=path).get_single_data()
if dstring:
add_fragments(dstring, path, fragment_loader=fragment_loader, is_module=(type_name == 'module'))
@@ -809,10 +809,12 @@ class PluginLoader:
if path not in self._module_cache:
self._module_cache[path] = self._load_module_source(name, path)
- self._load_config_defs(name, self._module_cache[path], path)
found_in_cache = False
+ self._load_config_defs(name, self._module_cache[path], path)
+
obj = getattr(self._module_cache[path], self.class_name)
+
if self.base_class:
# The import path is hardcoded and should be the right place,
# so we are not expecting an ImportError.
@@ -933,15 +935,18 @@ class PluginLoader:
else:
full_name = basename
module = self._load_module_source(full_name, path)
- self._load_config_defs(basename, module, path)
except Exception as e:
display.warning("Skipping plugin (%s) as it seems to be invalid: %s" % (path, to_text(e)))
continue
self._module_cache[path] = module
found_in_cache = False
+ else:
+ module = self._module_cache[path]
+
+ self._load_config_defs(basename, module, path)
try:
- obj = getattr(self._module_cache[path], self.class_name)
+ obj = getattr(module, self.class_name)
except AttributeError as e:
display.warning("Skipping plugin (%s) as it seems to be invalid: %s" % (path, to_text(e)))
continue