mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Don't be fatal on import errors so plays don't fail if plugin doesn't have required dependencies
This commit is contained in:
parent
125370ab48
commit
19ba54c9fd
1 changed files with 14 additions and 2 deletions
|
@ -64,13 +64,15 @@ import ConfigParser
|
||||||
import uuid
|
import uuid
|
||||||
try:
|
try:
|
||||||
import certifi
|
import certifi
|
||||||
|
HAS_CERTIFI = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("please do 'pip install certifi'")
|
HAS_CERTIFI = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import flatdict
|
import flatdict
|
||||||
|
HAS_FLATDICT = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("please do 'pip install flatdict'")
|
HAS_FLATDICT = False
|
||||||
|
|
||||||
from ansible.plugins.callback import CallbackBase
|
from ansible.plugins.callback import CallbackBase
|
||||||
|
|
||||||
|
@ -195,6 +197,16 @@ class CallbackModule(CallbackBase):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(CallbackModule, self).__init__()
|
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_path = os.path.abspath(os.path.dirname(__file__))
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue