Brian Coca 2 weeks ago committed by GitHub
commit 1ccbbb0a3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -90,6 +90,21 @@ class AnsiblePlugin(ABC):
options[option] = self.get_option(option, hostvars=hostvars)
return options
def get_ff_option(self, *options, hostvars=None, pc=None):
''' convenience function for when plugins have not followed strict conventions (user/remote_user)
and/or relied on play context, which is not strictly up to date, especially in loops. '''
for option in options:
if self.has_option(option):
return self.get_option(option, hostvars)
# fallback to play context
if pc is not None:
for option in options:
if hasattr(pc, option):
return getattr(pc, option)
raise KeyError("The %s plugin '%s' does not support any of these options: %s" % (self.plugin_type, self._load_name, ', '.join(options))
def set_option(self, option, value):
self._options[option] = C.config.get_config_value(option, plugin_type=self.plugin_type, plugin_name=self._load_name, direct={option: value})

Loading…
Cancel
Save