nameserver: fix bind statistics options (literal escapes broke named-checkconf)

The lineinfile 'line' used YAML single quotes, so '\t' and '\n' were written
literally, producing 'unknown option' errors from named-checkconf. Replace with
a blockinfile block, remove the legacy literal-escape lines on next run, and
keep validation via the named-checkconf wrapper.
This commit is contained in:
rene committed 2026-10-22 16:48:12 +02:00
1 parent d0fe8afddc
commit 52f2ac45e5
1 file changed
+16 -3
@@ -34,12 +34,25 @@
owner: "root"
group: "root"
- name: nameserver | snmpd | configure named for statistics
- name: nameserver | snmpd | remove legacy statistics options (tab / literal-escape forms)
lineinfile:
path: "{{ named_conf_options }}"
state: present
line: '\tstatistics-file "/var/cache/bind/stats";\n\tzone-statistics yes;'
regexp: "{{ item }}"
state: absent
loop:
- '^(?! )(?:[ \t]*)(?:\\t)?statistics-file "/var/cache/bind/stats";(?:\\n[ \t]*(?:\\t)?zone-statistics yes;)?[ \t]*$'
- '^(?! )[ \t]*statistics-file "/var/cache/bind/stats"; zone-statistics yes;[ \t]*$'
- '^(?! )[ \t]*zone-statistics yes;[ \t]*$'
notify: restart_named
- name: nameserver | snmpd | configure named for statistics
blockinfile:
path: "{{ named_conf_options }}"
insertafter: "options {"
marker: " # {mark} ANSIBLE MANAGED - snmpd statistics"
block: |
statistics-file "/var/cache/bind/stats";
zone-statistics yes;
validate: "/usr/local/bin/named-checkconf-wrapper.sh %s {{ named_conf }} {{ named_conf_options }} {{ named_checkconf }}"
notify: restart_named