From 68f8acbaf44379173faaa8aa7cae6ee40024df88 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 16 Apr 2022 12:13:06 +0200 Subject: dns: T4353: fix Jinja2 linting errors --- data/templates/dns-forwarding/recursor.conf.j2 | 42 ++++++++++++++++++ data/templates/dns-forwarding/recursor.conf.lua.j2 | 9 ++++ .../dns-forwarding/recursor.conf.lua.tmpl | 9 ---- data/templates/dns-forwarding/recursor.conf.tmpl | 41 ----------------- .../dns-forwarding/recursor.forward-zones.conf.j2 | 29 ++++++++++++ .../recursor.forward-zones.conf.tmpl | 28 ------------ .../recursor.vyos-hostsd.conf.lua.j2 | 30 +++++++++++++ .../recursor.vyos-hostsd.conf.lua.tmpl | 30 ------------- .../templates/dns-forwarding/recursor.zone.conf.j2 | 6 +++ .../dns-forwarding/recursor.zone.conf.tmpl | 7 --- data/templates/dynamic-dns/ddclient.conf.j2 | 51 ++++++++++++++++++++++ data/templates/dynamic-dns/ddclient.conf.tmpl | 51 ---------------------- data/templates/vyos-hostsd/hosts.j2 | 26 +++++++++++ data/templates/vyos-hostsd/hosts.tmpl | 25 ----------- data/templates/vyos-hostsd/resolv.conf.j2 | 25 +++++++++++ data/templates/vyos-hostsd/resolv.conf.tmpl | 25 ----------- 16 files changed, 218 insertions(+), 216 deletions(-) create mode 100644 data/templates/dns-forwarding/recursor.conf.j2 create mode 100644 data/templates/dns-forwarding/recursor.conf.lua.j2 delete mode 100644 data/templates/dns-forwarding/recursor.conf.lua.tmpl delete mode 100644 data/templates/dns-forwarding/recursor.conf.tmpl create mode 100644 data/templates/dns-forwarding/recursor.forward-zones.conf.j2 delete mode 100644 data/templates/dns-forwarding/recursor.forward-zones.conf.tmpl create mode 100644 data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.j2 delete mode 100644 data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.tmpl create mode 100644 data/templates/dns-forwarding/recursor.zone.conf.j2 delete mode 100644 data/templates/dns-forwarding/recursor.zone.conf.tmpl create mode 100644 data/templates/dynamic-dns/ddclient.conf.j2 delete mode 100644 data/templates/dynamic-dns/ddclient.conf.tmpl create mode 100644 data/templates/vyos-hostsd/hosts.j2 delete mode 100644 data/templates/vyos-hostsd/hosts.tmpl create mode 100644 data/templates/vyos-hostsd/resolv.conf.j2 delete mode 100644 data/templates/vyos-hostsd/resolv.conf.tmpl (limited to 'data/templates') diff --git a/data/templates/dns-forwarding/recursor.conf.j2 b/data/templates/dns-forwarding/recursor.conf.j2 new file mode 100644 index 000000000..c1950e1bc --- /dev/null +++ b/data/templates/dns-forwarding/recursor.conf.j2 @@ -0,0 +1,42 @@ +{# j2lint: disable=single-statement-per-line #} +### Autogenerated by dns_forwarding.py ### + +# XXX: pdns recursor doesn't like whitespace near entry separators, +# especially in the semicolon-separated lists of name servers. +# Please be careful if you edit the template. + +# Non-configurable defaults +daemon=yes +threads=1 +allow-from={{ allow_from | join(',') }} +log-common-errors=yes +non-local-bind=yes +query-local-address={{ source_address | join(',') }} +lua-config-file=recursor.conf.lua + +# cache-size +max-cache-entries={{ cache_size }} + +# negative TTL for NXDOMAIN +max-negative-ttl={{ negative_ttl }} + +# timeout +network-timeout={{ timeout }} + +# ignore-hosts-file +export-etc-hosts={{ 'no' if ignore_hosts_file is vyos_defined else 'yes' }} + +# listen-address +local-address={{ listen_address | join(',') }} + +# dnssec +dnssec={{ dnssec }} + +# serve rfc1918 records +serve-rfc1918={{ 'no' if no_serve_rfc1918 is vyos_defined else 'yes' }} + +# zones +auth-zones={% for z in authoritative_zones %}{{ z.name }}={{ z.file }}{{- "," if not loop.last -}}{% endfor %} + +forward-zones-file=recursor.forward-zones.conf + diff --git a/data/templates/dns-forwarding/recursor.conf.lua.j2 b/data/templates/dns-forwarding/recursor.conf.lua.j2 new file mode 100644 index 000000000..e2506238d --- /dev/null +++ b/data/templates/dns-forwarding/recursor.conf.lua.j2 @@ -0,0 +1,9 @@ +-- Autogenerated by VyOS (dns_forwarding.py) -- +-- Do not edit, your changes will get overwritten -- + +-- Load DNSSEC root keys from dns-root-data package. +dofile("/usr/share/pdns-recursor/lua-config/rootkeys.lua") + +-- Load lua from vyos-hostsd -- +dofile("recursor.vyos-hostsd.conf.lua") + diff --git a/data/templates/dns-forwarding/recursor.conf.lua.tmpl b/data/templates/dns-forwarding/recursor.conf.lua.tmpl deleted file mode 100644 index e2506238d..000000000 --- a/data/templates/dns-forwarding/recursor.conf.lua.tmpl +++ /dev/null @@ -1,9 +0,0 @@ --- Autogenerated by VyOS (dns_forwarding.py) -- --- Do not edit, your changes will get overwritten -- - --- Load DNSSEC root keys from dns-root-data package. -dofile("/usr/share/pdns-recursor/lua-config/rootkeys.lua") - --- Load lua from vyos-hostsd -- -dofile("recursor.vyos-hostsd.conf.lua") - diff --git a/data/templates/dns-forwarding/recursor.conf.tmpl b/data/templates/dns-forwarding/recursor.conf.tmpl deleted file mode 100644 index 385bef94b..000000000 --- a/data/templates/dns-forwarding/recursor.conf.tmpl +++ /dev/null @@ -1,41 +0,0 @@ -### Autogenerated by dns_forwarding.py ### - -# XXX: pdns recursor doesn't like whitespace near entry separators, -# especially in the semicolon-separated lists of name servers. -# Please be careful if you edit the template. - -# Non-configurable defaults -daemon=yes -threads=1 -allow-from={{ allow_from | join(',') }} -log-common-errors=yes -non-local-bind=yes -query-local-address={{ source_address | join(',') }} -lua-config-file=recursor.conf.lua - -# cache-size -max-cache-entries={{ cache_size }} - -# negative TTL for NXDOMAIN -max-negative-ttl={{ negative_ttl }} - -# timeout -network-timeout={{ timeout }} - -# ignore-hosts-file -export-etc-hosts={{ 'no' if ignore_hosts_file is vyos_defined else 'yes' }} - -# listen-address -local-address={{ listen_address | join(',') }} - -# dnssec -dnssec={{ dnssec }} - -# serve rfc1918 records -serve-rfc1918={{ 'no' if no_serve_rfc1918 is vyos_defined else 'yes' }} - -# zones -auth-zones={% for z in authoritative_zones %}{{ z.name }}={{ z.file }}{{- "," if not loop.last -}}{% endfor %} - -forward-zones-file=recursor.forward-zones.conf - diff --git a/data/templates/dns-forwarding/recursor.forward-zones.conf.j2 b/data/templates/dns-forwarding/recursor.forward-zones.conf.j2 new file mode 100644 index 000000000..de3269e47 --- /dev/null +++ b/data/templates/dns-forwarding/recursor.forward-zones.conf.j2 @@ -0,0 +1,29 @@ +{# j2lint: disable=operator-enclosed-by-spaces #} +# Autogenerated by VyOS (vyos-hostsd) +# Do not edit, your changes will get overwritten + +# dot zone (catch-all): '+' indicates recursion is desired +# (same as forward-zones-recurse) +{# the code below ensures the order of nameservers is determined first by #} +{# the order of tags, then by the order of nameservers within that tag #} +{% set n = namespace(dot_zone_ns='') %} +{% for tag in name_server_tags_recursor %} +{% set ns = '' %} +{% if tag in name_servers %} +{% set ns = ns + name_servers[tag] | join(', ') %} +{% set n.dot_zone_ns = (n.dot_zone_ns, ns) | join(', ') if n.dot_zone_ns != '' else ns %} +{% endif %} +# {{ tag }}: {{ ns }} +{% endfor %} + +{% if n.dot_zone_ns %} ++.={{ n.dot_zone_ns }} +{% endif %} + +{% if forward_zones is vyos_defined %} +# zones added via 'service dns forwarding domain' +{% for zone, zonedata in forward_zones.items() %} +{{ "+" if zonedata.recursion_desired is vyos_defined }}{{ zone | replace('_', '-') }}={{ zonedata.server | join(', ') }} +{% endfor %} +{% endif %} + diff --git a/data/templates/dns-forwarding/recursor.forward-zones.conf.tmpl b/data/templates/dns-forwarding/recursor.forward-zones.conf.tmpl deleted file mode 100644 index 96cbc35a5..000000000 --- a/data/templates/dns-forwarding/recursor.forward-zones.conf.tmpl +++ /dev/null @@ -1,28 +0,0 @@ -# Autogenerated by VyOS (vyos-hostsd) -# Do not edit, your changes will get overwritten - -# dot zone (catch-all): '+' indicates recursion is desired -# (same as forward-zones-recurse) -{# the code below ensures the order of nameservers is determined first by #} -{# the order of tags, then by the order of nameservers within that tag #} -{% set n = namespace(dot_zone_ns='') %} -{% for tag in name_server_tags_recursor %} -{% set ns = '' %} -{% if tag in name_servers %} -{% set ns = ns + name_servers[tag]|join(', ') %} -{% set n.dot_zone_ns = (n.dot_zone_ns, ns)|join(', ') if n.dot_zone_ns != '' else ns %} -{% endif %} -# {{ tag }}: {{ ns }} -{% endfor %} - -{% if n.dot_zone_ns %} -+.={{ n.dot_zone_ns }} -{% endif %} - -{% if forward_zones is vyos_defined %} -# zones added via 'service dns forwarding domain' -{% for zone, zonedata in forward_zones.items() %} -{{ "+" if zonedata.recursion_desired is vyos_defined }}{{ zone | replace('_', '-') }}={{ zonedata.server | join(', ') }} -{% endfor %} -{% endif %} - diff --git a/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.j2 b/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.j2 new file mode 100644 index 000000000..987c7de1f --- /dev/null +++ b/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.j2 @@ -0,0 +1,30 @@ +-- Autogenerated by VyOS (vyos-hostsd) -- +-- Do not edit, your changes will get overwritten -- + +{% if hosts %} +-- from 'system static-host-mapping' and DHCP server +{% for tag, taghosts in hosts.items() %} +{% for host, hostprops in taghosts.items() %} +addNTA("{{ host }}.", "{{ tag }}") +{% for a in hostprops['aliases'] %} +addNTA("{{ a }}.", "{{ tag }} alias") +{% endfor %} +{% endfor %} +{% endfor %} +{% endif %} + +{% if forward_zones is vyos_defined %} +-- from 'service dns forwarding domain' +{% for zone, zonedata in forward_zones.items() %} +{% if zonedata.addnta is vyos_defined %} +addNTA("{{ zone }}", "static") +{% endif %} +{% endfor %} +{% endif %} + +{% if authoritative_zones is vyos_defined %} +-- from 'service dns forwarding authoritative-domain' +{% for zone in authoritative_zones %} +addNTA("{{ zone }}", "static") +{% endfor %} +{% endif %} diff --git a/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.tmpl b/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.tmpl deleted file mode 100644 index 04fb72121..000000000 --- a/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.tmpl +++ /dev/null @@ -1,30 +0,0 @@ --- Autogenerated by VyOS (vyos-hostsd) -- --- Do not edit, your changes will get overwritten -- - -{% if hosts %} --- from 'system static-host-mapping' and DHCP server -{% for tag, taghosts in hosts.items() %} -{% for host, hostprops in taghosts.items() %} -addNTA("{{ host }}.", "{{ tag }}") -{% for a in hostprops['aliases'] %} -addNTA("{{ a }}.", "{{ tag }} alias") -{% endfor %} -{% endfor %} -{% endfor %} -{% endif %} - -{% if forward_zones is vyos_defined %} --- from 'service dns forwarding domain' -{% for zone, zonedata in forward_zones.items() %} -{% if zonedata.addnta is vyos_defined %} -addNTA("{{ zone }}", "static") -{% endif %} -{% endfor %} -{% endif %} - -{% if authoritative_zones is vyos_defined %} --- from 'service dns forwarding authoritative-domain' -{% for zone in authoritative_zones %} -addNTA("{{ zone }}", "static") -{% endfor %} -{% endif %} diff --git a/data/templates/dns-forwarding/recursor.zone.conf.j2 b/data/templates/dns-forwarding/recursor.zone.conf.j2 new file mode 100644 index 000000000..25193c2ec --- /dev/null +++ b/data/templates/dns-forwarding/recursor.zone.conf.j2 @@ -0,0 +1,6 @@ +; +; Autogenerated by dns_forwarding.py +; +{% for r in records %} +{{ r.name }} {{ r.ttl }} {{ r.type }} {{ r.value }} +{% endfor %} diff --git a/data/templates/dns-forwarding/recursor.zone.conf.tmpl b/data/templates/dns-forwarding/recursor.zone.conf.tmpl deleted file mode 100644 index 758871bef..000000000 --- a/data/templates/dns-forwarding/recursor.zone.conf.tmpl +++ /dev/null @@ -1,7 +0,0 @@ -; -; Autogenerated by dns_forwarding.py -; -; -{% for r in records %} -{{ r.name }} {{ r.ttl }} {{ r.type }} {{ r.value }} -{% endfor %} diff --git a/data/templates/dynamic-dns/ddclient.conf.j2 b/data/templates/dynamic-dns/ddclient.conf.j2 new file mode 100644 index 000000000..3c2d17cbb --- /dev/null +++ b/data/templates/dynamic-dns/ddclient.conf.j2 @@ -0,0 +1,51 @@ +### Autogenerated by dynamic_dns.py ### +daemon=1m +syslog=yes +ssl=yes + +{% if interface is vyos_defined %} +{% for iface, iface_config in interface.items() %} +# ddclient configuration for interface "{{ iface }}" +{% if iface_config.use_web is vyos_defined %} +{% set web_skip = ", web-skip='" ~ iface_config.use_web.skip ~ "'" if iface_config.use_web.skip is vyos_defined else '' %} +use=web, web='{{ iface_config.use_web.url }}'{{ web_skip }} +{% else %} +{{ 'usev6=if' if iface_config.ipv6_enable is vyos_defined else 'use=if' }}, if={{ iface }} +{% endif %} + +{% if iface_config.rfc2136 is vyos_defined %} +{% for rfc2136, config in iface_config.rfc2136.items() %} +{% for dns_record in config.record if config.record is vyos_defined %} +# RFC2136 dynamic DNS configuration for {{ rfc2136 }}, {{ config.zone }}, {{ dns_record }} +server={{ config.server }} +protocol=nsupdate +password={{ config.key }} +ttl={{ config.ttl }} +zone={{ config.zone }} +{{ dns_record }} + +{% endfor %} +{% endfor %} +{% endif %} + +{% if iface_config.service is vyos_defined %} +{% for service, config in iface_config.service.items() %} +{% for dns_record in config.host_name %} +# DynDNS provider configuration for {{ service }}, {{ dns_record }} +protocol={{ config.protocol }}, +max-interval=28d, +login={{ config.login }}, +password='{{ config.password }}', +{% if config.server is vyos_defined %} +server={{ config.server }}, +{% endif %} +{% if config.zone is vyos_defined %} +zone={{ config.zone }}, +{% endif %} +{{ dns_record }} + +{% endfor %} +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} diff --git a/data/templates/dynamic-dns/ddclient.conf.tmpl b/data/templates/dynamic-dns/ddclient.conf.tmpl deleted file mode 100644 index ee55c9fa6..000000000 --- a/data/templates/dynamic-dns/ddclient.conf.tmpl +++ /dev/null @@ -1,51 +0,0 @@ -### Autogenerated by dynamic_dns.py ### -daemon=1m -syslog=yes -ssl=yes - -{% if interface is vyos_defined %} -{% for iface, iface_config in interface.items() %} -# ddclient configuration for interface "{{ iface }}" -{% if iface_config.use_web is vyos_defined %} -{% set web_skip = ", web-skip='" ~ iface_config.use_web.skip ~ "'" if iface_config.use_web.skip is vyos_defined else '' %} -use=web, web='{{ iface_config.use_web.url }}'{{ web_skip }} -{% else %} -{{ 'usev6=if' if iface_config.ipv6_enable is vyos_defined else 'use=if' }}, if={{ iface }} -{% endif %} - -{% if iface_config.rfc2136 is vyos_defined %} -{% for rfc2136, config in iface_config.rfc2136.items() %} -{% for dns_record in config.record if config.record is vyos_defined %} -# RFC2136 dynamic DNS configuration for {{ rfc2136 }}, {{ config.zone }}, {{ dns_record }} -server={{ config.server }} -protocol=nsupdate -password={{ config.key }} -ttl={{ config.ttl }} -zone={{ config.zone }} -{{ dns_record }} - -{% endfor %} -{% endfor %} -{% endif %} - -{% if iface_config.service is vyos_defined %} -{% for service, config in iface_config.service.items() %} -{% for dns_record in config.host_name %} -# DynDNS provider configuration for {{ service }}, {{ dns_record }} -protocol={{ config.protocol }}, -max-interval=28d, -login={{ config.login }}, -password='{{ config.password }}', -{% if config.server is vyos_defined %} -server={{ config.server }}, -{% endif %} -{% if config.zone is vyos_defined %} -zone={{ config.zone }}, -{% endif %} -{{ dns_record }} - -{% endfor %} -{% endfor %} -{% endif %} -{% endfor %} -{% endif %} diff --git a/data/templates/vyos-hostsd/hosts.j2 b/data/templates/vyos-hostsd/hosts.j2 new file mode 100644 index 000000000..5cad983b4 --- /dev/null +++ b/data/templates/vyos-hostsd/hosts.j2 @@ -0,0 +1,26 @@ +{# j2lint: disable=single-statement-per-line #} +### Autogenerated by VyOS ### +### Do not edit, your changes will get overwritten ### + +# Local host +127.0.0.1 localhost +127.0.1.1 {{ host_name }}{% if domain_name %}.{{ domain_name }} {{ host_name }}{% endif %} + +# The following lines are desirable for IPv6 capable hosts +::1 localhost ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters + +{% if hosts is vyos_defined %} +# From 'system static-host-mapping' and DHCP server +{% for tag, taghosts in hosts.items() %} +# {{ tag }} +{% for host, hostprops in taghosts.items() if hostprops.address is vyos_defined %} +{% for addr in hostprops.address %} +{{ "%-15s" | format(addr) }} {{ host }} {{ hostprops.aliases | join(' ') if hostprops.aliases is vyos_defined }} +{% endfor %} +{% endfor %} +{% endfor %} +{% endif %} diff --git a/data/templates/vyos-hostsd/hosts.tmpl b/data/templates/vyos-hostsd/hosts.tmpl deleted file mode 100644 index bc75d384e..000000000 --- a/data/templates/vyos-hostsd/hosts.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -### Autogenerated by VyOS ### -### Do not edit, your changes will get overwritten ### - -# Local host -127.0.0.1 localhost -127.0.1.1 {{ host_name }}{% if domain_name %}.{{ domain_name }} {{ host_name }}{% endif %} - -# The following lines are desirable for IPv6 capable hosts -::1 localhost ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters - -{% if hosts is vyos_defined %} -# From 'system static-host-mapping' and DHCP server -{% for tag, taghosts in hosts.items() %} -# {{ tag }} -{% for host, hostprops in taghosts.items() if hostprops.address is vyos_defined %} -{% for addr in hostprops.address %} -{{ "%-15s" | format(addr) }} {{ host }} {{ hostprops.aliases|join(' ') if hostprops.aliases is vyos_defined }} -{% endfor %} -{% endfor %} -{% endfor %} -{% endif %} diff --git a/data/templates/vyos-hostsd/resolv.conf.j2 b/data/templates/vyos-hostsd/resolv.conf.j2 new file mode 100644 index 000000000..5f651f1a1 --- /dev/null +++ b/data/templates/vyos-hostsd/resolv.conf.j2 @@ -0,0 +1,25 @@ +### Autogenerated by VyOS ### +### Do not edit, your changes will get overwritten ### + +{# the code below ensures the order of nameservers is determined first by #} +{# the order of tags, then by the order of nameservers within that tag #} + +{% for tag in name_server_tags_system %} +{% if tag in name_servers %} +# {{ tag }} +{% for ns in name_servers[tag] %} +nameserver {{ ns }} +{% endfor %} +{% endif %} +{% endfor %} + +{% if domain_name %} +domain {{ domain_name }} +{% endif %} + +{% for tag in name_server_tags_system %} +{% if tag in search_domains %} +# {{ tag }} +search {{ search_domains[tag] | join(' ') }} +{% endif %} +{% endfor %} diff --git a/data/templates/vyos-hostsd/resolv.conf.tmpl b/data/templates/vyos-hostsd/resolv.conf.tmpl deleted file mode 100644 index 58a5f9312..000000000 --- a/data/templates/vyos-hostsd/resolv.conf.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -### Autogenerated by VyOS ### -### Do not edit, your changes will get overwritten ### - -{# the code below ensures the order of nameservers is determined first by #} -{# the order of tags, then by the order of nameservers within that tag #} - -{% for tag in name_server_tags_system %} -{% if tag in name_servers %} -# {{ tag }} -{% for ns in name_servers[tag] %} -nameserver {{ ns }} -{% endfor %} -{% endif %} -{% endfor %} - -{% if domain_name %} -domain {{ domain_name }} -{% endif %} - -{% for tag in name_server_tags_system %} -{% if tag in search_domains %} -# {{ tag }} -search {{ search_domains[tag]|join(' ') }} -{% endif %} -{% endfor %} -- cgit v1.2.3