Make hosts file dynamic according to machine type

This commit is contained in:
Sam A. 2023-11-07 21:27:35 +01:00
parent 2ed912de44
commit a15eb67a0f
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA

View file

@ -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 %}