From 1850bb752f9f1cf54b62e279e3ef79f41e970fdc Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 10 Apr 2018 17:15:28 -0400 Subject: [PATCH] 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 --- lib/ansible/executor/task_queue_manager.py | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 6d25125a201..456cb656632 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -188,22 +188,21 @@ class TaskQueueManager: 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): - if hasattr(callback_plugin, 'CALLBACK_VERSION') and callback_plugin.CALLBACK_VERSION >= 2.0: - # we only allow one callback of type 'stdout' to be loaded, so check - # the name of the current plugin and type to see if we need to skip - # loading this callback plugin - callback_type = getattr(callback_plugin, 'CALLBACK_TYPE', None) - callback_needs_whitelist = getattr(callback_plugin, 'CALLBACK_NEEDS_WHITELIST', False) - (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)): + callback_type = getattr(callback_plugin, 'CALLBACK_TYPE', '') + callback_needs_whitelist = getattr(callback_plugin, 'CALLBACK_NEEDS_WHITELIST', False) + (callback_name, _) = os.path.splitext(os.path.basename(callback_plugin._original_path)) + if callback_type == 'stdout': + # we only allow one callback of type 'stdout' to be loaded, + if callback_name != self._stdout_callback or stdout_callback_loaded: 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() try: @@ -211,7 +210,7 @@ class TaskQueueManager: except AttributeError: 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, " - " 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._callbacks_loaded = True