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:
James Cammarata
2015-04-29 01:06:33 -05:00
parent dc12669c40
commit 4bb37b82c4
7 changed files with 48 additions and 13 deletions

View File

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

View File

@@ -31,6 +31,7 @@ class CallbackModule(CallbackBase):
'''
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
def v2_on_any(self, *args, **kwargs):
pass

View File

@@ -32,6 +32,7 @@ class CallbackModule(CallbackBase):
'''
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
def v2_on_any(self, *args, **kwargs):
pass