Commit 65aa0ea5 by Calen Pennington

Support Ansible 2.0

parent 71c5f89a
...@@ -6,6 +6,12 @@ from os.path import splitext, basename, exists, dirname ...@@ -6,6 +6,12 @@ from os.path import splitext, basename, exists, dirname
import sys import sys
import time import time
try:
from ansible.plugins.callback import CallbackBase
except ImportError:
# Support Ansible 1.9.x
CallbackBase = object
import datadog import datadog
logging.basicConfig(level=logging.INFO, stream=sys.stdout) logging.basicConfig(level=logging.INFO, stream=sys.stdout)
...@@ -203,7 +209,7 @@ class LoggingTimingLogger(TimingLogger): ...@@ -203,7 +209,7 @@ class LoggingTimingLogger(TimingLogger):
) )
class CallbackModule(object): class CallbackModule(CallbackBase):
""" """
Ansible plugin get the time of each task and total time Ansible plugin get the time of each task and total time
...@@ -214,6 +220,7 @@ class CallbackModule(object): ...@@ -214,6 +220,7 @@ class CallbackModule(object):
self.current_task = None self.current_task = None
self.playbook_name = None self.playbook_name = None
self.playbook_timestamp = None self.playbook_timestamp = None
self.play = None
self.loggers = [ self.loggers = [
DatadogTimingLogger(), DatadogTimingLogger(),
...@@ -221,6 +228,10 @@ class CallbackModule(object): ...@@ -221,6 +228,10 @@ class CallbackModule(object):
JsonTimingLogger(), JsonTimingLogger(),
] ]
def v2_playbook_on_play_start(self, play):
self.play = play
super(CallbackModule, self).v2_playbook_on_play_start(play)
def playbook_on_play_start(self, pattern): def playbook_on_play_start(self, pattern):
""" """
Record the start of a play. Record the start of a play.
......
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