diff --git a/roles/nameserver/tasks/configure_bind_snmpd.yml b/roles/nameserver/tasks/configure_bind_snmpd.yml index 33910ab..59f80d8 100755 --- a/roles/nameserver/tasks/configure_bind_snmpd.yml +++ b/roles/nameserver/tasks/configure_bind_snmpd.yml @@ -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