forked from infra/ansible
Zabbix: re-use base monitoring role in zabbix_server for non-Ansible hosts
Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
parent
75051c499d
commit
a0d52dff1a
6 changed files with 78 additions and 16 deletions
|
|
@ -3,4 +3,3 @@ dns1: 10.16.163.33
|
|||
dns2: 10.16.163.34
|
||||
dns_search1: rdu3.fedoraproject.org
|
||||
nbde: false
|
||||
zabbix_ping_only: false
|
||||
|
|
|
|||
|
|
@ -4,4 +4,3 @@ dns1: 10.16.163.33
|
|||
dns2: 10.16.163.34
|
||||
dns_search1: rdu3.fedoraproject.org
|
||||
nbde: false
|
||||
zabbix_ping_only: false
|
||||
|
|
|
|||
|
|
@ -15,11 +15,39 @@ zabbix_pkgs_list:
|
|||
- zabbix-sender
|
||||
- bc
|
||||
# These hosts are not running Zabbix or not under Ansible control
|
||||
# So we define them manually in the zabbix_server role for ping checks
|
||||
# So we define them manually in the zabbix_server role for ping/mgmt checks
|
||||
# If bmc is not defined, it only does ping against the DNS name
|
||||
zabbix_external_hosts:
|
||||
- opengear01.mgmt.rdu3.fedoraproject.org
|
||||
- worker01.mgmt.rdu3.fedoraproject.org
|
||||
- worker02.mgmt.rdu3.fedoraproject.org
|
||||
- worker03.mgmt.rdu3.fedoraproject.org
|
||||
- worker04.mgmt.rdu3.fedoraproject.org
|
||||
- worker05.mgmt.rdu3.fedoraproject.org
|
||||
- ocp01.ocp.rdu3.fedoraproject.org:
|
||||
- ocp02.ocp.rdu3.fedoraproject.org:
|
||||
- ocp03.ocp.rdu3.fedoraproject.org:
|
||||
- worker01.ocp.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.180
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
- worker02.ocp.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.181
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
- worker03.ocp.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.182
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
- worker04.ocp.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.51
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
- worker05.ocp.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.40
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
|
|
|
|||
|
|
@ -14,8 +14,27 @@ zabbix_pkgs_list:
|
|||
- zabbix-sender
|
||||
- bc
|
||||
# These hosts are not running Zabbix or not under Ansible control
|
||||
# So we define them manually in the zabbix_server role for ping checks
|
||||
# So we define them manually in the zabbix_server role for ping/mgmt checks
|
||||
# If bmc is not defined, it only does ping against the DNS name
|
||||
zabbix_external_hosts:
|
||||
- worker01-stg.mgmt.rdu3.fedoraproject.org
|
||||
- worker02-stg.mgmt.rdu3.fedoraproject.org
|
||||
- worker03-stg.mgmt.rdu3.fedoraproject.org
|
||||
- ocp01.ocp.stg.rdu3.fedoraproject.org:
|
||||
- ocp02.ocp.stg.rdu3.fedoraproject.org:
|
||||
- ocp03.ocp.stg.rdu3.fedoraproject.org:
|
||||
- worker01.ocp.stg.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.183
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
- worker02.ocp.stg.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.184
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
- worker03.ocp.stg.rdu3.fedoraproject.org
|
||||
bmc:
|
||||
ip_address: 10.16.160.185
|
||||
ping: true
|
||||
http: true
|
||||
https: true
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# Ensure the base Ping/BMC checks are present
|
||||
- name: Import base ping-and-bmc Zabbix template
|
||||
community.zabbix.zabbix_template:
|
||||
template_yaml: "{{ lookup('file', 'zabbix/base-template.yml') }}"
|
||||
# This is hardcoded relative to the playbooks, because it is *also* called from the zabbix_server role
|
||||
template_yaml: "{{ lookup('file', playbook_dir + '/../../roles/base/files/zabbix/base-template.yml') }}"
|
||||
state: present
|
||||
|
||||
# Create the host in Zabbix
|
||||
|
|
@ -74,7 +75,6 @@
|
|||
"{$MGMT_HTTPS}": "{{ bmc.https | default('False') | int }}"
|
||||
"{$MGMT_HTTP}": "{{ bmc.http | default('False') | int }}"
|
||||
"{$MGMT_PING}": "{{ bmc.ping | default('False') | int }}"
|
||||
loop: "{{ bmc | dict2items }}"
|
||||
|
||||
- name: Set host macros
|
||||
community.zabbix.zabbix_hostmacro:
|
||||
|
|
@ -82,4 +82,4 @@
|
|||
macro_name: "{{ item.key }}"
|
||||
macro_value: "{{ item.value }}"
|
||||
loop: "{{ bmc_macros | dict2items }}"
|
||||
when: "'bmc' in hostvars[inventory_hostname]"
|
||||
when: bmc is defined
|
||||
|
|
|
|||
|
|
@ -19,3 +19,20 @@
|
|||
ansible.builtin.include_tasks: start_services.yml
|
||||
tags:
|
||||
- zabbix
|
||||
|
||||
# Some hosts like the OCP workers are not under Ansible control, so we
|
||||
# define them in the zabbix server hostvars and use this task to
|
||||
# transform the data to the same format as Ansible hosts, and then
|
||||
# call the same code as all the other hosts use, in base
|
||||
- name: Handle non-Ansible host monitoring in Zabbix
|
||||
ansible.builtin.include_tasks:
|
||||
file: "{{ role_path }}/../../base/tasks/monitoring.yml"
|
||||
vars:
|
||||
inventory_hostname: "{{ ext_host.key }}"
|
||||
bmc: "{{ ext_host.value.bmc }}"
|
||||
loop: "{{ zabbix_external_hosts | map('dict2items') | flatten }}"
|
||||
loop_control:
|
||||
label: "{{ ext_host.key }}"
|
||||
loop_var: ext_host
|
||||
tags:
|
||||
- zabbix_api
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue