refactor(dns): set source of dns domain on fw.yaml

This commit is contained in:
il
2026-06-29 11:46:53 +09:00
parent 5ccb60bd2a
commit 88e85fff56
43 changed files with 606 additions and 406 deletions
@@ -0,0 +1,50 @@
$TTL 86400
@ IN SOA {{ services['bind']['domain']['internal'] }}.{{ domain['internal'] }}. {{ services['bind']['domain']['internal'] }}.{{ domain['internal'] }}. (
{{ network['dns_serial'] }} ; serial
3600 ; refresh (1 hour)
1800 ; retry (30 minutes)
604800 ; expire (1 week)
86400 ; minimum (1 day)
)
IN NS {{ services['bind']['domain']['internal'] }}.{{ domain['internal'] }}.
{%
set hosts = (
network
| dict2items
| rejectattr('key', 'in', ['dns_serial', 'subnet', 'reverse_zone'])
| list
)
%}
{%
set alias_hosts = (
network
| dict2items
| rejectattr('key', 'in', ['dns_serial', 'subnet', 'reverse_zone'])
| selectattr('value.alias', 'defined')
| list
)
%}
{% for item in hosts %}
{% set name = item['key'] %}
{% set host = item['value'] %}
{% if host['ipv4'] is defined %}
{% if host['ipv4']['server'] is defined %}
{{ "%-12s" | format(name) }}IN A {{ host['ipv4']['server'] }}
{% elif host['ipv4']['client'] is defined %}
{{ "%-12s" | format(name) }}IN A {{ host['ipv4']['client'] }}
{% endif %}
{% endif %}
{% if host['ipv6'] is defined %}
{% if host['ipv6']['server'] is defined %}
{{ "%-12s" | format(name) }}IN AAAA {{ host['ipv6']['server'] }}
{% elif host['ipv6']['client'] is defined %}
{{ "%-12s" | format(name) }}IN AAAA {{ host['ipv6']['client'] }}
{% endif %}
{% endif %}
{% endfor %}
{% for item in alias_hosts %}
{% for alias in item['value']['alias'] %}
{{ "%-12s" | format(alias) }}IN CNAME {{ item['key'] }}.{{ domain['internal'] }}.
{% endfor %}
{% endfor %}