Zabbix inventory improvement (#42669)

* Add validate_certs option to zabbix inventory

* Add validation option

* Fix pep8

* Add changelog
pull/42176/merge
Filippo125 6 years ago committed by Sam Doran
parent 106e4b374a
commit 5864871fc1

@ -0,0 +1,4 @@
---
minor_changes:
- Added capability to skip ssl verification
on zabbix host with dynamic inventory

@ -9,3 +9,6 @@ server = http://zabbix.example.com/zabbix
# Login
username = admin
password = zabbix
# Verify the server's SSL certificate
validate_certs = True

@ -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)

Loading…
Cancel
Save