Commit 465a903f authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

log_parse plugin compatible with Ansible version 1 and 2

parent ddb01dec
...@@ -2,9 +2,16 @@ ...@@ -2,9 +2,16 @@
import os import os
import time import time
import json import json
from ansible.plugins.callback import CallbackBase import ansible
class CallbackModule(CallbackBase): baseModule = object
ANSIBLE_VERSION = 1
if hasattr(ansible, 'plugins') and hasattr(ansible.plugins, 'callback'):
baseModule = ansible.plugins.callback.CallbackBase
ANSIBLE_VERSION = 2
class CallbackModule(baseModule):
""" """
logs playbook results, per host, in /var/log/ansible/hosts logs playbook results, per host, in /var/log/ansible/hosts
""" """
...@@ -13,7 +20,8 @@ class CallbackModule(CallbackBase): ...@@ -13,7 +20,8 @@ class CallbackModule(CallbackBase):
def __init__(self): def __init__(self):
super(CallbackModule, self).__init__() if ANSIBLE_VERSION > 1:
super(baseModule, self).__init__()
if not os.path.exists(self.log_path): if not os.path.exists(self.log_path):
os.makedirs(self.log_path) os.makedirs(self.log_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment