diff --git a/roles/common/templates/etc/hosts.j2 b/roles/common/templates/etc/hosts.j2 index b1e62be..6cd5b0e 100644 --- a/roles/common/templates/etc/hosts.j2 +++ b/roles/common/templates/etc/hosts.j2 @@ -10,7 +10,19 @@ ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts -# Static hostnames for VMs +{% if hostname in groups['virtualservers'] %} +# Static hostnames for other VMs {% for host in groups['virtualservers'] %} {{ hostvars[host].private_ip }} {{ hostvars[host].fqdn }} {% endfor %} +{% elif hostname in groups['control_infr'] %} +# Static hostnames for VM hosts +{% for host in groups['vmhost_infr'] %} +{{ hostvars[host].ansible_host }} {{ hostvars[host].fqdn }} +{% endfor %} + +# Static hostnames for VMs +{% for host in groups['virtualservers'] %} +{{ hostvars[host].ansible_host }} {{ hostvars[host].fqdn }} +{% endfor %} +{% endif %}