nagios: fix empty groups members in all-external.cfg.j2

This commit is contained in:
Pavel Raiskup 2023-04-26 09:18:06 +02:00
parent 5adeb88890
commit 56c3f11a48
2 changed files with 8 additions and 7 deletions

View file

@ -35,11 +35,13 @@ define hostgroup {
{% for key, value in groups.items()|sort %}
{% if groups[key] != [] and key.startswith('copr') %}
define hostgroup{
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 %}

View file

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