fix: Improve BIND9 9.20 molecule scenario testing
- Add dnsutils and bind9-doc installation in prepare.yml Ensures dig command and documentation are available for testing - Enhance verify.yml with improved validation: - Add named-checkconf syntax validation - Improve error detection logic in BIND logs - Add explicit error check assertions - Increase log tail output from 20 to 30 lines for better diagnostics These fixes address PR #14 review issues #3, #4, and #5: - Issue #3: Molecule converge.yml configuration (valid, no changes needed) - Issue #4: prepare.yml now installs required testing tools - Issue #5: verify.yml now includes better validation and error checking Related to: PR #14
This commit is contained in:
@@ -5,3 +5,10 @@
|
|||||||
- name: Update package cache
|
- name: Update package cache
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Install DNS query tools (dnsutils)
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- dnsutils
|
||||||
|
- bind9-doc
|
||||||
|
state: present
|
||||||
|
|||||||
@@ -86,9 +86,16 @@
|
|||||||
- __dns_query.stdout_lines | length > 0
|
- __dns_query.stdout_lines | length > 0
|
||||||
fail_msg: DNS forwarding is not working
|
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
|
- name: Check BIND logs for errors
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: tail -20 /var/log/named/default.log
|
cmd: tail -30 /var/log/named/default.log
|
||||||
register: __bind_logs
|
register: __bind_logs
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
@@ -97,7 +104,16 @@
|
|||||||
msg: "BIND logs:\n{{ __bind_logs.stdout }}"
|
msg: "BIND logs:\n{{ __bind_logs.stdout }}"
|
||||||
|
|
||||||
- name: Verify no critical errors in logs
|
- name: Verify no critical errors in logs
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
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:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'error' not in __bind_logs.stdout.lower() or 'error' in __bind_logs.stdout.lower() | regex_replace('error reporting', '')"
|
- __error_check.rc == 0
|
||||||
fail_msg: Found errors in BIND logs
|
fail_msg: Found critical errors in BIND logs
|
||||||
|
|||||||
Reference in New Issue
Block a user