diff options
author | Filippo125 <filippo.ferrazini@gmail.com> | 2018-07-14 15:10:16 +0200 |
---|---|---|
committer | Sam Doran <sdoran@redhat.com> | 2018-07-14 15:10:16 +0200 |
commit | 5864871fc17046ce37875dd6e43414b1cf381cd3 (patch) | |
tree | ecbbda5d3f709320c87917fad01dc1a663efeaf9 /contrib | |
parent | Meraki utility - construct_path() now supports custom keys (#42286) (diff) | |
download | ansible-5864871fc17046ce37875dd6e43414b1cf381cd3.tar.xz ansible-5864871fc17046ce37875dd6e43414b1cf381cd3.zip |
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.ini | 3 | ||||
-rwxr-xr-x | contrib/inventory/zabbix.py | 7 |
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) |