{% for host in groups['all']|sort %}
{% if hostvars[host].datacenter == 'rdu' and hostvars[host].nagios_Can_Connect == true %}
define host {
{% if vars['nagios_location'] == 'iad2_internal' %}
   use                     defaulttemplate
{% else %}
  use                          mincheck
{% endif %}
  host_name               {{ host }}
{% if hostvars[host].ansible_hostname is defined %}
   alias                   {{ hostvars[host].ansible_hostname }}
{% else %}
   alias                   {{ host }}
{% endif %}
{% if hostvars[host].public_ip is defined %}
   address                 {{ hostvars[host].public_ip }}
{% else %}
   address                 {{ host }}
{% endif %}
{% if hostvars[host]['vmhost'] is defined %}
   parents                 {{ hostvars[host]['vmhost'] }}
{% elif hostvars[host].datacenter is defined %}
   parents                 rdu-gw
{% endif %}
}

{% endif %}
{% endfor %}
