1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ignore version when deciding callback loading (#38281)

* ignore version when deciding callback loading

The code already defaulted to load the callback if the properties are not present
there was no need for us to also check the version

fixes #38270

* fix error msg on set optoins to use correct name
This commit is contained in:
Brian Coca 2018-04-10 17:15:28 -04:00 committed by GitHub
parent 95ce00ff00
commit 1850bb752f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,22 +188,21 @@ class TaskQueueManager:
raise AnsibleError("callback must be an instance of CallbackBase or the name of a callback plugin") raise AnsibleError("callback must be an instance of CallbackBase or the name of a callback plugin")
for callback_plugin in callback_loader.all(class_only=True): for callback_plugin in callback_loader.all(class_only=True):
if hasattr(callback_plugin, 'CALLBACK_VERSION') and callback_plugin.CALLBACK_VERSION >= 2.0: callback_type = getattr(callback_plugin, 'CALLBACK_TYPE', '')
# we only allow one callback of type 'stdout' to be loaded, so check callback_needs_whitelist = getattr(callback_plugin, 'CALLBACK_NEEDS_WHITELIST', False)
# the name of the current plugin and type to see if we need to skip (callback_name, _) = os.path.splitext(os.path.basename(callback_plugin._original_path))
# loading this callback plugin if callback_type == 'stdout':
callback_type = getattr(callback_plugin, 'CALLBACK_TYPE', None) # we only allow one callback of type 'stdout' to be loaded,
callback_needs_whitelist = getattr(callback_plugin, 'CALLBACK_NEEDS_WHITELIST', False) if callback_name != self._stdout_callback or stdout_callback_loaded:
(callback_name, _) = os.path.splitext(os.path.basename(callback_plugin._original_path))
if callback_type == 'stdout':
if callback_name != self._stdout_callback or stdout_callback_loaded:
continue
stdout_callback_loaded = True
elif callback_name == 'tree' and self._run_tree:
pass
elif not self._run_additional_callbacks or (callback_needs_whitelist and (
C.DEFAULT_CALLBACK_WHITELIST is None or callback_name not in C.DEFAULT_CALLBACK_WHITELIST)):
continue continue
stdout_callback_loaded = True
elif callback_name == 'tree' and self._run_tree:
# special case for ansible cli option
pass
elif not self._run_additional_callbacks or (callback_needs_whitelist and (
C.DEFAULT_CALLBACK_WHITELIST is None or callback_name not in C.DEFAULT_CALLBACK_WHITELIST)):
# 2.x plugins shipped with ansible should require whitelisting, older or non shipped should load automatically
continue
callback_obj = callback_plugin() callback_obj = callback_plugin()
try: try:
@ -211,7 +210,7 @@ class TaskQueueManager:
except AttributeError: except AttributeError:
display.deprecated("%s callback, does not support setting 'options', it will work for now, " display.deprecated("%s callback, does not support setting 'options', it will work for now, "
" but this will be required in the future and should be updated, " " but this will be required in the future and should be updated, "
" see the 2.4 porting guide for details." % self._stdout_callback._load_name, version="2.9") " see the 2.4 porting guide for details." % self.callback_obj._load_name, version="2.9")
self._callback_plugins.append(callback_obj) self._callback_plugins.append(callback_obj)
self._callbacks_loaded = True self._callbacks_loaded = True