refactor: Change records file deployment

This commit is contained in:
2025-03-30 08:36:09 +02:00
parent 02056f9e6f
commit bd8d50c06d
7 changed files with 26 additions and 44 deletions

View File

@@ -1,12 +1,22 @@
# {{ ansible_managed }}
{% for host in groups[dnsmasq_ansible_group] %}
# ansible inventory
{%- for host in (groups[dnsmasq_ansible_group] | sort) %}
{%- set ipv4 = hostvars[host]['ansible_host'] %}
{%- set ipv6_prefix = dnsmasq_ipv6_subnet | split('/') | first %}
{%- 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 }}
## {{ host }}
{{ ipv4 }} {{ aliases | join(' ') }}
{{ ipv6 }} {{ aliases | join(' ') }}
{{ ipv6_prefix }}{{ ipv6_suffix }} {{ aliases | join(' ') }}
{% endfor %}
# role specifics
{%- for specific in dnsmasq_specifics %}
## {{ specific.hostname }}
{% for ip in specific.ips %}
{{ ip }} {{ specific.hostname }}
{% endfor %}
{% endfor %}

View File

@@ -1,17 +1,8 @@
# {{ ansible_managed }}
{% for specific in dnsmasq_specifics %}
{% for host in groups['zone_gaia'] %}
{%- set ipv4 = hostvars[host]['ansible_host'] %}
{%- set ipv6_suffix = hostvars[host]['ansible_host'] | split('.') | last %}
{%- 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 %}
# {{ specific.hostname }}
{% for ip in specific.ips %}
{{ ip }} {{ specific.hostname }}
{% endfor %}
{% endfor %}

View File

@@ -1,7 +0,0 @@
# {{ ansible_managed }}
{% for host in group['zone_gaia'] %}
# {{ inventory_hostname }}
192.168.84.{{ proxmox_host_id }} {{ inventory_hostname }} {{ inventory_hostname_short }} {{ dnsmasq_host_aliases | join(' ') }}
2a01:cb00:131:f100::d0{{ proxmox_host_id }} {{ inventory_hostname }} {{ inventory_hostname_short }} {{ dnsmasq_host_aliases | join(' ') }}
{% endfor %}