diff --git a/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 b/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 index 05dcff2c9a..dd54a04993 100644 --- a/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 +++ b/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 @@ -4,7 +4,9 @@ ## {{ env }} {% for key, value in groups.iteritems() %} -{% if groups[key] != [] and hostvars[host].nagios_Check_Services['monitor'] == true %} +{% if groups[key] != [] %} +{% for host in groups[key] %} +{% if hostvars[host].nagios_Check_Services['monitor'] == true %} define hostgroup{ hostgroup_name {{ key }} alias {{ key }} @@ -12,6 +14,7 @@ define hostgroup{ } {% endif %} +{% endif %} {% endfor %} ## Services with minimal monitoring