diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2022-09-28 09:16:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 08:16:40 -0500 |
commit | 0d188114c658c01e65a173bba83219f14e70e52f (patch) | |
tree | 88d8b994abfbb34dd0eb242bca61559d4ac8b8e6 | |
parent | fa0655228a818134082b5fcb2dfcf6f94a0f4299 (diff) | |
download | ansible-0d188114c658c01e65a173bba83219f14e70e52f.tar.gz |
plugin loader fix existing config testing (#78859) (#78890)
create specific function to find config entry to avoid repopulating constantly
(cherry picked from commit 4115ddd135a0445092c9f9a7b5904942ceedd57c)
-rw-r--r-- | changelogs/fragments/plugin_loader_fix.yml | 2 | ||||
-rw-r--r-- | lib/ansible/config/manager.py | 8 | ||||
-rw-r--r-- | lib/ansible/plugins/loader.py | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/changelogs/fragments/plugin_loader_fix.yml b/changelogs/fragments/plugin_loader_fix.yml new file mode 100644 index 0000000000..85d5f0735a --- /dev/null +++ b/changelogs/fragments/plugin_loader_fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - plugin loader, fix detection for existing configuration before initializing for a plugin diff --git a/lib/ansible/config/manager.py b/lib/ansible/config/manager.py index 468f666b03..51e8ce08b5 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -385,6 +385,14 @@ class ConfigManager(object): return ret + def has_configuration_definition(self, plugin_type, name): + + has = False + if plugin_type in self._plugins: + has = (name in self._plugins[plugin_type]) + + return has + def get_configuration_definitions(self, plugin_type=None, name=None, ignore_private=False): ''' just list the possible settings, either base or for specific plugins or plugin ''' diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py index a9d6f19c60..74bdeb5719 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -397,7 +397,7 @@ class PluginLoader: type_name = get_plugin_class(self.class_name) # if type name != 'module_doc_fragment': - if type_name in C.CONFIGURABLE_PLUGINS and not C.config.get_configuration_definition(type_name, name): + if type_name in C.CONFIGURABLE_PLUGINS and not C.config.has_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')) |