4 Commits

Author SHA1 Message Date
Daniel Akulenok
07f84b7c96 Fix Molecule default scenario tests
Some checks failed
Test / Lint (pull_request) Successful in 16s
Test / Test (pull_request) Failing after 2m12s
2026-02-08 20:43:56 +01:00
Daniel Akulenok
a4f06d3daf fix: Install molecule-podman driver for CI/CD tests
All checks were successful
Test / Lint (push) Successful in 16s
Test / Test (push) Has been skipped
The test stage was failing because molecule couldn't find the podman
driver. The issue was that 'molecule[podman]' extra doesn't exist in
molecule 25.12.0. Install 'molecule-podman' package instead which
provides the required podman driver for molecule.
2026-02-08 00:29:47 +01:00
Daniel Akulenok
282e7601b4 fix: Add pipefail option to shell command in verify.yml
All checks were successful
Test / Lint (push) Successful in 15s
Test / Test (push) Has been skipped
Resolves ansible-lint risky-shell-pipe violation by adding
'set -o pipefail' to shell task that uses pipes.
2026-02-08 00:26:46 +01:00
f15d33b619 Merge pull request 'feat: Add BIND9 9.20 support with molecule scenario and documentation' (#14) from feature/bind9-20-support into main
Some checks failed
Test / Lint (push) Failing after 15s
Test / Test (push) Has been skipped
Reviewed-on: #14
2026-02-07 23:21:35 +00:00
6 changed files with 60 additions and 11 deletions

View File

@@ -54,8 +54,8 @@ jobs:
run: |
pip install --no-cache-dir \
ansible \
molecule[podman] \
podman-compose \
molecule \
molecule-podman \
pyyaml \
jinja2

View File

@@ -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.

View File

@@ -105,6 +105,7 @@
- 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

View File

@@ -2,18 +2,11 @@
- 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_log_dir: /var/log/named
bind9_backup_config: false
bind9_host_config:
- name: named.conf.options
@@ -113,3 +106,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

View File

@@ -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:

View File

@@ -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 }}"