summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorFilippo125 <filippo.ferrazini@gmail.com>2018-07-14 15:10:16 +0200
committerSam Doran <sdoran@redhat.com>2018-07-14 09:10:16 -0400
commit5864871fc17046ce37875dd6e43414b1cf381cd3 (patch)
treeecbbda5d3f709320c87917fad01dc1a663efeaf9 /contrib
parent106e4b374a4eae78900c757b8faee503062b3fd4 (diff)
downloadansible-5864871fc17046ce37875dd6e43414b1cf381cd3.tar.gz
Zabbix inventory improvement (#42669)
* Add validate_certs option to zabbix inventory * Add validation option * Fix pep8 * Add changelog
Diffstat (limited to 'contrib')
-rw-r--r--contrib/inventory/zabbix.ini3
-rwxr-xr-xcontrib/inventory/zabbix.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/contrib/inventory/zabbix.ini b/contrib/inventory/zabbix.ini
index 618c2b9fe8..ac12c1b497 100644
--- a/contrib/inventory/zabbix.ini
+++ b/contrib/inventory/zabbix.ini
@@ -9,3 +9,6 @@ server = http://zabbix.example.com/zabbix
# Login
username = admin
password = zabbix
+
+# Verify the server's SSL certificate
+validate_certs = True \ No newline at end of file
diff --git a/contrib/inventory/zabbix.py b/contrib/inventory/zabbix.py
index d5573aa003..48b3017194 100755
--- a/contrib/inventory/zabbix.py
+++ b/contrib/inventory/zabbix.py
@@ -73,6 +73,10 @@ class ZabbixInventory(object):
self.zabbix_username = config.get('zabbix', 'username')
if config.has_option('zabbix', 'password'):
self.zabbix_password = config.get('zabbix', 'password')
+ # ssl certs
+ if config.has_option('zabbix', 'validate_certs'):
+ if config.get('zabbix', 'validate_certs') in ['false', 'False', False]:
+ self.validate_certs = False
def read_cli(self):
parser = argparse.ArgumentParser()
@@ -118,6 +122,7 @@ class ZabbixInventory(object):
self.zabbix_server = None
self.zabbix_username = None
self.zabbix_password = None
+ self.validate_certs = True
self.meta = {}
self.read_settings()
@@ -125,7 +130,7 @@ class ZabbixInventory(object):
if self.zabbix_server and self.zabbix_username:
try:
- api = ZabbixAPI(server=self.zabbix_server)
+ api = ZabbixAPI(server=self.zabbix_server, validate_certs=self.validate_certs)
api.login(user=self.zabbix_username, password=self.zabbix_password)
except BaseException as e:
print("Error: Could not login to Zabbix server. Check your zabbix.ini.", file=sys.stderr)