From 131d417c7a0d8fb87a13f8c9eb23d91dfeb94ed0 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 20 Sep 2017 15:20:19 -0400 Subject: [PATCH] made callbacks backwards compatible (#30625) * made callbacks backwards compatible This fixes #30597 for those that were not inheriting from base. Added deprecation notice so those callbacks get updated. Callback must either inherit from base (directly or indirectly), which already implements this or implement set_options themselves. * added note about porting guide --- lib/ansible/executor/task_queue_manager.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 239ce0bfe6..a70a3923c9 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -176,7 +176,12 @@ class TaskQueueManager: raise AnsibleError("Invalid callback for stdout specified: %s" % self._stdout_callback) else: self._stdout_callback = callback_loader.get(self._stdout_callback) - self._stdout_callback.set_options(C.config.get_plugin_options('callback', self._stdout_callback._load_name)) + try: + self._stdout_callback.set_options(C.config.get_plugin_options('callback', self._stdout_callback._load_name)) + except AttributeError: + display.deprecated("%s stdout 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") stdout_callback_loaded = True else: raise AnsibleError("callback must be an instance of CallbackBase or the name of a callback plugin") @@ -200,7 +205,12 @@ class TaskQueueManager: continue callback_obj = callback_plugin() - callback_obj .set_options(C.config.get_plugin_options('callback', callback_plugin._load_name)) + try: + callback_obj .set_options(C.config.get_plugin_options('callback', callback_plugin._load_name)) + 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") self._callback_plugins.append(callback_obj) self._callbacks_loaded = True