{% for host in groups['cloud']|sort %}
{% if host.startswith('copr') and vars['nagios_location'] == 'external' %}
{% else %}
define host {
{% if hostvars[host].nagios_Check_Services['nrpe'] and vars['nagios_location'] == '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].eth0_ip is defined %}
   address                 {{ hostvars[host].eth0_ip }}
{% elif hostvars[host].ansible_default_ipv4 is defined %}
{% if hostvars[host].ansible_default_ipv4.address is defined and host not in groups['cloud'] %}
   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                 cloud-gw
{% endif %}
}
{% endif %}
{% endfor %}
