From 8e12a4388f5c2ee7a089ec2a320ff1d6db94db96 Mon Sep 17 00:00:00 2001 From: Daniel Akulenok Date: Fri, 19 Aug 2022 22:01:36 +0200 Subject: [PATCH] changes to indentation --- defaults/main.yml | 1 + templates/named.conf.controls.j2 | 2 +- templates/named.conf.dlz.j2 | 2 +- templates/named.conf.dnssec-policy.j2 | 4 ++-- templates/named.conf.dyndb.j2 | 2 +- templates/named.conf.functions.j2 | 6 +++--- templates/named.conf.generator.j2 | 2 +- templates/named.conf.http.j2 | 4 ++-- templates/named.conf.key.j2 | 2 +- templates/named.conf.logging.j2 | 4 ++-- templates/named.conf.options.j2 | 14 +++++++------- templates/named.conf.parental-agents.j2 | 2 +- templates/named.conf.server.j2 | 2 +- templates/named.conf.statistics-channels.j2 | 2 +- templates/named.conf.tls.j2 | 2 +- templates/named.conf.trust-anchors.j2 | 2 +- templates/named.conf.view.j2 | 2 +- templates/named.conf.zone.j2 | 4 ++-- 18 files changed, 30 insertions(+), 29 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3c46fd7..e914823 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,6 +11,7 @@ bind9_backup_dir: /data/backup/bind bind9_backup_config: true bind9_debug_config: false +bind9_config_indent: 4 bind9_group_config: [] bind9_leaf_config: [] diff --git a/templates/named.conf.controls.j2 b/templates/named.conf.controls.j2 index 90f4522..867c347 100644 --- a/templates/named.conf.controls.j2 +++ b/templates/named.conf.controls.j2 @@ -1,6 +1,6 @@ {% macro controls(controls) %} controls { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for control in controls %} {% if control.type == "inet" %} {{ ('inet ' + control.address) -}} diff --git a/templates/named.conf.dlz.j2 b/templates/named.conf.dlz.j2 index 368d260..f47e9b2 100644 --- a/templates/named.conf.dlz.j2 +++ b/templates/named.conf.dlz.j2 @@ -1,7 +1,7 @@ {% macro dlz(dlzs) %} {% for dlz in dlzs if dlzs is iterable %} dlz "{{ dlz.name }}" { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ ('database "' + simple_item_list(dlz.database) + '";') }} {{ functions.boolean_option('search', dlz.search) }} {% endfilter %} diff --git a/templates/named.conf.dnssec-policy.j2 b/templates/named.conf.dnssec-policy.j2 index 975d4a6..cd111f4 100644 --- a/templates/named.conf.dnssec-policy.j2 +++ b/templates/named.conf.dnssec-policy.j2 @@ -1,10 +1,10 @@ {% macro dnssec_policy(policies) %} {% for policy in policies if policies is iterable %} dnssec-policy "{{ policy.name }}" { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% if policy.keys is defined and policy.keys %} keys { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for dnskey in policy.keylist if policy.keylist is iterable %} {{ dnskey.role -}} {{ (' key-directory') if dnskey.key_directory is defined and dnskey.key_directory -}} diff --git a/templates/named.conf.dyndb.j2 b/templates/named.conf.dyndb.j2 index 287bc74..ee73c02 100644 --- a/templates/named.conf.dyndb.j2 +++ b/templates/named.conf.dyndb.j2 @@ -1,7 +1,7 @@ {% macro dyndb(dyndbs) %} {% for dyndb in dyndbs if dyndbs is iterable %} dyndb {{ dyndb.name }} "{{ dyndb.driver }}" { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ functions.simple_item_list(dyndb.parameters) -}} {% endfilter %}}; {% endfor %} diff --git a/templates/named.conf.functions.j2 b/templates/named.conf.functions.j2 index 1854d35..7b89025 100644 --- a/templates/named.conf.functions.j2 +++ b/templates/named.conf.functions.j2 @@ -1,11 +1,11 @@ -{% macro simple_item_list(item_list, indent=2) %} +{% macro simple_item_list(item_list, indent=bind9_config_indent) %} {# This macro is for use in simple address lists #} {% filter indent(indent, true) %} {{ item_list | join(';\n') }}; {% endfilter %} {% endmacro %} -{% macro list_address_port_key_tls(dict, indent=2) %} +{% macro list_address_port_key_tls(dict, indent=bind9_config_indent) %} {% filter indent(indent, true) %} {% for item in dict %} {% if item is not mapping %} @@ -35,7 +35,7 @@ {% endif %} {% endmacro %} -{% macro list_address_port_dscp(dict, indent=2) %} +{% macro list_address_port_dscp(dict, indent=bind9_config_indent) %} {# This macro is for use for statements with grammar like #} {# address port 00 dscp 00; address port 00 dscp 00; #} {# it is usually called by a parent macro #} diff --git a/templates/named.conf.generator.j2 b/templates/named.conf.generator.j2 index 509b16e..70e3d0e 100644 --- a/templates/named.conf.generator.j2 +++ b/templates/named.conf.generator.j2 @@ -3,7 +3,7 @@ {% if item.options is defined and item.options %} {% from 'named.conf.options.j2' import options with context %} options { -{% filter indent(2,true)%} +{% filter indent(bind9_config_indent,true)%} {{ options(item.options) -}} {% endfilter %} }; diff --git a/templates/named.conf.http.j2 b/templates/named.conf.http.j2 index e69e1ec..0eacc46 100644 --- a/templates/named.conf.http.j2 +++ b/templates/named.conf.http.j2 @@ -1,10 +1,10 @@ {% macro http(seq) %} {% for http in seq if seq is iterable %} http {{ http.name }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% if http.endpoints is defined and http.endpoints %} endpoints { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for endpoint in http.endpoints %} {{ '"' + endpoint + '";' }} {% endfor %} diff --git a/templates/named.conf.key.j2 b/templates/named.conf.key.j2 index 0350186..659aa38 100644 --- a/templates/named.conf.key.j2 +++ b/templates/named.conf.key.j2 @@ -1,7 +1,7 @@ {% macro keylist(keylists) %} {% for keyname in keylists if keylists is iterable %} key {{ keyname.name }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ ('algorithm ' + keyname.algorithm + ';\n') if keyname.algorithm is defined and keyname.algorithm -}} {{ ('secret "' + keyname.secret + '";\n') if keyname.secret is defined and keyname.secret -}} {% endfilter %}}; diff --git a/templates/named.conf.logging.j2 b/templates/named.conf.logging.j2 index f2b3094..f4935d4 100644 --- a/templates/named.conf.logging.j2 +++ b/templates/named.conf.logging.j2 @@ -1,13 +1,13 @@ {% macro logging(logging) %} logging { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for category in logging.categories if logging.categories is defined and logging.categories %} category {{ category.name }} { {{ functions.simple_item_list(category.channels) }}}; {% endfor %} {% for channel in logging.channels if logging.channels is defined and logging.channels %} channel {{ channel.name }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% if channel.file is defined and channel.file %} file "{{ channel.file.name }}" {{- (' versions ' + channel.file.versions | string) if channel.file.versions is defined and channel.file.versions -}} diff --git a/templates/named.conf.options.j2 b/templates/named.conf.options.j2 index 17d890b..48a3d93 100644 --- a/templates/named.conf.options.j2 +++ b/templates/named.conf.options.j2 @@ -2,7 +2,7 @@ {# Unicorn Options#} {% if option.rrset_order is defined and option.rrset_order %} rrset-order { -{% filter indent(4, true) %} +{% filter indent(bind9_config_indent*2, true) %} {% for rrset in option.rrset_order %} {{ ('class ' + rrset.class | string + ' ') if rrset.class is defined and rrset.class -}} {{ ('type ' + rrset.type | string + ' ') if rrset.type is defined and rrset.type -}} @@ -13,7 +13,7 @@ rrset-order { {% endif %} {% if option.response_policy is defined and option.response_policy %} response-policy { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for zone in option.response_policy.zones %} {{- ('zone ' + zone.zone | string) -}} {{- (' max-policy-ttl ' + zone.max_policy_ttl | string) if zone.max_policy_ttl is defined and zone.max_policy_ttl -}} @@ -47,7 +47,7 @@ response-padding { {% endif %} {% if option.rate_limit is defined and option.rate_limit %} rate-limit { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ ('all-per-second ' + option.rate_limit.all_per_second | string + ';\n') if option.rate_limit.all_per_second is defined and option.rate_limit.all_per_second -}} {{ ('errors-per-second ' + option.rate_limit.errors_per_second | string + ';\n') if option.rate_limit.errors_per_second is defined and option.rate_limit.errors_per_second -}} {{ ('responses-per-second ' + option.rate_limit.responses_per_second | string + ';\n') if option.rate_limit.responses_per_second is defined and option.rate_limit.responses_per_second -}} @@ -104,7 +104,7 @@ listen-on dual-stack-servers {{ (' port ' + option.dual_stack_servers.port | string) if option.dual_stack_servers.port is defined and option.dual_stack_servers }} { {% for host in option.dual_stack_servers.addresses %} -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ host.address | ansible.utils.ipaddr | ternary(host.address, '"' + host.address + '"') }} {{- (' port ' + host.port | string) if host.port is defined and host.port -}} {{- (' dscp ' + host.dscp | string) if host.dscp is defined and host.dscp -}}; @@ -120,7 +120,7 @@ dnstap-output {{ option.dnstap_output.output_type -}} {% endif %} {% if option.dnstap is defined and option.dnstap %} dnstap { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for dnstap in option.dnstap %} {{ dnstap.type }}{{ ' ' + dnstap.log if dnstap.log is defined and dnstap.log }}; {% endfor %} @@ -129,7 +129,7 @@ dnstap { {% if option.dns64 is defined and option.dns64 %} {% for dns64 in option.dns64 if option.dns64 is sequence %} dns64 {{ dns64.netprefix }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ ('break-dnssec ' + dns64.break_dnssec | functions.named_boolean + ';\n') if dns64.break_dnssec is defined and dns64.break_dnssec is boolean -}} {{ ('recursive-only ' + dns64.recursive_only | functions.named_boolean + ';\n') if dns64.recursive_only is defined and dns64.recursive_only is boolean -}} {{ ('suffix ' + dns64.suffix + ';\n') if dns64.suffix is defined and dns64.suffix -}} @@ -164,7 +164,7 @@ check-names {{ policy.type }} {{ policy.action }}; catalog-zones { {% for catalog_zone in option.catalog_zones %} zone {{ catalog_zone.zone }} -{% filter indent(6, true) %} +{% filter indent(bind9_config_indent*3, true) %} {% if catalog_zone.default_primaries is defined and catalog_zone.default_primaries %} default-primaries {{- (' port ' + catalog_zone.default_primaries.port | string) if catalog_zone.default_primaries.port is defined and catalog_zone.default_primaries.port -}} diff --git a/templates/named.conf.parental-agents.j2 b/templates/named.conf.parental-agents.j2 index 412c1f8..95b0a4b 100644 --- a/templates/named.conf.parental-agents.j2 +++ b/templates/named.conf.parental-agents.j2 @@ -3,7 +3,7 @@ parental-agents {{ agent.name -}} {{ (' port ' + agent.port | string) if agent.port is defined and agent.port -}} {{ (' dscp ' + agent.dscp | string) if agent.dscp is defined and agent.dscp }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ functions.list_address_port_key_tls(agent.addresses) -}} {% endfilter %}}; {% endfor %} diff --git a/templates/named.conf.server.j2 b/templates/named.conf.server.j2 index 663d57f..c5d24f8 100644 --- a/templates/named.conf.server.j2 +++ b/templates/named.conf.server.j2 @@ -1,7 +1,7 @@ {% macro server(servers) %} {% for server in servers if servers is iterable %} server {{ server.prefix }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% if server.transfer_source is defined and server.transfer_source is mapping %} transfer-source {{ server.transfer_source.address -}} {{- (' port ' + server.transfer_source.port | string) if server.transfer_source.port is defined and server.transfer_source.port -}} diff --git a/templates/named.conf.statistics-channels.j2 b/templates/named.conf.statistics-channels.j2 index 2a87d55..088c044 100644 --- a/templates/named.conf.statistics-channels.j2 +++ b/templates/named.conf.statistics-channels.j2 @@ -1,6 +1,6 @@ {% macro statistics_channels(statistics_channels) %} statistics-channels { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for channel in statistics_channels if statistics_channels is iterable %} inet {{ channel.address | string }} {{- (' port ' + channel.port | string) if channel.port is defined and channel.port -}} diff --git a/templates/named.conf.tls.j2 b/templates/named.conf.tls.j2 index bcbc051..37b9aff 100644 --- a/templates/named.conf.tls.j2 +++ b/templates/named.conf.tls.j2 @@ -1,7 +1,7 @@ {% macro tls(tlss) %} {% for tls in tlss if tlss is iterable %} tls {{ tls.name }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ ('cert-file "' + tls.cert_file + '";\n') if tls.cert_file is defined and tls.cert_file -}} {{ ('key-file "' + tls.key_file + '";\n') if tls.key_file is defined and tls.key_file -}} {{ ('dhparam-file "' + tls.dhparam_file + '";\n') if tls.dhparam_file is defined and tls.dhparam_file -}} diff --git a/templates/named.conf.trust-anchors.j2 b/templates/named.conf.trust-anchors.j2 index bc47ee8..033fb57 100644 --- a/templates/named.conf.trust-anchors.j2 +++ b/templates/named.conf.trust-anchors.j2 @@ -1,6 +1,6 @@ {% macro trust_anchors(trust_anchors) %} trust-anchors { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for anchor in trust_anchors if trust_anchors is iterable %} {{ (anchor.name | string) -}} {{ (' ' + anchor.type) -}} diff --git a/templates/named.conf.view.j2 b/templates/named.conf.view.j2 index 8f005cf..8191024 100644 --- a/templates/named.conf.view.j2 +++ b/templates/named.conf.view.j2 @@ -1,7 +1,7 @@ {% macro view(views) %} {% for view in views if views is iterable %} view {{ view.name }} { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {{ ('match-recursive-only ' + functions.named_boolean(view.match_recursive_only) + ';\n') if view.match_recursive_only is defined -}} {{ ('match-clients {\n' + functions.simple_item_list(view.match_clients) + '};\n') if view.match_clients is defined and view.match_clients -}} {{ ('match-destinations {\n' + functions.simple_item_list(view.match_destinations) + '};\n') if view.match_destinations is defined and view.match_destinations -}} diff --git a/templates/named.conf.zone.j2 b/templates/named.conf.zone.j2 index b2ad534..e313c31 100644 --- a/templates/named.conf.zone.j2 +++ b/templates/named.conf.zone.j2 @@ -2,7 +2,7 @@ {% macro zones(zones) -%} {% for zone in zones %} zone "{{ zone.name }}" { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} # Zone {{ zone.name }} type {{ zone.type }} {# Most critical/defining statements first #} {{ ('type ' + zone.type | string+';\n') if zone.type is defined and zone.type -}} @@ -24,7 +24,7 @@ zone "{{ zone.name }}" { update-policy local; {% else %} update-policy { -{% filter indent(2, true) %} +{% filter indent(bind9_config_indent, true) %} {% for policy in zone.update_policy %} {{ policy.permission -}} {{ ' ' + policy.identity -}}