Zabbix: ensure existence of correct hostgroups

also applies the correct hostgroups when creating/updating hosts

Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
Greg Sutcliffe
2025-07-31 12:46:33 +01:00
parent 922fec19e2
commit a1b2783a67
5 changed files with 23 additions and 8 deletions

View File

@@ -22,3 +22,7 @@ num_cpus: 4
tcp_ports: [80, 443]
notes: Test instanec for zabbix server
zabbix_matrix_roomid: "!dODrizXNtqWjiylAyh:fedora.im"
zabbix_base_hostgroups:
- All servers
- Linux servers
- Zabbix servers

View File

@@ -22,3 +22,7 @@ num_cpus: 2
tcp_ports: [80, 443]
notes: Test instance for zabbix server
zabbix_stg_matrix_roomid: "!dODrizXNtqWjiylAyh:fedora.im"
zabbix_base_hostgroups:
- All servers
- Linux servers
- Zabbix servers

View File

@@ -4,6 +4,9 @@ zabbix_host: "zabbix01{{ env_suffix }}.{{ datacenter }}.fedoraproject.org"
zabbix_agent_hostname: "{{ ansible_hostname }}"
zabbix_base_templates:
- Linux by Zabbix agent active
zabbix_base_hostgroups:
- All servers
- Linux servers
# TLS/PSK settings to encrypt between agent and proxy/server
zabbix_tls_connect: "psk"

View File

@@ -24,8 +24,7 @@
- name: Create self in Zabbix
community.zabbix.zabbix_host:
host_name: "{{ inventory_hostname }}"
host_groups:
- Linux servers
host_groups: "{{ zabbix_base_hostgroups }}"
link_templates: "{{ zabbix_base_templates }}"
status: enabled
state: present

View File

@@ -16,6 +16,15 @@
tags:
- zabbix_configuration
block:
- name: Setup host groups
community.zabbix.zabbix_group:
state: present
host_groups:
- All servers
- Linux servers
- Ping-only servers
- Zabbix servers
# Templates seem to always report a change :/
- name: Import all template files
community.zabbix.zabbix_template:
@@ -39,9 +48,7 @@
community.zabbix.zabbix_usergroup:
name: Sysadmin-noc
hostgroup_rights:
- host_group: Discovered hosts
permission: read-write
- host_group: Zabbix servers
- host_group: All servers
permission: read-write
templategroup_rights:
- template_group: Fedora
@@ -52,9 +59,7 @@
community.zabbix.zabbix_usergroup:
name: Guests
hostgroup_rights:
- host_group: Discovered hosts
permission: read-only
- host_group: Zabbix servers
- host_group: All servers
permission: read-only
templategroup_rights:
- template_group: Fedora