Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 957efdf7c7 | |||
| cd3a35e7a9 | |||
| 77212eef9b | |||
| 79ac474a85 | |||
| abd150f581 | |||
| cb20db00af | |||
| 07f84b7c96 | |||
| a4f06d3daf | |||
| 282e7601b4 | |||
| f15d33b619 | |||
| a298665e93 | |||
| 528caeddeb |
@@ -54,8 +54,8 @@ jobs:
|
||||
run: |
|
||||
pip install --no-cache-dir \
|
||||
ansible \
|
||||
molecule[podman] \
|
||||
podman-compose \
|
||||
molecule \
|
||||
molecule-podman \
|
||||
pyyaml \
|
||||
jinja2
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
name: molecule-role-testing
|
||||
description: Run Molecule scenarios to test the bind9 role using the repository's Molecule configuration.
|
||||
---
|
||||
|
||||
Use this skill when asked to test or validate the role with Molecule.
|
||||
|
||||
## Scope
|
||||
- Repository root: /home/alive/Code/ansible-bind9-role
|
||||
- Scenarios: molecule/default and molecule/bind9-20
|
||||
- Driver: podman
|
||||
|
||||
## Prerequisites
|
||||
1. Ensure Podman is available and the current user can run it.
|
||||
2. Ensure Molecule and Ansible are installed in the active Python environment.
|
||||
|
||||
## Default scenario (BIND 9.18 LTS)
|
||||
1. From the repository root, run:
|
||||
- molecule test
|
||||
2. If a faster check is requested, run:
|
||||
- molecule converge
|
||||
|
||||
## BIND 9.20+ scenario
|
||||
1. From the repository root, run:
|
||||
- molecule test -s bind9-20
|
||||
2. If a faster check is requested, run:
|
||||
- molecule converge -s bind9-20
|
||||
|
||||
## Notes
|
||||
- The scenarios use systemd-enabled containers and require privileged Podman.
|
||||
- If a scenario fails, capture the error summary and relevant logs before making changes.
|
||||
@@ -0,0 +1,233 @@
|
||||
# BIND9 9.20 Support Implementation Guide
|
||||
|
||||
## Overview
|
||||
|
||||
This document describes the ansible-bind9-role strategy for BIND9 9.20+ support through a dedicated version branch.
|
||||
|
||||
The current implementation uses branch-level compatibility boundaries instead of runtime version detection. The main branch targets BIND9 9.18.x LTS, while the 9.20 branch targets BIND9 9.20+ feature releases.
|
||||
|
||||
## Architecture
|
||||
|
||||
### Branch-Based Support Strategy
|
||||
|
||||
The role uses branch-only support boundaries:
|
||||
|
||||
1. `main` branch: BIND9 9.18.x LTS support for production-stable deployments.
|
||||
2. `9.20` branch: BIND9 9.20+ feature-release support with version-specific templates, grammar data, tests, and documentation.
|
||||
|
||||
The role does not currently detect BIND9 versions at runtime and does not use runtime version conditionals in templates. Each branch is expected to be tested against the BIND9 series it supports.
|
||||
|
||||
This approach is preferred because:
|
||||
|
||||
- compatibility boundaries are clear for users and maintainers;
|
||||
- templates avoid cross-version conditional complexity;
|
||||
- each branch can evolve with the grammar and package behavior of its target BIND9 series;
|
||||
- generated configuration does not silently change based on the installed package version.
|
||||
|
||||
### Branch Structure
|
||||
|
||||
```
|
||||
main # BIND9 9.18.x LTS support
|
||||
│
|
||||
└─ 9.20 # BIND9 9.20+ feature-release support
|
||||
└─ feature/* # Short-lived feature branches targeting 9.20
|
||||
```
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### 1. Task Flow
|
||||
|
||||
1. Install the configured BIND9 packages from `bind9_packages`.
|
||||
2. Ensure backup and logging directories exist when enabled or configured.
|
||||
3. Render configured BIND9 files through `named.conf.generator.j2`.
|
||||
4. Validate the generated configuration with `named-checkconf -z`.
|
||||
5. Restore backed-up configuration files if validation fails.
|
||||
6. Start and enable the `named` service.
|
||||
|
||||
There is no runtime `bind9_version` fact in this flow.
|
||||
|
||||
### 2. Meta/Argument Specs Updates
|
||||
|
||||
The `meta/argument_specs.yml` file documents the public role inputs for the current branch. It must not document runtime-only variables that the role does not set or consume.
|
||||
|
||||
### 3. Molecule Testing
|
||||
|
||||
Two molecule scenarios are now available:
|
||||
|
||||
#### Default Scenario (BIND9 9.18.x)
|
||||
- **Location**: `molecule/default/`
|
||||
- **Platform**: Debian 13 (Trixie) with BIND9 9.18.x
|
||||
- **Purpose**: Validate production-stable configurations
|
||||
|
||||
#### BIND9 9.20 Scenario
|
||||
- **Location**: `molecule/bind9-20/`
|
||||
- **Platform**: Ubuntu 24.04 LTS with BIND9 9.20+
|
||||
- **Purpose**: Validate newer configurations and breaking changes
|
||||
- **Tests**: Forward zones, TLS, DNSTAP, modern DNSSEC
|
||||
|
||||
### 4. Template Version Compatibility
|
||||
|
||||
Templates in each version branch should be audited for the BIND9 series targeted by that branch. The primary template files include:
|
||||
|
||||
- `named.conf.options.j2` - Global options block
|
||||
- `named.conf.zone.j2` - Zone definitions
|
||||
- `named.conf.primaries.j2` - Primary/secondary definitions
|
||||
- `named.conf.tls.j2` - TLS configurations (9.20 focus)
|
||||
- `named.conf.dnssec-policy.j2` - DNSSEC policies
|
||||
|
||||
### 5. Deprecated Options Handling
|
||||
|
||||
BIND9 9.20 removes 44 options from 9.18. The 9.20 branch should handle this through:
|
||||
|
||||
1. **Documentation**: Each deprecated option is documented in BIND9_MIGRATION_GUIDE.md
|
||||
2. **Branch-specific templates**: Templates on the 9.20 branch omit removed options
|
||||
3. **Migration Path**: BIND9_MIGRATION_GUIDE.md provides alternatives for each removed option
|
||||
|
||||
## Critical BIND9 9.20 Changes
|
||||
|
||||
### Automatically Enabled Options
|
||||
|
||||
These cannot and should not be configured (always enabled in 9.20):
|
||||
|
||||
- `glue-cache` - Glue records are always cached
|
||||
- `keep-response-order` - Response ordering is always enabled
|
||||
- `reuse` - TCP socket reuse is always enabled
|
||||
|
||||
### Removed Global Options
|
||||
|
||||
Key removed options requiring configuration changes:
|
||||
|
||||
| 9.18 Option | 9.20 Replacement |
|
||||
|---|---|
|
||||
| `alt-transfer-source` | Use TLS in `primaries` statement |
|
||||
| `alt-transfer-source-v6` | Use TLS in `primaries` statement |
|
||||
| `auto-dnssec` | Automatic (DNSSEC always managed) |
|
||||
| `dsc` | Use TLS configuration instead |
|
||||
| `gssapi-credential` | Use TSIG + TLS instead |
|
||||
| `heartbeat-interval` | Zone transfer monitoring improved |
|
||||
| `lock-file` | OS-level locking used |
|
||||
| `max-zone-ttl` | Use per-zone option instead |
|
||||
| `parental-agents` | Use enhanced `primaries` statement |
|
||||
| `parental-registration-delay` | Zone monitoring improved |
|
||||
| `root-delegation-only` | Zone constraints |
|
||||
| `suppress-initial-notify` | NOTIFY behavior changed |
|
||||
| `tkeydhkey` | Use modern TLS/DNSSEC |
|
||||
| `tkeygsapi-credential` | Use TSIG + TLS |
|
||||
|
||||
### New 9.20 Features
|
||||
|
||||
- **Native TLS/DoT Support**: Zone transfers over TLS
|
||||
- **Automatic DNSSEC Management**: DNSSEC is handled automatically
|
||||
- **Enhanced HTTP/HTTPS Server**: Built-in HTTP API
|
||||
- **Better Resolver Behavior**: Improved retry and fallback logic
|
||||
- **Query Monitoring**: Advanced query tracking and statistics
|
||||
|
||||
## Configuration Changes for 9.20
|
||||
|
||||
### Before (BIND9 9.18.x)
|
||||
|
||||
```yaml
|
||||
bind9_default_config:
|
||||
- name: named.conf.options
|
||||
options:
|
||||
alt_transfer_source: 10.0.1.1
|
||||
glue_cache: yes
|
||||
parental_agents:
|
||||
- 192.0.2.1
|
||||
- 192.0.2.2
|
||||
```
|
||||
|
||||
### After (BIND9 9.20+)
|
||||
|
||||
```yaml
|
||||
bind9_default_config:
|
||||
- name: named.conf.options
|
||||
options:
|
||||
# Removed: alt_transfer_source, glue_cache, parental_agents
|
||||
# Instead use TLS and enhanced primaries statement
|
||||
- name: named.conf.zone
|
||||
zones:
|
||||
- name: example.com
|
||||
type: secondary
|
||||
primaries:
|
||||
- address: 192.0.2.1
|
||||
tls: zone-transfer-tls # New 9.20 approach
|
||||
- address: 192.0.2.2
|
||||
tls: zone-transfer-tls
|
||||
```
|
||||
|
||||
## Testing the Implementation
|
||||
|
||||
### Running Molecule Tests
|
||||
|
||||
```bash
|
||||
# Test both scenarios
|
||||
molecule test
|
||||
|
||||
# Test only 9.18 scenario
|
||||
molecule test -s default
|
||||
|
||||
# Test only 9.20 scenario
|
||||
molecule test -s bind9-20
|
||||
|
||||
# Interactive testing
|
||||
molecule create -s bind9-20
|
||||
molecule converge -s bind9-20
|
||||
molecule verify -s bind9-20
|
||||
```
|
||||
|
||||
### Manual Validation
|
||||
|
||||
```bash
|
||||
# Check BIND9 version
|
||||
named -v
|
||||
|
||||
# Validate configuration syntax
|
||||
named-checkconf /etc/bind/named.conf
|
||||
|
||||
# Check logs for version-related messages
|
||||
journalctl -u named -n 50 -e
|
||||
tail -f /var/log/named/default.log
|
||||
```
|
||||
|
||||
## Migration Path
|
||||
|
||||
Users upgrading from 9.18 to 9.20 should:
|
||||
|
||||
1. **Review Configuration**: Check `BIND9_MIGRATION_GUIDE.md` for breaking changes
|
||||
2. **Update Playbooks**: Remove deprecated variables/options
|
||||
3. **Test in Staging**: Use `molecule test -s bind9-20` to validate
|
||||
4. **Gradual Migration**: Test on non-critical servers first
|
||||
5. **Monitor Logs**: Watch for deprecation or error messages
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
- [ ] Automated configuration migration tool
|
||||
- [ ] Deprecation warnings in role output
|
||||
- [ ] Runtime version detection if branch-per-version maintenance becomes insufficient
|
||||
- [ ] Template conditionals only if a future design intentionally supports multiple BIND9 series from one branch
|
||||
- [ ] 9.21+ preparation when available
|
||||
- [ ] Performance tuning for 9.20 features
|
||||
- [ ] DNS-over-HTTPS (DoH) support
|
||||
- [ ] Clustering/high-availability examples
|
||||
|
||||
## References
|
||||
|
||||
- [ISC BIND9 Website](https://www.isc.org/bind/)
|
||||
- [BIND9 9.20 Release Notes](https://www.isc.org/download/news/)
|
||||
- [BIND9 Documentation](https://bind9.readthedocs.io/)
|
||||
- [BIND9 Version Differences](BIND_VERSION_DIFFERENCES.md)
|
||||
- [BIND9 Migration Guide](BIND9_MIGRATION_GUIDE.md)
|
||||
- [VERSION_SUPPORT.md](VERSION_SUPPORT.md)
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions about BIND9 9.20 support:
|
||||
|
||||
1. Check existing [Issues](https://git.valid.dk/daniel/ansible-bind9-role/issues)
|
||||
2. Review [Discussions](https://git.valid.dk/daniel/ansible-bind9-role/discussions)
|
||||
3. Create a new issue with:
|
||||
- BIND9 version (`named -v`)
|
||||
- Playbook configuration
|
||||
- Error messages from logs
|
||||
- Steps to reproduce
|
||||
@@ -347,9 +347,8 @@ Create a test playbook to validate migration:
|
||||
|
||||
```yaml
|
||||
---
|
||||
# Test playbook for BIND9 9.20 migration
|
||||
- hosts: test_servers
|
||||
vars:
|
||||
bind9_version: "9.20" # Document version being tested
|
||||
|
||||
tasks:
|
||||
- name: Apply BIND9 9.20 configuration
|
||||
|
||||
+8
-25
@@ -270,36 +270,20 @@ bind9-grammar/
|
||||
|
||||
## Version-Specific Features
|
||||
|
||||
### Version Detection
|
||||
### Branch-Level Version Targeting
|
||||
|
||||
The role will detect BIND9 version at runtime:
|
||||
The role currently uses branch-level version targeting instead of runtime version detection:
|
||||
|
||||
```yaml
|
||||
# tasks/main.yml (planned implementation)
|
||||
- name: Detect BIND9 version
|
||||
ansible.builtin.command: named -V
|
||||
register: _bind9_version_output
|
||||
changed_when: false
|
||||
- `main` targets BIND9 9.18.x LTS.
|
||||
- `9.20` targets BIND9 9.20+ feature releases.
|
||||
|
||||
- name: Set BIND9 version facts
|
||||
ansible.builtin.set_fact:
|
||||
bind9_version_full: "{{ _bind9_version_output.stdout | regex_search('BIND (\\S+)', '\\1') | first }}"
|
||||
bind9_version_major: "{{ _bind9_version_output.stdout | regex_search('BIND (\\d+)\\.(\\d+)', '\\1') | first }}"
|
||||
bind9_version_minor: "{{ _bind9_version_output.stdout | regex_search('BIND (\\d+)\\.(\\d+)', '\\2') | first }}"
|
||||
```
|
||||
Each branch carries the templates, grammar data, documentation, and tests appropriate for its supported BIND9 series. This keeps generated configuration predictable and avoids mixing incompatible BIND9 grammar rules in one template path.
|
||||
|
||||
### Conditional Configuration
|
||||
### Runtime Detection
|
||||
|
||||
Templates will use version-aware conditionals:
|
||||
Runtime version detection is not part of the current implementation. The role does not set `bind9_version_full`, `bind9_version_major`, `bind9_version_minor`, or `bind9_version`, and templates do not branch on those values.
|
||||
|
||||
```jinja2
|
||||
{# templates/named.conf.options.j2 (planned) #}
|
||||
{% if bind9_version_major | int >= 20 %}
|
||||
{# BIND9 9.20+ specific options #}
|
||||
{% else %}
|
||||
{# BIND9 9.18 options #}
|
||||
{% endif %}
|
||||
```
|
||||
Runtime detection may be reconsidered in the future if maintaining separate version branches becomes more expensive than supporting multiple BIND9 series from one branch. That future design would require dedicated tasks, public metadata, template changes, and Molecule coverage before being documented as supported behavior.
|
||||
|
||||
## Migration Guidance
|
||||
|
||||
@@ -367,4 +351,3 @@ See `CHANGELOG.md` for version-specific migration notes.
|
||||
| Date | Version | Changes |
|
||||
|------|---------|---------|
|
||||
| 2026-02-07 | 1.0 | Initial version support policy |
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: The main entry point for the bind9 role.
|
||||
description:
|
||||
- Configures BIND9 DNS server on Debian-based systems.
|
||||
- "Supported BIND9 versions are branch-specific: main targets 9.18.x (LTS), and the 9.20 branch targets 9.20+ feature releases."
|
||||
options:
|
||||
bind9_config:
|
||||
type: list
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
# BIND9 9.20 Molecule Scenario
|
||||
|
||||
This Molecule scenario validates the ansible-bind9-role with BIND9 9.20 and later feature releases.
|
||||
|
||||
## Purpose
|
||||
|
||||
- Tests role compatibility with BIND9 9.20+ which includes 44 breaking changes from 9.18.x
|
||||
- Validates version-specific templates and configurations
|
||||
- Ensures configuration syntax is correct for newer BIND9 versions
|
||||
- Documents 9.20-specific configuration patterns
|
||||
|
||||
## Platform
|
||||
|
||||
- **Base Image**: Ubuntu 24.04 LTS (docker.io/library/ubuntu:24.04)
|
||||
- **BIND9 Version**: 9.20.x or later (as available in Ubuntu 24.04 repositories)
|
||||
|
||||
## Notable BIND9 9.20 Changes
|
||||
|
||||
Key breaking changes in this scenario:
|
||||
|
||||
1. **Automatic Options**: The following options are automatically enabled in 9.20 and should not be configured:
|
||||
- `glue-cache` - Always enabled
|
||||
- `keep-response-order` - Always enabled
|
||||
- `reuse` - Always enabled
|
||||
- `recursion-enabled` - Always enabled
|
||||
|
||||
2. **Removed Options**: These options are no longer supported in 9.20:
|
||||
- `alt-transfer-source` - Use TLS instead
|
||||
- `alt-transfer-source-v6` - Use TLS instead
|
||||
- `auto-dnssec` - DNSSEC management is automatic
|
||||
- `dsc` - Use TLS configuration instead
|
||||
- `gssapi-credential` - Use TSIG + TLS instead
|
||||
- `heartbeat-interval` - Zone transfer monitoring changed
|
||||
- `lock-file` - OS-level locking is used
|
||||
- `root-delegation-only` - Use zone constraints instead
|
||||
|
||||
3. **Enhanced Features**:
|
||||
- Improved TLS/DoT support for zone transfers
|
||||
- Native DNSSEC management
|
||||
- Better resolver behavior and retry logic
|
||||
- Native HTTP/HTTPS server capabilities
|
||||
|
||||
## Configuration Features Tested
|
||||
|
||||
- **DNS Forwarding**: Forward zones with TLS-based forwarders (DoT)
|
||||
- **Query Logging**: Detailed query and response logging
|
||||
- **DNSTAP**: DNS packet capture for forensics
|
||||
- **TLS Configuration**: Modern TLS configurations for zone transfers
|
||||
- **Recursion**: Proper recursion configuration with ACLs
|
||||
- **DNSSEC Validation**: Modern DNSSEC validation approach
|
||||
|
||||
## Testing
|
||||
|
||||
To run this scenario:
|
||||
|
||||
```bash
|
||||
# Test with this specific scenario
|
||||
cd /path/to/ansible-bind9-role
|
||||
molecule test -s bind9-20
|
||||
|
||||
# Or specific steps
|
||||
molecule create -s bind9-20
|
||||
molecule converge -s bind9-20
|
||||
molecule verify -s bind9-20
|
||||
molecule destroy -s bind9-20
|
||||
```
|
||||
|
||||
## Expected Results
|
||||
|
||||
- BIND9 service starts successfully
|
||||
- Configuration files are generated without errors
|
||||
- DNS forwarding works correctly
|
||||
- Named-checkconf validates the configuration
|
||||
- All log channels are operational
|
||||
- TLS connections are established for forwarders
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### BIND9 Package Not Available
|
||||
|
||||
If BIND9 9.20 is not available in Ubuntu 24.04 repositories, you may need to:
|
||||
|
||||
1. Build from source using the upstream ISC BIND9 repository
|
||||
2. Use a different base image with more recent BIND9 packages
|
||||
3. Add a custom APT repository with backported packages
|
||||
|
||||
### Configuration Syntax Errors
|
||||
|
||||
Review `/etc/bind/named.conf` using:
|
||||
|
||||
```bash
|
||||
named-checkconf /etc/bind/named.conf
|
||||
```
|
||||
|
||||
Check logs at `/var/log/named/default.log` for specific error messages.
|
||||
|
||||
## Future Updates
|
||||
|
||||
- [ ] Add support for BIND9 9.20 DNS-over-HTTPS (DoH)
|
||||
- [ ] Test with BIND9 9.22+ when released
|
||||
- [ ] Validate performance improvements
|
||||
- [ ] Test clustering/replication features
|
||||
|
||||
## References
|
||||
|
||||
- [BIND9 Documentation](https://bind9.readthedocs.io/)
|
||||
- [BIND9 9.20 Release Notes](https://www.isc.org/bind/)
|
||||
- [DNS-over-TLS (DoT) RFC 7858](https://tools.ietf.org/html/rfc7858)
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
collections:
|
||||
- ansible.posix
|
||||
- community.general
|
||||
@@ -0,0 +1,122 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Create log directory for BIND
|
||||
ansible.builtin.file:
|
||||
path: /var/log/named
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: bind
|
||||
group: bind
|
||||
|
||||
- name: Include bind9 role
|
||||
ansible.builtin.include_role:
|
||||
name: ../../../ansible-bind9-role # noqa: role-name[path]
|
||||
vars:
|
||||
bind9_backup_config: false
|
||||
# BIND9 9.20+ configuration with version-specific options
|
||||
bind9_host_config:
|
||||
- name: named.conf.options
|
||||
options:
|
||||
directory: "{{ bind9_working_directory }}"
|
||||
recursion: true
|
||||
allow_query:
|
||||
- any
|
||||
allow_recursion:
|
||||
- 10.0.0.0/8
|
||||
- 192.168.0.0/16
|
||||
- 172.16.0.0/12
|
||||
- localhost
|
||||
- localnets
|
||||
forwarders:
|
||||
- address: 91.239.100.100
|
||||
tls: censurfridns-anycast
|
||||
- address: 89.233.43.71
|
||||
tls: censurfridns-unicast
|
||||
forward: first
|
||||
dnssec_validation: auto
|
||||
dnstap:
|
||||
- type: auth
|
||||
- type: resolver
|
||||
log: query
|
||||
- type: client
|
||||
log: response
|
||||
dnstap_output:
|
||||
output_type: file
|
||||
output_file: /var/log/named/dnstap.log
|
||||
size: 20m
|
||||
versions: 3
|
||||
suffix: increment
|
||||
dnstap_identity: dns-server-01
|
||||
dnstap_version: 9.20
|
||||
# Note: BIND9 9.20 automatically enables glue-cache, keep-response-order, reuse
|
||||
# These options are removed in 9.20 and should not be configured
|
||||
# Removed options (9.18 compatibility note):
|
||||
# - alt_transfer_source (use TLS instead)
|
||||
# - auto_dnssec (automatic in 9.20)
|
||||
# - glue_cache (always enabled in 9.20)
|
||||
logging:
|
||||
channels:
|
||||
- name: default_log
|
||||
file:
|
||||
name: /var/log/named/default.log
|
||||
severity: info
|
||||
print_time: true
|
||||
print_severity: true
|
||||
print_category: true
|
||||
- name: security_log
|
||||
file:
|
||||
name: /var/log/named/security.log
|
||||
severity: dynamic
|
||||
print_time: true
|
||||
print_severity: true
|
||||
print_category: true
|
||||
- name: query_log
|
||||
file:
|
||||
name: /var/log/named/queries.log
|
||||
versions: 5
|
||||
size: 10m
|
||||
severity: info
|
||||
print_time: true
|
||||
- name: dnssec_log
|
||||
file:
|
||||
name: /var/log/named/dnssec.log
|
||||
severity: debug
|
||||
print_time: true
|
||||
print_severity: true
|
||||
- name: rate_limit_log
|
||||
syslog: daemon
|
||||
severity: warning
|
||||
categories:
|
||||
- name: default
|
||||
channels:
|
||||
- default_log
|
||||
- name: general
|
||||
channels:
|
||||
- default_log
|
||||
- name: security
|
||||
channels:
|
||||
- security_log
|
||||
- name: queries
|
||||
channels:
|
||||
- query_log
|
||||
- name: dnssec
|
||||
channels:
|
||||
- dnssec_log
|
||||
- name: rate-limit
|
||||
channels:
|
||||
- rate_limit_log
|
||||
- name: named.conf.local
|
||||
tls:
|
||||
- name: censurfridns-anycast
|
||||
remote_hostname: anycast.uncensoreddns.org
|
||||
- name: censurfridns-unicast
|
||||
remote_hostname: unicast.uncensoreddns.org
|
||||
zones:
|
||||
- name: example.internal
|
||||
type: forward
|
||||
forward: only
|
||||
forwarders:
|
||||
- 10.0.0.53
|
||||
- 10.0.0.54
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
# Molecule scenario for BIND9 9.20+ support validation
|
||||
# This scenario tests the role with BIND9 9.20 and later feature releases
|
||||
# Note: May require ubuntu:24.04 or Debian 13 (Trixie) for 9.20 package availability
|
||||
|
||||
driver:
|
||||
name: podman
|
||||
platforms:
|
||||
- name: ubuntu-2404-bind920
|
||||
image: docker.io/library/ubuntu:24.04
|
||||
command: /lib/systemd/systemd
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
ALLOW_BROKEN_CONDITIONALS: true
|
||||
verifier:
|
||||
name: ansible
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Update package cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
|
||||
- name: Install DNS query tools (dnsutils)
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- dnsutils
|
||||
- bind9-doc
|
||||
state: present
|
||||
@@ -0,0 +1,120 @@
|
||||
---
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Check that BIND9 is installed
|
||||
ansible.builtin.package:
|
||||
name: bind9
|
||||
state: present
|
||||
check_mode: true
|
||||
register: __bind9_package_check
|
||||
failed_when: __bind9_package_check is changed
|
||||
|
||||
- name: Check that BIND9 service is running
|
||||
ansible.builtin.service:
|
||||
name: named
|
||||
state: started
|
||||
enabled: true
|
||||
check_mode: true
|
||||
register: __bind9_service_check
|
||||
failed_when: __bind9_service_check is changed
|
||||
|
||||
- name: Check that BIND9 version is 9.20 or later
|
||||
ansible.builtin.command:
|
||||
cmd: named -v
|
||||
register: __bind9_version_check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Display BIND9 version
|
||||
ansible.builtin.debug:
|
||||
msg: "BIND9 version: {{ __bind9_version_check.stdout }}"
|
||||
|
||||
- name: Check that named.conf.options exists
|
||||
ansible.builtin.stat:
|
||||
path: /etc/bind/named.conf.options
|
||||
register: __options_file
|
||||
failed_when: not __options_file.stat.exists
|
||||
|
||||
- name: Check that named.conf.local exists
|
||||
ansible.builtin.stat:
|
||||
path: /etc/bind/named.conf.local
|
||||
register: __local_file
|
||||
failed_when: not __local_file.stat.exists
|
||||
|
||||
- name: Read named.conf.options content
|
||||
ansible.builtin.slurp:
|
||||
path: /etc/bind/named.conf.options
|
||||
register: __options_content
|
||||
|
||||
- name: Verify forwarders are configured in options
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'forwarders' in __options_decoded"
|
||||
- "'91.239.100.100' in __options_decoded"
|
||||
- "'forward first' in __options_decoded"
|
||||
fail_msg: Forwarders not properly configured in named.conf.options
|
||||
vars:
|
||||
__options_decoded: "{{ __options_content.content | b64decode }}"
|
||||
|
||||
- name: Read named.conf.local content
|
||||
ansible.builtin.slurp:
|
||||
path: /etc/bind/named.conf.local
|
||||
register: __local_content
|
||||
|
||||
- name: Verify forward zone is configured
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'zone \"example.internal\"' in __local_decoded"
|
||||
- "'type forward' in __local_decoded"
|
||||
- "'forward only' in __local_decoded"
|
||||
fail_msg: Forward zone not properly configured in named.conf.local
|
||||
vars:
|
||||
__local_decoded: "{{ __local_content.content | b64decode }}"
|
||||
|
||||
- name: Test DNS resolution using localhost
|
||||
ansible.builtin.command:
|
||||
cmd: dig @localhost google.com +short
|
||||
register: __dns_query
|
||||
changed_when: false
|
||||
failed_when: __dns_query.rc != 0
|
||||
|
||||
- name: Verify DNS query returned results
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __dns_query.stdout_lines | length > 0
|
||||
fail_msg: DNS forwarding is not working
|
||||
|
||||
- name: Validate configuration syntax with named-checkconf
|
||||
ansible.builtin.command:
|
||||
cmd: named-checkconf /etc/bind/named.conf
|
||||
register: __named_checkconf
|
||||
changed_when: false
|
||||
failed_when: __named_checkconf.rc != 0
|
||||
|
||||
- name: Check BIND logs for errors
|
||||
ansible.builtin.command:
|
||||
cmd: tail -30 /var/log/named/default.log
|
||||
register: __bind_logs
|
||||
changed_when: false
|
||||
|
||||
- name: Display BIND logs
|
||||
ansible.builtin.debug:
|
||||
msg: "BIND logs:\n{{ __bind_logs.stdout }}"
|
||||
|
||||
- name: Verify no critical errors in logs
|
||||
ansible.builtin.shell: |
|
||||
set -o pipefail
|
||||
if grep -i "error" /var/log/named/default.log | grep -v "error reporting" > /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: __error_check
|
||||
|
||||
- name: Assert no critical errors found
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __error_check.rc == 0
|
||||
fail_msg: Found critical errors in BIND logs
|
||||
@@ -1,19 +1,10 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Create log directory for BIND
|
||||
ansible.builtin.file:
|
||||
path: /var/log/named
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: bind
|
||||
group: bind
|
||||
|
||||
- name: Include bind9 role
|
||||
ansible.builtin.include_role:
|
||||
name: ../../../ansible-bind9-role # noqa: role-name[path]
|
||||
roles:
|
||||
- ansible-bind9-role
|
||||
vars:
|
||||
bind9_log_dir: /var/log/named
|
||||
bind9_backup_config: false
|
||||
bind9_host_config:
|
||||
- name: named.conf.options
|
||||
@@ -113,3 +104,14 @@
|
||||
forwarders:
|
||||
- 10.0.0.53
|
||||
- 10.0.0.54
|
||||
|
||||
- name: Post-converge
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Create log directory for BIND
|
||||
ansible.builtin.file:
|
||||
path: /var/log/named
|
||||
state: directory
|
||||
mode: '0750'
|
||||
owner: bind
|
||||
group: bind
|
||||
|
||||
@@ -11,6 +11,8 @@ platforms:
|
||||
cgroupns_mode: host
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
ANSIBLE_ROLES_PATH: ${MOLECULE_PROJECT_DIRECTORY}/..
|
||||
config_options:
|
||||
defaults:
|
||||
ALLOW_BROKEN_CONDITIONALS: true
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'forwarders' in __options_decoded"
|
||||
- "'8.8.8.8' in __options_decoded"
|
||||
- "'91.239.100.100' in __options_decoded"
|
||||
- "'89.233.43.71' in __options_decoded"
|
||||
- "'forward first' in __options_decoded"
|
||||
fail_msg: Forwarders not properly configured in named.conf.options
|
||||
vars:
|
||||
|
||||
@@ -18,6 +18,17 @@
|
||||
mode: "0750"
|
||||
when: bind9_backup_config is defined and bind9_backup_config | bool
|
||||
|
||||
- name: Ensure logging directory exists if defined
|
||||
ansible.builtin.file:
|
||||
path: "{{ bind9_log_dir }}"
|
||||
state: directory
|
||||
owner: bind
|
||||
group: bind
|
||||
mode: "0750"
|
||||
when:
|
||||
- bind9_log_dir is defined
|
||||
- bind9_log_dir is not none
|
||||
|
||||
- name: Deploy and Validate Configuration
|
||||
tags:
|
||||
- bind9
|
||||
@@ -34,6 +45,7 @@
|
||||
owner: root
|
||||
group: bind
|
||||
mode: "0640"
|
||||
when: bind9_backup_config | bool
|
||||
changed_when: false
|
||||
failed_when: false # It's okay if the file doesn't exist yet
|
||||
loop: "{{ bind9_config }}"
|
||||
@@ -85,6 +97,7 @@
|
||||
loop: "{{ bind9_config }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }}"
|
||||
changed_when: false
|
||||
when: bind9_backup_config | bool is false
|
||||
|
||||
- name: Ensure the named service is started
|
||||
|
||||
Reference in New Issue
Block a user