summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonLeary42 <71396965+simonLeary42@users.noreply.github.com>2025-01-08 17:26:42 +0100
committerGitHub <noreply@github.com>2025-01-08 17:26:42 +0100
commit64cbb71e6e5fb1972c0809036979ab578537f791 (patch)
tree93060f3205c82cb2fb22d17926a733a59aa6953d
parent📝 Update the outdated WGs+community links in GH issues (#84523) (diff)
downloadansible-64cbb71e6e5fb1972c0809036979ab578537f791.tar.xz
ansible-64cbb71e6e5fb1972c0809036979ab578537f791.zip
FIX get_options function for CallbackBase (#84496)
-rw-r--r--changelogs/fragments/84496-CallbackBase-get_options.yml4
-rw-r--r--lib/ansible/plugins/__init__.py2
-rw-r--r--lib/ansible/plugins/callback/__init__.py5
3 files changed, 9 insertions, 2 deletions
diff --git a/changelogs/fragments/84496-CallbackBase-get_options.yml b/changelogs/fragments/84496-CallbackBase-get_options.yml
new file mode 100644
index 0000000000..09bcd4bb6d
--- /dev/null
+++ b/changelogs/fragments/84496-CallbackBase-get_options.yml
@@ -0,0 +1,4 @@
+---
+minor_changes:
+ - callback plugins - add has_option() to CallbackBase to match other functions overloaded from AnsiblePlugin
+ - callback plugins - fix get_options() for CallbackBase
diff --git a/lib/ansible/plugins/__init__.py b/lib/ansible/plugins/__init__.py
index ff9068effa..44112597aa 100644
--- a/lib/ansible/plugins/__init__.py
+++ b/lib/ansible/plugins/__init__.py
@@ -129,7 +129,7 @@ class AnsiblePlugin(ABC):
@property
def option_definitions(self):
- if self._defs is None:
+ if (not hasattr(self, "_defs")) or self._defs is None:
self._defs = C.config.get_configuration_definitions(plugin_type=self.plugin_type, name=self._load_name)
return self._defs
diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py
index aa75ac5fa3..12d97a5a96 100644
--- a/lib/ansible/plugins/callback/__init__.py
+++ b/lib/ansible/plugins/callback/__init__.py
@@ -171,9 +171,12 @@ class CallbackBase(AnsiblePlugin):
def set_option(self, k, v):
self._plugin_options[k] = C.config.get_config_value(k, plugin_type=self.plugin_type, plugin_name=self._load_name, direct={k: v})
- def get_option(self, k):
+ def get_option(self, k, hostvars=None):
return self._plugin_options[k]
+ def has_option(self, option):
+ return (option in self._plugin_options)
+
def set_options(self, task_keys=None, var_options=None, direct=None):
""" This is different than the normal plugin method as callbacks get called early and really don't accept keywords.
Also _options was already taken for CLI args and callbacks use _plugin_options instead.