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
pull/30656/head
Brian Coca 7 years ago committed by GitHub
parent 875153d503
commit 131d417c7a

@ -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

Loading…
Cancel
Save