config lookup can now handle collection plugins (#74250)

use load_name of valid plugin to find config, will handle the renamed loaded plugin that collections do:
`ansible_collection.<ns>.<collname>.plugins.<type>.<name>`
This commit is contained in:
Brian Coca 2021-04-13 00:00:43 -04:00 committed by GitHub
parent f38d03f6fb
commit 3a244c5533
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- config lookup, can also handle collection plugins now

View file

@ -89,8 +89,12 @@ def _get_plugin_config(pname, ptype, config, variables):
try:
# plugin creates settings on load, this is cached so not too expensive to redo
loader = getattr(plugin_loader, '%s_loader' % ptype)
dump = loader.get(pname, class_only=True)
result = C.config.get_config_value(config, plugin_type=ptype, plugin_name=pname, variables=variables)
p = loader.get(pname, class_only=True)
if p is None:
raise AnsibleLookupError('Unable to load %s plugin "%s"' % (ptype, pname))
result = C.config.get_config_value(config, plugin_type=ptype, plugin_name=p._load_name, variables=variables)
except AnsibleLookupError:
raise
except AnsibleError as e:
msg = to_native(e)
if 'was not defined' in msg: