{% for host in groups['all']|sort %}
{% if hostvars[host].datacenter == 'phx2' and hostvars[host].nagios_Check_Services['ping'] == true %}
define host {
{% if hostvars[host].nagios_Check_Services['nrpe'] == true %}
   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].eth0_ip is defined %}
   address                 {{ hostvars[host].eth0_ip }}
{% elif hostvars[host].em3_ip is defined %}
   address                 {{ hostvars[host].em3_ip }}
{% elif hostvars[host].ansible_default_ipv4 is defined %}
{% if hostvars[host].ansible_default_ipv4.address is defined %}
   address                 {{ hostvars[host].ansible_default_ipv4.address }}
{% endif %}
{% else %}
   address                 {{ host }}
{% endif %}
{% if hostvars[host]['vmhost'] is defined %}
   parents                 {{ hostvars[host]['vmhost'] }}
{% elif hostvars[host].datacenter is defined %}
   parents                 phx2-gw
{% endif %}
}

{% endif %}
{% endfor %}
