From e5fd4ae7478d2c7ae085e3c99e6717525569a547 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 28 Sep 2022 09:15:43 -0400 Subject: [PATCH] plugin loader fix existing config testing (#78859) (#78891) create specific function to find config entry to avoid repopulating constantly (cherry picked from commit 4115ddd135a0445092c9f9a7b5904942ceedd57c) --- changelogs/fragments/plugin_loader_fix.yml | 2 ++ lib/ansible/config/manager.py | 8 ++++++++ lib/ansible/plugins/loader.py | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/plugin_loader_fix.yml diff --git a/changelogs/fragments/plugin_loader_fix.yml b/changelogs/fragments/plugin_loader_fix.yml new file mode 100644 index 00000000000..85d5f0735ae --- /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 4efaf1aa272..e1fde1d30aa 100644 --- a/lib/ansible/config/manager.py +++ b/lib/ansible/config/manager.py @@ -383,6 +383,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 78487d1cb1f..dbaa6677307 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -399,7 +399,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() # TODO: allow configurable plugins to use sidecar