Set-OPS-Public/roles/hosts_statiques/templates/hosts.j2

23 lines
1.1 KiB
Text
Raw Normal View History

# /etc/hosts — GÉNÉRÉ par Set-OPS (rôle hosts_statiques) depuis l'inventaire.
# Plancher de résolution interne, indépendant du serveur DNS. NE PAS éditer à la main.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# --- Écosystème (dérivé du plan ; chaque hôte → son IP réelle) ---
{% set fleet = (groups.get('hotes_actifs', []) + groups.get('hotes_planifies', [])) | unique | sort %}
{% for h in fleet if hostvars[h].ansible_host is defined %}
{{ "%-15s" | format(hostvars[h].ansible_host) }} {{ h }}{{ (' ' ~ h ~ '.' ~ hosts_statiques_domaine) if hosts_statiques_domaine else '' }}
{% endfor %}
{% if hosts_statiques_publier_expositions | default(false) and hosts_statiques_expositions %}
# --- Alias d'exposition (FQDN publics → l'edge qui les sert) ---
{% for expo in hosts_statiques_expositions %}
{% set edge_hosts = groups.get(expo.edge, []) %}
{% if edge_hosts and hostvars[edge_hosts[0]].ansible_host is defined %}
{{ "%-15s" | format(hostvars[edge_hosts[0]].ansible_host) }} {{ expo.fqdn }}
{% endif %}
{% endfor %}
{% endif %}