18 Commits

Author SHA1 Message Date
Daniel Akulenok
f93f2c5597 Update forwarders for 9.20 2026-01-23 12:24:06 +01:00
Daniel Akulenok
90f4f1d9db Merge branch 'main' of ssh://git.valid.dk:2222/daniel/ansible-bind9-role 2026-01-23 10:34:22 +01:00
Daniel Akulenok
df56bcd23d Start with some molecule stuff 2026-01-23 00:30:22 +01:00
781bd90580 revert 26c6e7844d
revert feat: Add remote-servers support for BIND 9.20
2026-01-22 22:36:55 +00:00
50d570a59e revert b5a9e97712
revert refactor: Update templates to use dynamic ordering and add deprecation warnings
2026-01-22 22:36:50 +00:00
276d7519ea revert 192747e438
revert refactor: Rename leaf config to site config

feat: Add argument specs and atomic validation
2026-01-22 22:36:43 +00:00
d870c5e0e7 revert 986b33df21
revert fix: explicit boolean checks for Ansible 12 compatibility
2026-01-22 22:36:25 +00:00
d1f384abab revert 2502389156
revert Merge pull request 'feature/bind9-20-support' (#1) from feature/bind9-20-support into main

Reviewed-on: https://gitea/daniel/ansible-bind9-role/pulls/1
2026-01-22 22:34:13 +00:00
0eacd56934 revert 0a8ea77c63
revert Merge pull request 'feature/role-improvements' (#2) from feature/role-improvements into main

Reviewed-on: https://gitea/daniel/ansible-bind9-role/pulls/2
2026-01-22 22:33:44 +00:00
0a8ea77c63 Merge pull request 'feature/role-improvements' (#2) from feature/role-improvements into main
Reviewed-on: https://gitea/daniel/ansible-bind9-role/pulls/2
2025-12-07 20:22:40 +00:00
2502389156 Merge pull request 'feature/bind9-20-support' (#1) from feature/bind9-20-support into main
Reviewed-on: https://gitea/daniel/ansible-bind9-role/pulls/1
2025-12-07 19:37:05 +00:00
Daniel Akulenok
986b33df21 fix: explicit boolean checks for Ansible 12 compatibility 2025-12-07 20:28:26 +01:00
Daniel Akulenok
192747e438 refactor: Rename leaf config to site config
feat: Add argument specs and atomic validation
2025-12-07 20:24:22 +01:00
Daniel Akulenok
b5a9e97712 refactor: Update templates to use dynamic ordering and add deprecation warnings 2025-12-07 20:15:54 +01:00
Daniel Akulenok
26c6e7844d feat: Add remote-servers support for BIND 9.20 2025-12-07 20:15:41 +01:00
Daniel Akulenok
cfde49d95a Spacing 2024-05-15 12:21:17 +02:00
Daniel Akulenok
e538644617 Spacing 2024-05-15 11:04:46 +02:00
Daniel Akulenok
f535f1af20 Remove surplus comment 2024-05-14 14:40:41 +02:00
26 changed files with 142 additions and 28 deletions

View File

@@ -18,7 +18,7 @@
- "{{ bind9_libdir }}" - "{{ bind9_libdir }}"
dest: "{{ dest: "{{
bind9_backup_dir + '/bind9-config-' + bind9_backup_dir + '/bind9-config-' +
ansible_date_time.iso8601_basic_short + '.tar.gz' }}" ansible_facts.date_time.iso8601_basic_short + '.tar.gz' }}"
owner: root owner: root
group: root group: root
mode: 0640 mode: 0640

View File

@@ -0,0 +1,7 @@
---
collections:
- name: ansible.utils
- name: ansible.posix
- name: community.crypto
- name: community.general

View File

@@ -1,5 +1,31 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
roles: vars:
- keepit.bind9 bind9_group_config:
- name: named.conf.options
options:
directory: "{{ bind9_working_directory }}"
forwarders:
port: 853
tls: common-upstream
addresses:
- address: 192.0.2.10
port: 5353
tls: leaf-a
- address:
- 2001:db8::10
- 198.51.100.10
tls: dual-stack
- 203.0.113.10
tls:
- name: common-upstream
remote_hostname: upstream.example
- name: leaf-a
remote_hostname: leaf-a.example
- name: dual-stack
remote_hostname: dual-stack.example
tasks:
- name: Include bind9 role
ansible.builtin.include_role:
name: ../../../ansible-bind9-role

View File

@@ -1,22 +1,18 @@
--- ---
dependency:
name: galaxy
driver: driver:
name: podman name: podman
platforms: platforms:
- name: ubuntu-jammy - name: debian-trixie
image: ubuntu:jammy image: docker.io/jrei/systemd-debian:13
- name: ubuntu-focal command: /lib/systemd/systemd
image: ubuntu:focal privileged: true
- name: debian-bullseye volumes:
image: debian:bullseye - /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
provisioner: provisioner:
name: ansible name: ansible
lint: config_options:
name: ansible-lint defaults:
ALLOW_BROKEN_CONDITIONALS: true
verifier: verifier:
name: ansible name: ansible
lint: |
set -e
ansible-lint .
yamllint .

View File

@@ -0,0 +1,6 @@
---
- hosts: all
tasks:
- name: Update apt
ansible.builtin.apt:
update_cache: true

View File

@@ -0,0 +1,21 @@
---
- name: Verify forwarders configuration
hosts: all
gather_facts: false
tasks:
- name: Read named.conf.options
ansible.builtin.slurp:
src: /etc/bind/named.conf.options
register: forwarders_file
- name: Assert forwarders render with port and tls
ansible.builtin.assert:
that:
- forwarders_content is search('forwarders port 853 tls common-upstream \{')
- forwarders_content is search('192.0.2.10 port 5353 tls leaf-a;')
- forwarders_content is search('2001:db8::10 tls dual-stack;')
- forwarders_content is search('198.51.100.10 tls dual-stack;')
- forwarders_content is search('203.0.113.10;')
fail_msg: "Forwarders block missing expected port/tls entries"
vars:
forwarders_content: "{{ forwarders_file.content | b64decode }}"

View File

@@ -1,5 +1,6 @@
{# ACL Macro. Very easy statement. It's just a list of address match elements. #} {# ACL Macro. Very easy statement. It's just a list of address match elements. #}
{% for acl in item.acl %} {% for acl in item.acl %}
acl {{ acl.name }} { acl {{ acl.name }} {
{{ functions.simple_item_list(acl.addresses) -}} {{ functions.simple_item_list(acl.addresses) -}}
}; };

View File

@@ -1,3 +1,4 @@
controls { controls {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% for control in item.controls %} {% for control in item.controls %}

View File

@@ -1,4 +1,5 @@
{% for dlz in item.dlz if item.dlz is iterable %} {% for dlz in item.dlz if item.dlz is iterable %}
dlz "{{ dlz.name }}" { dlz "{{ dlz.name }}" {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{{ ('database "' + simple_item_list(dlz.database) + '";') }} {{ ('database "' + simple_item_list(dlz.database) + '";') }}

View File

@@ -1,4 +1,5 @@
{% for policy in item.dnssec_policy if item.dnssec_policy is iterable %} {% for policy in item.dnssec_policy if item.dnssec_policy is iterable %}
dnssec-policy "{{ policy.name }}" { dnssec-policy "{{ policy.name }}" {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% if policy.keys is defined and policy.keys %} {% if policy.keys is defined and policy.keys %}

View File

@@ -1,4 +1,5 @@
{% for dyndb in item.dyndb if item.dyndb is iterable %} {% for dyndb in item.dyndb if item.dyndb is iterable %}
dyndb {{ dyndb.name }} "{{ dyndb.driver }}" { dyndb {{ dyndb.name }} "{{ dyndb.driver }}" {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{{ functions.simple_item_list(dyndb.parameters) -}} {{ functions.simple_item_list(dyndb.parameters) -}}

View File

@@ -42,6 +42,46 @@
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro list_address_port_tls(dict, indent=bind9_config_indent) %}
{# This macro is for use for statements with grammar like #}
{# address port 00 tls string; address port 00 tls string; #}
{# it is usually called by a parent macro #}
{% filter indent(indent, true) %}
{% for item in dict %}
{% if item is not mapping %}
{{ item }};
{% elif item.address is string %}
{{ item.address -}}
{{- (' port ' + item.port | string) if item.port is defined and item.port -}}
{{- (' tls ' + item.tls | string) if item.tls is defined and item.tls -}};
{% elif item.address is sequence %}
{% for address in item.address %}
{{ address -}}
{{- (' port ' + item.port | string) if item.port is defined and item.port -}}
{{- (' tls ' + item.tls | string) if item.tls is defined and item.tls -}};
{% endfor %}
{% endif %}
{% endfor %}
{% endfilter %}
{% endmacro %}
{% macro parent_address_port_tls(name, dict) %}
{# This macro is for statements with grammar like #}
{# statement port 00 tls string { address port 00 tls string; address port 00 tls string; } #}
{# the list inside the statement is handled by list_address_port_tls #}
{% if dict is not mapping and dict is iterable %}
{{ name }} {
{{ list_address_port_tls(dict) -}}
};
{% else %}
{{ name }}
{{- (' port ' + dict.port | string) if dict.port is defined and dict.port -}}
{{- (' tls ' + dict.tls | string) if dict.tls is defined and dict.tls }} {
{{ list_address_port_tls(dict.addresses) -}}
};
{% endif %}
{% endmacro %}
{% macro list_address_port_dscp(dict, indent=bind9_config_indent) %} {% macro list_address_port_dscp(dict, indent=bind9_config_indent) %}
{# This macro is for use for statements with grammar like #} {# This macro is for use for statements with grammar like #}
{# address port 00 dscp 00; address port 00 dscp 00; #} {# address port 00 dscp 00; address port 00 dscp 00; #}
@@ -65,12 +105,14 @@
{# the list inside the statement is handled by list_address_port #} {# the list inside the statement is handled by list_address_port #}
{% if dict is not mapping and dict is iterable %} {% if dict is not mapping and dict is iterable %}
{{ name }} { {{ name }} {
{{ list_address_port_dscp(dict) }}}; {{ list_address_port_dscp(dict) }}
};
{% else %} {% else %}
{{ name }} {{ name }}
{{- (' port ' + dict.port | string) if dict.port is defined and dict.port -}} {{- (' port ' + dict.port | string) if dict.port is defined and dict.port -}}
{{- (' dscp ' + dict.dscp | string) if dict.dscp is defined and dict.dscp }} { {{- (' dscp ' + dict.dscp | string) if dict.dscp is defined and dict.dscp }} {
{{ list_address_port_dscp(dict.addresses) }}}; {{ list_address_port_dscp(dict.addresses) }}
};
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}

View File

@@ -1,12 +1,7 @@
{% import 'named.conf.functions.j2' as functions with context %} {% import 'named.conf.functions.j2' as functions with context %}
{{ ansible_managed | comment }} {{ ansible_managed | comment }}
{% if item.options is defined and item.options %} {% if item.options is defined and item.options %}
options {
{% filter indent(bind9_config_indent,true)%}
{% include 'named.conf.options.j2' %} {% include 'named.conf.options.j2' %}
{% endfilter %}
};
{% endif %} {% endif %}
{% if item.acl is defined and item.acl %} {% if item.acl is defined and item.acl %}
{% include 'named.conf.acl.j2' %} {% include 'named.conf.acl.j2' %}

View File

@@ -1,4 +1,5 @@
{% for http in item.http if item.http is iterable %} {% for http in item.http if item.http is iterable %}
http {{ http.name }} { http {{ http.name }} {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% if http.endpoints is defined and http.endpoints %} {% if http.endpoints is defined and http.endpoints %}

View File

@@ -1,3 +1,4 @@
{% for file in item.include %} {% for file in item.include %}
include "{{ file }}"; include "{{ file }}";
{% endfor %} {% endfor %}

View File

@@ -1,4 +1,5 @@
{% for keyname in item.keylist if item.keylist is iterable %} {% for keyname in item.keylist if item.keylist is iterable %}
key {{ keyname.name }} { key {{ keyname.name }} {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{{ ('algorithm ' + keyname.algorithm + ';\n') if keyname.algorithm is defined and keyname.algorithm -}} {{ ('algorithm ' + keyname.algorithm + ';\n') if keyname.algorithm is defined and keyname.algorithm -}}

View File

@@ -1,3 +1,4 @@
logging { logging {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% for category in item.logging.categories if item.logging.categories is defined and item.logging.categories %} {% for category in item.logging.categories if item.logging.categories is defined and item.logging.categories %}

View File

@@ -1,3 +1,6 @@
options {
{% filter indent(bind9_config_indent,true)%}
{# Unicorn Options#} {# Unicorn Options#}
{% if item.options.rrset_order is defined and item.options.rrset_order %} {% if item.options.rrset_order is defined and item.options.rrset_order %}
rrset-order { rrset-order {
@@ -98,7 +101,7 @@ listen-on
{{ functions.simple_item_list(item.options.listen_on.addresses) }}}; {{ functions.simple_item_list(item.options.listen_on.addresses) }}};
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{{ functions.parent_address_port_dscp("forwarders", item.options.forwarders) if item.options.forwarders is defined and item.options.forwarders -}} {{ functions.parent_address_port_tls('forwarders', item.options.forwarders) if item.options.forwarders is defined and item.options.forwarders -}}
{% if item.options.dual_stack_servers is defined and item.options.dual_stack_servers %} {% if item.options.dual_stack_servers is defined and item.options.dual_stack_servers %}
dual-stack-servers dual-stack-servers
{{ (' port ' + item.options.dual_stack_servers.port | string) if item.options.dual_stack_servers.port is defined and item.options.dual_stack_servers }} { {{ (' port ' + item.options.dual_stack_servers.port | string) if item.options.dual_stack_servers.port is defined and item.options.dual_stack_servers }} {
@@ -460,3 +463,6 @@ tkey-dhkey "{{ item.options.tkey_dhkey.key_name }}" {{ item.options.tkey_dhkey.k
{{ (functions.boolean_option('use-alt-transfer-source', item.options.use_alt_transfer_source) + '\n') if item.options.use_alt_transfer_source is defined -}} {{ (functions.boolean_option('use-alt-transfer-source', item.options.use_alt_transfer_source) + '\n') if item.options.use_alt_transfer_source is defined -}}
{{ (functions.boolean_option('zero-no-soa-ttl', item.options.zero_no_soa_ttl) + '\n') if item.options.zero_no_soa_ttl is defined -}} {{ (functions.boolean_option('zero-no-soa-ttl', item.options.zero_no_soa_ttl) + '\n') if item.options.zero_no_soa_ttl is defined -}}
{{ (functions.boolean_option('zero-no-soa-ttl-cache', item.options.zero_no_soa_ttl_cache) + '\n') if item.options.zero_no_soa_ttl_cache is defined -}} {{ (functions.boolean_option('zero-no-soa-ttl-cache', item.options.zero_no_soa_ttl_cache) + '\n') if item.options.zero_no_soa_ttl_cache is defined -}}
{% endfilter %}
};

View File

@@ -1,4 +1,5 @@
{% for agent in item.parental_agents if item.parental_agents is iterable %} {% for agent in item.parental_agents if item.parental_agents is iterable %}
parental-agents {{ agent.name -}} parental-agents {{ agent.name -}}
{{ (' port ' + agent.port | string) if agent.port is defined and agent.port -}} {{ (' port ' + agent.port | string) if agent.port is defined and agent.port -}}
{{ (' dscp ' + agent.dscp | string) if agent.dscp is defined and agent.dscp }} { {{ (' dscp ' + agent.dscp | string) if agent.dscp is defined and agent.dscp }} {

View File

@@ -1,4 +1,5 @@
{% for primary in item.primaries if item.primaries is iterable %} {% for primary in item.primaries if item.primaries is iterable %}
primaries {{ primary.name -}} primaries {{ primary.name -}}
{{ (' port ' + primary.port | string) if primary.port is defined and primary.port -}} {{ (' port ' + primary.port | string) if primary.port is defined and primary.port -}}
{{ (' dscp ' + primary.dscp | string) if primary.dscp is defined and primary.dscp }} { {{ (' dscp ' + primary.dscp | string) if primary.dscp is defined and primary.dscp }} {

View File

@@ -1,4 +1,5 @@
{% for server in item.server if item.server is iterable %} {% for server in item.server if item.server is iterable %}
server {{ server.prefix }} { server {{ server.prefix }} {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% if server.transfer_source is defined and server.transfer_source is mapping %} {% if server.transfer_source is defined and server.transfer_source is mapping %}

View File

@@ -1,3 +1,4 @@
statistics-channels { statistics-channels {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% for channel in item.statistics_channels if item.statistics_channels is iterable %} {% for channel in item.statistics_channels if item.statistics_channels is iterable %}

View File

@@ -1,4 +1,5 @@
{% for tls in item.tls if item.tls is iterable %} {% for tls in item.tls if item.tls is iterable %}
tls {{ tls.name }} { tls {{ tls.name }} {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{{ ('cert-file "' + tls.cert_file + '";\n') if tls.cert_file is defined and tls.cert_file -}} {{ ('cert-file "' + tls.cert_file + '";\n') if tls.cert_file is defined and tls.cert_file -}}

View File

@@ -1,3 +1,4 @@
trust-anchors { trust-anchors {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
{% for anchor in item.trust_anchors if item.trust_anchors is iterable %} {% for anchor in item.trust_anchors if item.trust_anchors is iterable %}

View File

@@ -1,4 +1,5 @@
{% for view in item.view if item.view is iterable %} {% for view in item.view if item.view is iterable %}
view {{ view.name }} { view {{ view.name }} {
{% filter indent(bind9_config_indent, 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-recursive-only ' + functions.named_boolean(view.match_recursive_only) + ';\n') if view.match_recursive_only is defined -}}

View File

@@ -1,5 +1,5 @@
# Zones Macro
{% for zone in item.zones %} {% for zone in item.zones %}
zone "{{ zone.name }}" { zone "{{ zone.name }}" {
{% filter indent(bind9_config_indent, true) %} {% filter indent(bind9_config_indent, true) %}
# Zone {{ zone.name }} type {{ zone.type }} # Zone {{ zone.name }} type {{ zone.type }}
@@ -47,7 +47,7 @@ server-names {
server-addresses { server-addresses {
{{ functions.simple_item_list(zone.server_addresses) }}}; {{ functions.simple_item_list(zone.server_addresses) }}};
{% endif %} {% endif %}
{{ functions.parent_address_port_dscp('forwarders', zone.forwarders) if zone.forwarders is defined and zone.forwarders -}} {{ functions.parent_address_port_tls('forwarders', zone.forwarders) if zone.forwarders is defined and zone.forwarders -}}
{% if zone.allow_transfer is defined and zone.allow_transfer is not string %} {% if zone.allow_transfer is defined and zone.allow_transfer is not string %}
allow-transfer allow-transfer
{{- (' port ' + zone.allow_transfer.port | string) if zone.allow_transfer.port is defined and zone.allow_transfer.port -}} {{- (' port ' + zone.allow_transfer.port | string) if zone.allow_transfer.port is defined and zone.allow_transfer.port -}}
@@ -156,5 +156,4 @@ parental-source-v6 {{ zone.parental_source_v6.address -}}
{{ ('in-view ' + zone.in_view | string+';\n') if zone.in_view is defined and zone.in_view -}} {{ ('in-view ' + zone.in_view | string+';\n') if zone.in_view is defined and zone.in_view -}}
{% endfilter %} {% endfilter %}
}; };
{% endfor %} {% endfor %}