mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Fix duplicate callback issue in v2
All v2+ callbacks can now optionally define a CALLBACK_TYPE, which when set to 'stdout' will limit those callbacks which are used for primary output to a single callback plugin (specified to the TaskQueueManager object and configurable in ansible.cfg/environment)
This commit is contained in:
@@ -243,9 +243,12 @@ class PluginLoader:
|
||||
if path not in self._module_cache:
|
||||
self._module_cache[path] = imp.load_source('.'.join([self.package, name]), path)
|
||||
if kwargs.get('class_only', False):
|
||||
yield getattr(self._module_cache[path], self.class_name)
|
||||
obj = getattr(self._module_cache[path], self.class_name)
|
||||
else:
|
||||
yield getattr(self._module_cache[path], self.class_name)(*args, **kwargs)
|
||||
obj = getattr(self._module_cache[path], self.class_name)(*args, **kwargs)
|
||||
# set extra info on the module, in case we want it later
|
||||
setattr(obj, '_original_path', path)
|
||||
yield obj
|
||||
|
||||
action_loader = PluginLoader(
|
||||
'ActionModule',
|
||||
|
||||
@@ -31,6 +31,7 @@ class CallbackModule(CallbackBase):
|
||||
'''
|
||||
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'stdout'
|
||||
|
||||
def v2_on_any(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
@@ -32,6 +32,7 @@ class CallbackModule(CallbackBase):
|
||||
'''
|
||||
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'stdout'
|
||||
|
||||
def v2_on_any(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user