Skip to content

Commit

Permalink
Bgmot modules zabbix70 (ansible-collections#1273)
Browse files Browse the repository at this point in the history
* zabbix_proxy_group module added.

* zabbix_proxy module updated to support Zabbix 7.0.

* zabbix_host module updated to support Zabbix 7.0.

* Fix lint/sanity tests failures.

* Remove mistakenly committed tests/integration/inventory.

* zabbix_proxy module: handle proxy parameters dependency better.

* zabbix_discovery_rule module updated to support Zabbix 7.0.

* zabbix_group_events_info module updated to support Zabbix 7.0.

* zabbix_host_events_info module updated to support Zabbix 7.0.

* zabbix_proxy_info module updated to support Zabbix 7.0.

* zabbix_script module: update tests to run for Zabbix 7.0.

* Revert "zabbix_script module: update tests to run for Zabbix 7.0."

This reverts commit a4917a0275cc2a79a84395ee5aff44343c751293.

* Additional options to run Zabbix server docker to handle script tests properly.

* Rmove Zabbix 6.2 and add Zabbix 7.0 for plugins integration testing.

* Changelog fragment added.

* Fix sanity test problems.

* Fix plugins integration tests for Zabbxi < 7.0.

* zabbix_host_events_info: fix for Zabbix > 6.0.
  • Loading branch information
BGmot authored and pyrodie18 committed Jun 6, 2024
1 parent 32f7a96 commit 55d3b3a
Show file tree
Hide file tree
Showing 21 changed files with 1,805 additions and 420 deletions.
1 change: 1 addition & 0 deletions .env_srv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ZBX_ENABLEGLOBALSCRIPTS=1
2 changes: 1 addition & 1 deletion .github/workflows/plugins-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
matrix:
zabbix_container:
- version: "6.0"
- version: "6.2"
- version: "6.4"
- version: "7.0"
ansible:
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-changelogs
- stable-2.15
Expand Down
5 changes: 5 additions & 0 deletions changelogs/fragments/zabbix70_modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
breaking_changes:
- Remove support for Zabbix 6.2
minor_changes:
- zabbix_discovery_rule, zabbix_group_events_info, zabbix_host, zabbix_host_events_info, zabbix_proxy, zabbix_proxy_info modules updated to work wih Zabbix 7.0
- added new module zabbix_proxy_group (Zabbix 7.0)
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
- "zabbix-db"
links:
- "zabbix-db"
env_file:
- ./.env_srv
zabbix-web:
image: zabbix/zabbix-web-nginx-pgsql:ubuntu-${zabbix_version}-latest
environment:
Expand Down
23 changes: 17 additions & 6 deletions plugins/modules/zabbix_discovery_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,18 @@ def get_proxy_by_proxy_name(self, proxy_name):
proxy matching proxy name
"""
try:
proxy_list = self._zapi.proxy.get({
"output": "extend",
"selectInterface": "extend",
"filter": {"host": [proxy_name]}
})
if LooseVersion(self._zbx_api_version) < LooseVersion("7.0"):
proxy_list = self._zapi.proxy.get({
"output": "extend",
"selectInterface": "extend",
"filter": {"host": [proxy_name]}
})
else:
proxy_list = self._zapi.proxy.get({
"output": "extend",
"filter": {"name": [proxy_name]}
})

if len(proxy_list) < 1:
self._module.fail_json(msg="Proxy not found: %s" % proxy_name)
else:
Expand All @@ -458,7 +465,11 @@ def _construct_parameters(self, **kwargs):
"dchecks": kwargs["dchecks"]
}
if kwargs["proxy"]:
_params["proxy_hostid"] = self.get_proxy_by_proxy_name(kwargs["proxy"])["proxyid"]
if LooseVersion(self._zbx_api_version) < LooseVersion("7.0"):
_params["proxy_hostid"] = self.get_proxy_by_proxy_name(kwargs["proxy"])["proxyid"]
else:
_params["proxyid"] = self.get_proxy_by_proxy_name(kwargs["proxy"])["proxyid"]

return _params

def check_difference(self, **kwargs):
Expand Down
17 changes: 12 additions & 5 deletions plugins/modules/zabbix_group_events_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
description: acknowledges informations
type: complex
contains:
alias:
username:
description: Account who acknowledge
type: str
clock:
Expand Down Expand Up @@ -208,6 +208,9 @@
from ansible.module_utils.basic import AnsibleModule

from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase

from ansible.module_utils.compat.version import LooseVersion

import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils


Expand All @@ -228,10 +231,14 @@ def get_triggers_by_group_id_in_problem_state(self, group_id, trigger_severity):
def get_last_event_by_trigger_id(self, triggers_id):
""" Get the last event from triggerid"""
output = ["eventid", "clock", "acknowledged", "value"]
select_acknowledges = ["clock", "alias", "message"]
event = self._zapi.event.get({"output": output, "objectids": triggers_id,
"select_acknowledges": select_acknowledges, "limit": 1, "sortfield": "clock",
"sortorder": "DESC"})
if LooseVersion(self._zbx_api_version) < LooseVersion("7.0"):
event = self._zapi.event.get({"output": output, "objectids": triggers_id,
"select_acknowledges": "extend", "limit": 1, "sortfield": "clock",
"sortorder": "DESC"})
else:
event = self._zapi.event.get({"output": output, "objectids": triggers_id,
"selectAcknowledges": "extend", "limit": 1, "sortfield": "clock",
"sortorder": "DESC"})
return event[0]


Expand Down
Loading

0 comments on commit 55d3b3a

Please sign in to comment.