From df8ff857870060ea1471d102a74a8bef9ebbf2c0 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 22 Oct 2015 08:27:32 -0400 Subject: [PATCH] make callbacks declare needing whitelisting this will allow for custom or v1 callbacks locally loaded to automatically be triggered as they were in 1.x --- lib/ansible/executor/task_queue_manager.py | 3 ++- lib/ansible/plugins/callback/context_demo.py | 3 ++- lib/ansible/plugins/callback/hipchat.py | 3 ++- lib/ansible/plugins/callback/log_plays.py | 1 + lib/ansible/plugins/callback/mail.py | 1 + lib/ansible/plugins/callback/osx_say.py | 1 + lib/ansible/plugins/callback/profile_tasks.py | 1 + lib/ansible/plugins/callback/syslog_json.py | 1 + lib/ansible/plugins/callback/timer.py | 1 + lib/ansible/plugins/callback/tree.py | 1 + 10 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index ae41afb600..d4f4c4d275 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -150,12 +150,13 @@ class TaskQueueManager: # 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 C.DEFAULT_CALLBACK_WHITELIST is None or callback_name not in C.DEFAULT_CALLBACK_WHITELIST: + elif callback_needs_whitelist and (C.DEFAULT_CALLBACK_WHITELIST is None or callback_name not in C.DEFAULT_CALLBACK_WHITELIST): continue self._callback_plugins.append(callback_plugin(self._display)) diff --git a/lib/ansible/plugins/callback/context_demo.py b/lib/ansible/plugins/callback/context_demo.py index 3a5cd844cd..ec4454c45a 100644 --- a/lib/ansible/plugins/callback/context_demo.py +++ b/lib/ansible/plugins/callback/context_demo.py @@ -28,7 +28,8 @@ class CallbackModule(CallbackBase): """ CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'aggregate' - CALLBACK_TYPE = 'context_demo' + CALLBACK_NAME = 'context_demo' + CALLBACK_NEEDS_WHITELIST = True def v2_on_any(self, *args, **kwargs): i = 0 diff --git a/lib/ansible/plugins/callback/hipchat.py b/lib/ansible/plugins/callback/hipchat.py index 53551ba82c..5c2e3c6060 100644 --- a/lib/ansible/plugins/callback/hipchat.py +++ b/lib/ansible/plugins/callback/hipchat.py @@ -46,8 +46,9 @@ class CallbackModule(CallbackBase): """ CALLBACK_VERSION = 2.0 - CALLBACK_VERSION = 2.0 + CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'hipchat' + CALLBACK_NEEDS_WHITELIST = True def __init__(self, display): diff --git a/lib/ansible/plugins/callback/log_plays.py b/lib/ansible/plugins/callback/log_plays.py index d8a834cadc..9ca743254e 100644 --- a/lib/ansible/plugins/callback/log_plays.py +++ b/lib/ansible/plugins/callback/log_plays.py @@ -40,6 +40,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'log_plays' + CALLBACK_NEEDS_WHITELIST = True TIME_FORMAT="%b %d %Y %H:%M:%S" MSG_FORMAT="%(now)s - %(category)s - %(data)s\n\n" diff --git a/lib/ansible/plugins/callback/mail.py b/lib/ansible/plugins/callback/mail.py index 3895fbaddd..4a9c1f0b10 100644 --- a/lib/ansible/plugins/callback/mail.py +++ b/lib/ansible/plugins/callback/mail.py @@ -74,6 +74,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'mail' + CALLBACK_NEEDS_WHITELIST = True def v2_runner_on_failed(self, res, ignore_errors=False): diff --git a/lib/ansible/plugins/callback/osx_say.py b/lib/ansible/plugins/callback/osx_say.py index da1044c2b1..da588434a8 100644 --- a/lib/ansible/plugins/callback/osx_say.py +++ b/lib/ansible/plugins/callback/osx_say.py @@ -38,6 +38,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'notification' CALLBACK_NAME = 'osx_say' + CALLBACK_NEEDS_WHITELIST = True def __init__(self, display): diff --git a/lib/ansible/plugins/callback/profile_tasks.py b/lib/ansible/plugins/callback/profile_tasks.py index 669d6f05c0..b23f84092b 100644 --- a/lib/ansible/plugins/callback/profile_tasks.py +++ b/lib/ansible/plugins/callback/profile_tasks.py @@ -69,6 +69,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'aggregate' CALLBACK_NAME = 'profile_tasks' + CALLBACK_NEEDS_WHITELIST = True def __init__(self, display): self.stats = {} diff --git a/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py index 71deb4f976..6ba9c6f3cd 100644 --- a/lib/ansible/plugins/callback/syslog_json.py +++ b/lib/ansible/plugins/callback/syslog_json.py @@ -26,6 +26,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'aggregate' CALLBACK_NAME = 'syslog_json' + CALLBACK_NEEDS_WHITELIST = True def __init__(self, display): diff --git a/lib/ansible/plugins/callback/timer.py b/lib/ansible/plugins/callback/timer.py index 8694b281e7..4f4bd44dea 100644 --- a/lib/ansible/plugins/callback/timer.py +++ b/lib/ansible/plugins/callback/timer.py @@ -15,6 +15,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'aggregate' CALLBACK_NAME = 'timer' + CALLBACK_NEEDS_WHITELIST = True def __init__(self, display): diff --git a/lib/ansible/plugins/callback/tree.py b/lib/ansible/plugins/callback/tree.py index 0038450a6c..5c976cc6f2 100644 --- a/lib/ansible/plugins/callback/tree.py +++ b/lib/ansible/plugins/callback/tree.py @@ -34,6 +34,7 @@ class CallbackModule(CallbackBase): CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'aggregate' CALLBACK_NAME = 'tree' + CALLBACK_NEEDS_WHITELIST = True def __init__(self, display): super(CallbackModule, self).__init__(display)