bundles/icinga2: add hostgroup for every bw group
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit

This commit is contained in:
Franzi 2020-11-21 22:46:29 +01:00
parent 12cf03e03f
commit 0bc4b5439c
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 22 additions and 2 deletions

View file

@ -0,0 +1,7 @@
% for group in sorted(repo.groups):
object HostGroup "group-${group.name}" {
display_name = "bw group ${group.name}"
assign where "${group.name}" in host.vars.bw_groups
}
% endfor

View file

@ -2,10 +2,13 @@
object Host "${monitored_node.name}" { object Host "${monitored_node.name}" {
import "generic-host" import "generic-host"
vars.os = "Linux" address = "${monitored_node.metadata.get('icinga_options', {}).get('hostname', monitored_node.hostname)}"
vars.os = "${monitored_node.os}"
vars.sla = "${monitored_node.metadata.get('sla', '24x7')}" vars.sla = "${monitored_node.metadata.get('sla', '24x7')}"
vars.period = "${sla_info[monitored_node.metadata.get('sla', '24x7')]}" vars.period = "${sla_info[monitored_node.metadata.get('sla', '24x7')]}"
address = "${monitored_node.metadata.get('icinga_options', {}).get('hostname', monitored_node.hostname)}" vars.location = "${monitored_node.metadata.get('location', 'unknown')}"
vars.bw_groups = [ "${'", "'.join(sorted({group.name for group in monitored_node.groups}))}" ]
} }
% endfor % endfor

View file

@ -129,6 +129,16 @@ files = {
'svc_systemd:icinga2:restart', 'svc_systemd:icinga2:restart',
}, },
}, },
'/etc/icinga2/conf.d/groups.conf': {
'source': 'icinga2/groups.conf',
'content_type': 'mako',
'needs': {
'pkg_apt:icinga2',
},
'triggers': {
'svc_systemd:icinga2:restart',
},
},
'/etc/icinga2/conf.d/templates.conf': { '/etc/icinga2/conf.d/templates.conf': {
'source': 'icinga2/templates.conf', 'source': 'icinga2/templates.conf',
'needs': { 'needs': {