|
|
|
@ -34,7 +34,7 @@ author:
|
|
|
|
|
- "Michael Miko (@RedWhiteMiko)"
|
|
|
|
|
requirements:
|
|
|
|
|
- "python >= 2.6"
|
|
|
|
|
- zabbix-api
|
|
|
|
|
- "zabbix-api >= 0.5.3"
|
|
|
|
|
options:
|
|
|
|
|
host_name:
|
|
|
|
|
description:
|
|
|
|
@ -102,19 +102,7 @@ import traceback
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from zabbix_api import ZabbixAPI, ZabbixAPISubClass
|
|
|
|
|
|
|
|
|
|
# Extend the ZabbixAPI
|
|
|
|
|
# Since the zabbix-api python module too old (version 1.0, no higher version so far),
|
|
|
|
|
# it does not support the 'hostinterface' api calls,
|
|
|
|
|
# so we have to inherit the ZabbixAPI class to add 'hostinterface' support.
|
|
|
|
|
class ZabbixAPIExtends(ZabbixAPI):
|
|
|
|
|
hostinterface = None
|
|
|
|
|
|
|
|
|
|
def __init__(self, server, timeout, user, passwd, validate_certs, **kwargs):
|
|
|
|
|
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd, validate_certs=validate_certs)
|
|
|
|
|
self.hostinterface = ZabbixAPISubClass(self, dict({"prefix": "hostinterface"}, **kwargs))
|
|
|
|
|
|
|
|
|
|
from zabbix_api import ZabbixAPI
|
|
|
|
|
HAS_ZABBIX_API = True
|
|
|
|
|
except ImportError:
|
|
|
|
|
ZBX_IMP_ERR = traceback.format_exc()
|
|
|
|
@ -216,8 +204,8 @@ def main():
|
|
|
|
|
zbx = None
|
|
|
|
|
# login to zabbix
|
|
|
|
|
try:
|
|
|
|
|
zbx = ZabbixAPIExtends(server_url, timeout=timeout, user=http_login_user, passwd=http_login_password,
|
|
|
|
|
validate_certs=validate_certs)
|
|
|
|
|
zbx = ZabbixAPI(server_url, timeout=timeout, user=http_login_user, passwd=http_login_password,
|
|
|
|
|
validate_certs=validate_certs)
|
|
|
|
|
zbx.login(login_user, login_password)
|
|
|
|
|
atexit.register(zbx.logout)
|
|
|
|
|
except Exception as e:
|
|
|
|
|