nagios: allow empty non-member groups

This is mostly to fix the ansible-playbook failure
`nagios -v /etc/nagios/nagios.cfg` if `member` is empty.
This commit is contained in:
Pavel Raiskup 2023-04-25 13:17:21 +02:00
parent 4cfcfcc4d8
commit 01129c2be3
2 changed files with 5 additions and 3 deletions

View file

@ -1,6 +1,6 @@
hostbase: copr-pulp-
# This instance is WIP and we don't want nagios alerts yet
nagios_Can_Connect: false
nagios_Can_Connect: true
nagios_Check_Services:
dhcpd: false
httpd: false

View file

@ -7,8 +7,10 @@
define hostgroup{
hostgroup_name {{ key }}
alias {{ key }}
members {% for host in groups[key]|sort %}{% if hostvars[host].nagios_Can_Connect == true %}{{host}}, {% endif %}{% endfor %}
{% for host in groups[key]|sort if hostvars[host].nagios_Can_Connect == true %}
{% if loop.first %}
members {{ host }}{% else %}, {{ host }}{% endif %}
{%- endfor %}
}
{% endif %}
{% endfor %}