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>`
pull/74252/head
Brian Coca 3 years ago committed by GitHub
parent f38d03f6fb
commit 3a244c5533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -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:

Loading…
Cancel
Save