Browse Source

Merge pull request #2261 from richm/ansible2-support-hack-2

make the improved log formatter work with ansible 2.1
Scott Dodson 8 years ago
parent
commit
9e0e848563
1 changed files with 7 additions and 1 deletions
  1. 7 1
      callback_plugins/default.py

+ 7 - 1
callback_plugins/default.py

@@ -27,6 +27,12 @@ DEFAULT_MODULE = imp.load_source(
     DEFAULT_PATH
 )
 
+try:
+    from ansible.plugins.callback import CallbackBase
+    BASECLASS = CallbackBase
+except ImportError: # < ansible 2.1
+    BASECLASS = DEFAULT_MODULE.CallbackModule
+
 
 class CallbackModule(DEFAULT_MODULE.CallbackModule):  # pylint: disable=too-few-public-methods,no-init
     '''
@@ -48,7 +54,7 @@ class CallbackModule(DEFAULT_MODULE.CallbackModule):  # pylint: disable=too-few-
             if key in result:
                 save[key] = result.pop(key)
 
-        output = DEFAULT_MODULE.CallbackModule._dump_results(self, result)
+        output = BASECLASS._dump_results(self, result) # pylint: disable=protected-access
 
         for key in ['stdout', 'stderr', 'msg']:
             if key in save and save[key]: