feat: Add new variable for ipv6 subnet

This commit is contained in:
pulsar89.5 2025-02-28 10:27:13 +01:00
parent 180fe1c26a
commit ed9eb28dfb
2 changed files with 5 additions and 7 deletions

View File

@ -18,5 +18,8 @@ dnsmasq_client_hostname: "{{ inventory_hostname }} {{ inventory_hostname_short }
# Groupe ansible pour l'enregistrement automatique
dnsmasq_ansible_group: zone_gaia
# CIDR du sous-réseau IPv6
dnsmasq_ipv6_subnet: ""
# Enregistrement spécifiques
dnsmasq_specifics: []

View File

@ -3,15 +3,10 @@
{% for host in groups[dnsmasq_ansible_group] %}
{%- set ipv4 = hostvars[host]['ansible_host'] %}
{%- set ipv6_suffix = hostvars[host]['ansible_host'] | split('.') | last %}
{%- set ipv6 = (dnsmasq_ipv6_subnet | split('/') | first) + ipv6_suffix %}
{%- set aliases = [host] + hostvars[host].get('dnsmasq_host_aliases', []) %}
# {{ host }}
{{ ipv4 }} {{ aliases | join(' ') }}
{% if (ipv6_suffix | int) < 10 %}
2a01:e0a:ee5:8b0::d00{{ ipv6_suffix }} {{ aliases | join(' ') }}
{% elif (ipv6_suffix | int) < 100 %}
2a01:e0a:ee5:8b0::d0{{ ipv6_suffix }} {{ aliases | join(' ') }}
{% else %}
2a01:e0a:ee5:8b0::d{{ ipv6_suffix }} {{ aliases | join(' ') }}
{% endif %}
{{ ipv6 }} {{ aliases | join(' ') }}
{% endfor %}