From 19ba54c9fd7f51475101213f0440397e3d673e7f Mon Sep 17 00:00:00 2001 From: Jimmy Tang Date: Sat, 14 Nov 2015 19:53:26 +0000 Subject: [PATCH] Don't be fatal on import errors so plays don't fail if plugin doesn't have required dependencies --- lib/ansible/plugins/callback/logentries.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/callback/logentries.py b/lib/ansible/plugins/callback/logentries.py index 22980e1e4d..bf168d68a9 100644 --- a/lib/ansible/plugins/callback/logentries.py +++ b/lib/ansible/plugins/callback/logentries.py @@ -64,13 +64,15 @@ import ConfigParser import uuid try: import certifi + HAS_CERTIFI = True except ImportError: - print("please do 'pip install certifi'") + HAS_CERTIFI = False try: import flatdict + HAS_FLATDICT = True except ImportError: - print("please do 'pip install flatdict'") + HAS_FLATDICT = False from ansible.plugins.callback import CallbackBase @@ -195,6 +197,16 @@ class CallbackModule(CallbackBase): def __init__(self): super(CallbackModule, self).__init__() + if not HAS_CERTIFI: + self.disabled =True + self.display.warning('The `certifi` python module is not installed. ' + 'Disabling the Logentries callback plugin.') + + if not HAS_FLATDICT: + self.disabled =True + self.display.warning('The `flatdict` python module is not installed. ' + 'Disabling the Logentries callback plugin.') + config_path = os.path.abspath(os.path.dirname(__file__)) config = ConfigParser.ConfigParser() try: