File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 22import os .path
33import time
44
5- import datadog
6- import yaml
5+ try :
6+ import datadog
7+ import yaml
8+ HAS_MODULES = True
9+ except ImportError :
10+ HAS_MODULES = False
11+
712
813from ansible .plugins .callback import CallbackBase
914from __main__ import cli
1015
1116
1217class CallbackModule (CallbackBase ):
1318 def __init__ (self ):
19+ if not HAS_MODULES :
20+ self .disabled = True
21+ print 'Datadog callback disabled.\n Make sure you call all required libraries.'
1422
1523 self ._playbook_name = None
1624 self ._start_time = time .time ()
@@ -197,7 +205,8 @@ def v2_playbook_on_start(self, playbook):
197205 def v2_playbook_on_play_start (self , play ):
198206 # On Ansible v2, Ansible doesn't set `self.play` automatically
199207 self .play = play
200- self .disabled = False
208+ if self .disabled :
209+ return
201210
202211 # Read config and hostvars
203212 api_key , url = self ._load_conf (os .path .join (os .path .dirname (__file__ ), "datadog_callback.yml" ))
You can’t perform that action at this time.
0 commit comments