diff --git a/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 b/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 index fbd4b86fdb..cd42e1da82 100644 --- a/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 +++ b/roles/nagios_server/templates/nagios/hostgroups/all.cfg.j2 @@ -2,6 +2,16 @@ # All Servers and associated devices ############### ## {{ env }} +{% for key, value in groups.iteritems()|sort %} +{% if groups[key] != [] and key not in vars['exclude_hostgroups'] %} +define hostgroup{ + hostgroup_name {{ key }} + alias {{ key }} + members {% for host in groups[key]|sort %}{% if hostvars[host].nagios_Can_Connect == true %}{{host}}, {% endif %}{% endfor %} + +} +{% endif %} +{% endfor %} define hostgroup{ hostgroup_name no_ping