Browse Source

roles/icinga2-monitoring: new monitored facts format

python3
Zolfa 5 years ago
parent
commit
1a2e4e565d
Signed by: zolfa GPG Key ID: E1A43B038C4D6616
3 changed files with 18 additions and 12 deletions
  1. +3
    -1
      roles/icinga2-monitoring/defaults/main.yaml
  2. +12
    -9
      roles/icinga2-monitoring/tasks/main.yaml
  3. +3
    -2
      roles/icinga2-monitoring/templates/host.conf.j2

+ 3
- 1
roles/icinga2-monitoring/defaults/main.yaml View File

@ -1 +1,3 @@
monitoring_host: []
---
monitoring_facts: {}
...

+ 12
- 9
roles/icinga2-monitoring/tasks/main.yaml View File

@ -1,15 +1,18 @@
- include_role:
name: service
name: 'service'
vars:
service_name: icinga2
service_name: 'icinga2'
tags:
- 'monitoring'
- debug:
var: monitoring_host
var: 'monitoring_facts'
- name: add host monitoring
- name: 'MONITORING | configure HOST/{{ item.key }}'
template:
src: host.conf.j2
dest: "/etc/icinga2/conf.d/hosts/{{ item }}.conf"
with_items:
- "{{ monitoring_host }}"
notify: reload icinga2
src: 'host.conf.j2'
dest: "/etc/icinga2/conf.d/hosts/{{ item.key }}.conf"
loop: '{{ monitoring_facts|dict2items }}'
notify: 'reload icinga2'
tags:
- 'monitoring'

+ 3
- 2
roles/icinga2-monitoring/templates/host.conf.j2 View File

@ -1,7 +1,8 @@
object Host "{{ item }}" {
object Host "{{ item.key }}" {
import "generic-host"
address = "{{ item.value.address }}"
vars.os = "Linux"
vars.address = "{{ hostvars | ip_from_inventory(item) }}"
vars.sla = "24x7"
}

Loading…
Cancel
Save