From 9fae8c7d2db23e3618bac36d793431f6fc2f45bc Mon Sep 17 00:00:00 2001 From: Greg Sutcliffe Date: Mon, 22 Dec 2025 15:09:07 +0000 Subject: [PATCH] Zabbix: First try of the CMDB-in-Zabbix-Inventory idea (#12817) Signed-off-by: Greg Sutcliffe --- inventory/group_vars/all | 5 +++++ inventory/group_vars/staging | 5 +++++ .../host_vars/vmhost-x86-copr01.rdu3.fedoraproject.org | 9 +++++++++ .../host_vars/vmhost-x86-copr02.rdu3.fedoraproject.org | 9 +++++++++ .../host_vars/vmhost-x86-copr03.rdu3.fedoraproject.org | 9 +++++++++ .../host_vars/vmhost-x86-copr04.rdu3.fedoraproject.org | 9 +++++++++ roles/zabbix/zabbix_agent/tasks/hosts.yml | 2 ++ 7 files changed, 48 insertions(+) diff --git a/inventory/group_vars/all b/inventory/group_vars/all index c8327387de..b33a701dec 100644 --- a/inventory/group_vars/all +++ b/inventory/group_vars/all @@ -341,6 +341,11 @@ zabbix_url_path: "" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. h zabbix_host: "zabbix01{{ env_suffix }}.{{ datacenter }}.fedoraproject.org" zabbix_tls_psk_identity: "Fedora" zabbix_tls_psk: "{{ zabbix_tls_prod_psk }}" # in ansible-private repo +# This is used to populate the inventory fields, only specific keys are allowed, see +# https://www.zabbix.com/documentation/current/en/manual/api/reference/host/object#host-inventory +zabbix_inventory: + # Env is not a valid key, so use this field for environment + deployment_status: production notes: | Unspecified. diff --git a/inventory/group_vars/staging b/inventory/group_vars/staging index 0d2e33812f..3e223ca440 100644 --- a/inventory/group_vars/staging +++ b/inventory/group_vars/staging @@ -69,3 +69,8 @@ wildcard_key_file: wildcard-2025.stg.fedoraproject.org.key zabbix_server: zabbix.stg.fedoraproject.org zabbix_auth_key: "{{ zabbix_stg_apikey }}" # in ansible-private repo zabbix_tls_psk: "{{ zabbix_tls_stg_psk }}" # in ansible-private repo +# This is used to populate the inventory fields, only specific keys are allowed, see +# https://www.zabbix.com/documentation/current/en/manual/api/reference/host/object#host-inventory +zabbix_inventory: + # Env is not a valid key, so use this field for environment + deployment_status: staging diff --git a/inventory/host_vars/vmhost-x86-copr01.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr01.rdu3.fedoraproject.org index 04a66ac812..5368d02ac8 100644 --- a/inventory/host_vars/vmhost-x86-copr01.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr01.rdu3.fedoraproject.org @@ -65,3 +65,12 @@ network_connections: state: up mtu: 1500 zabbix_host: zabbix01.vpn.fedoraproject.org +# This is used to populate the inventory fields, only specific keys are allowed, see +# https://www.zabbix.com/documentation/current/en/manual/api/reference/host/object#host-inventory +zabbix_inventory: + hardware: PowerEdge R6525 + location: RDU3 + oob_ip: 10.16.160.23 + serialno_a: BM4LS13 + site_rack: W34 U18 + vendor: Dell diff --git a/inventory/host_vars/vmhost-x86-copr02.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr02.rdu3.fedoraproject.org index 2c82e9db40..004eaebbcb 100644 --- a/inventory/host_vars/vmhost-x86-copr02.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr02.rdu3.fedoraproject.org @@ -63,3 +63,12 @@ network_connections: state: up mtu: 1500 zabbix_host: zabbix01.vpn.fedoraproject.org +# This is used to populate the inventory fields, only specific keys are allowed, see +# https://www.zabbix.com/documentation/current/en/manual/api/reference/host/object#host-inventory +zabbix_inventory: + hardware: PowerEdge R6525 + location: RDU3 + oob_ip: 10.16.160.24 + serialno_a: BM4MS13 + site_rack: W34 U19 + vendor: Dell diff --git a/inventory/host_vars/vmhost-x86-copr03.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr03.rdu3.fedoraproject.org index a8b92c0a84..3ee9c9a40b 100644 --- a/inventory/host_vars/vmhost-x86-copr03.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr03.rdu3.fedoraproject.org @@ -65,3 +65,12 @@ network_connections: state: up mtu: 1500 zabbix_host: zabbix01.vpn.fedoraproject.org +# This is used to populate the inventory fields, only specific keys are allowed, see +# https://www.zabbix.com/documentation/current/en/manual/api/reference/host/object#host-inventory +zabbix_inventory: + hardware: PowerEdge R6525 + location: RDU3 + oob_ip: 10.16.160.25 + serialno_a: BM4KS13 + site_rack: W34 U20 + vendor: Dell diff --git a/inventory/host_vars/vmhost-x86-copr04.rdu3.fedoraproject.org b/inventory/host_vars/vmhost-x86-copr04.rdu3.fedoraproject.org index fb9ec00ce5..10c1471940 100644 --- a/inventory/host_vars/vmhost-x86-copr04.rdu3.fedoraproject.org +++ b/inventory/host_vars/vmhost-x86-copr04.rdu3.fedoraproject.org @@ -65,3 +65,12 @@ network_connections: state: up mtu: 1500 zabbix_host: zabbix01.vpn.fedoraproject.org +# This is used to populate the inventory fields, only specific keys are allowed, see +# https://www.zabbix.com/documentation/current/en/manual/api/reference/host/object#host-inventory +zabbix_inventory: + hardware: PowerEdge R6525 + location: RDU3 + oob_ip: 10.16.160.26 + serialno_a: BM3RS13 + site_rack: BB34 U18 + vendor: Dell diff --git a/roles/zabbix/zabbix_agent/tasks/hosts.yml b/roles/zabbix/zabbix_agent/tasks/hosts.yml index 5fad2ea1a8..ac040da7b7 100644 --- a/roles/zabbix/zabbix_agent/tasks/hosts.yml +++ b/roles/zabbix/zabbix_agent/tasks/hosts.yml @@ -26,6 +26,8 @@ host_name: "{{ inventory_hostname }}" host_groups: "{{ zabbix_base_hostgroups }}" link_templates: "{{ zabbix_base_templates }}" + inventory_mode: manual + inventory_zabbix: "{{ zabbix_inventory }}" interfaces: - type: agent main: 1