Zabbix-stg: Enable setting host-level overrides to template macros
This commit is contained in:
parent
b6bf597a91
commit
634f70c457
6 changed files with 65 additions and 2 deletions
|
@ -21,3 +21,15 @@ num_cpus: 4
|
||||||
# the host_vars/$hostname file
|
# the host_vars/$hostname file
|
||||||
tcp_ports: [80, 443]
|
tcp_ports: [80, 443]
|
||||||
notes: Test instanec for zabbix server
|
notes: Test instanec for zabbix server
|
||||||
|
|
||||||
|
# Template defaults are defined in the template macros
|
||||||
|
# If we need a specific host to have different values for a macro,
|
||||||
|
# define it here
|
||||||
|
|
||||||
|
# Use the macro name as it is in Zabbix so we can search for it easily
|
||||||
|
|
||||||
|
# If you remove a key, Zabbix is *not* updated - set the value to
|
||||||
|
# "absent" instead
|
||||||
|
|
||||||
|
# This is overriden at the host_var level
|
||||||
|
zabbix_macros: {}
|
||||||
|
|
|
@ -22,3 +22,15 @@ num_cpus: 2
|
||||||
tcp_ports: [80, 443]
|
tcp_ports: [80, 443]
|
||||||
notes: Test instance for zabbix server
|
notes: Test instance for zabbix server
|
||||||
zabbix_stg_matrix_roomid: "!dODrizXNtqWjiylAyh:fedora.im"
|
zabbix_stg_matrix_roomid: "!dODrizXNtqWjiylAyh:fedora.im"
|
||||||
|
|
||||||
|
# Template defaults are defined in the template macros
|
||||||
|
# If we need a specific host to have different values for a macro,
|
||||||
|
# define it here
|
||||||
|
|
||||||
|
# Use the macro name as it is in Zabbix so we can search for it easily
|
||||||
|
|
||||||
|
# If you remove a key, Zabbix is *not* updated - set the value to
|
||||||
|
# "absent" instead
|
||||||
|
|
||||||
|
# This is overriden at the host_var level
|
||||||
|
zabbix_macros: {}
|
||||||
|
|
|
@ -8,3 +8,8 @@ ks_repo: https://infrastructure.fedoraproject.org/repo/rhel/RHEL9-x86_64/
|
||||||
ks_url: https://infrastructure.fedoraproject.org/repo/rhel/ks/kvm-rhel
|
ks_url: https://infrastructure.fedoraproject.org/repo/rhel/ks/kvm-rhel
|
||||||
vmhost: vmhost-x86-02.stg.iad2.fedoraproject.org
|
vmhost: vmhost-x86-02.stg.iad2.fedoraproject.org
|
||||||
volgroup: /dev/vg_guests
|
volgroup: /dev/vg_guests
|
||||||
|
|
||||||
|
# see group_vars/zabbix_stg for details
|
||||||
|
zabbix_macros:
|
||||||
|
VFS.DEV.READ.AWAIT.WARN: 30
|
||||||
|
VFS.DEV.WRITE.AWAIT.WARN: 30
|
||||||
|
|
|
@ -8,3 +8,8 @@ ks_repo: https://infrastructure.fedoraproject.org/repo/rhel/RHEL9-x86_64/
|
||||||
ks_url: https://infrastructure.fedoraproject.org/repo/rhel/ks/kvm-rhel
|
ks_url: https://infrastructure.fedoraproject.org/repo/rhel/ks/kvm-rhel
|
||||||
vmhost: vmhost-x86-02.stg.iad2.fedoraproject.org
|
vmhost: vmhost-x86-02.stg.iad2.fedoraproject.org
|
||||||
volgroup: /dev/vg_guests
|
volgroup: /dev/vg_guests
|
||||||
|
|
||||||
|
# see group_vars/zabbix_stg for details
|
||||||
|
zabbix_macros:
|
||||||
|
VFS.DEV.READ.AWAIT.WARN: 30
|
||||||
|
VFS.DEV.WRITE.AWAIT.WARN: 30
|
||||||
|
|
23
roles/zabbix/zabbix_agent/tasks/macros.yml
Normal file
23
roles/zabbix/zabbix_agent/tasks/macros.yml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
# This applies any host-level overrides to macro (variable) values in Zabbix.
|
||||||
|
# It's applied through the base agent role, but will work for the macros in
|
||||||
|
# *any* template, since unused macros will be ignored anyway.
|
||||||
|
|
||||||
|
- name: Set Host-level macros
|
||||||
|
loop: "{{ lookup('dict', zabbix_macros, wantlist=True) }}"
|
||||||
|
vars:
|
||||||
|
ansible_zabbix_auth_key: "{{ (env == 'staging') | ternary(zabbix_stg_apikey, zabbix_apikey) }}"
|
||||||
|
ansible_network_os: community.zabbix.zabbix
|
||||||
|
ansible_connection: httpapi
|
||||||
|
ansible_httpapi_port: 443
|
||||||
|
ansible_httpapi_use_ssl: true
|
||||||
|
ansible_httpapi_validate_certs: false
|
||||||
|
ansible_host: "{{ (env == 'staging') | ternary(zabbix_stg_hostname, zabbix_hostname) }}"
|
||||||
|
ansible_zabbix_url_path: ""
|
||||||
|
community.zabbix.zabbix_hostmacro:
|
||||||
|
host_name: "{{ inventory_hostname }}"
|
||||||
|
macro_name: "{{ item.key }}"
|
||||||
|
macro_value: "{{ item.value }}"
|
||||||
|
state: "{{ 'absent' if item.value == 'absent' else 'present' }}"
|
||||||
|
tags:
|
||||||
|
- zabbix_macros
|
|
@ -109,7 +109,7 @@
|
||||||
- zabbix_agent
|
- zabbix_agent
|
||||||
|
|
||||||
- name: Enabling Zabbix service
|
- name: Enabling Zabbix service
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: started
|
state: started
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
@ -118,4 +118,10 @@
|
||||||
tags:
|
tags:
|
||||||
- zabbix_agent
|
- zabbix_agent
|
||||||
|
|
||||||
- include_tasks: tools.yml
|
- name: Configure Zabbix tools
|
||||||
|
ansible.builtin.include_tasks: tools.yml
|
||||||
|
|
||||||
|
- name: Configure Zabbix macros / variables
|
||||||
|
ansible.builtin.include_tasks: macros.yml
|
||||||
|
tags:
|
||||||
|
- zabbix_macros
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue