From b5406d18de64f273cbebb3875a84bc31074f0f00 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 10 Nov 2022 19:31:09 +0100 Subject: prometheus: add exporter for bind --- roles/network/bind/defaults/main.yml | 9 ++++++++- roles/network/bind/tasks/main.yml | 22 ++++++++++++++++++++++ roles/network/bind/templates/stats.j2 | 7 +++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 roles/network/bind/templates/stats.j2 (limited to 'roles/network/bind') diff --git a/roles/network/bind/defaults/main.yml b/roles/network/bind/defaults/main.yml index 80dbe396..7ed9521b 100644 --- a/roles/network/bind/defaults/main.yml +++ b/roles/network/bind/defaults/main.yml @@ -1,4 +1,12 @@ --- +## stats + +# bind_stats_channels: +# - addr: 127.0.0.1 +# port: 8053 +# allow: +# - 127.0.0.1 + ## options # bind_option_empty_zones_enable: yes @@ -9,7 +17,6 @@ # bind_option_also_notify: [] # bind_option_allow_transfer: [] - ## zone configs bind_empty_onion_zone: no diff --git a/roles/network/bind/tasks/main.yml b/roles/network/bind/tasks/main.yml index 2303e76c..49898162 100644 --- a/roles/network/bind/tasks/main.yml +++ b/roles/network/bind/tasks/main.yml @@ -89,6 +89,28 @@ notify: reload bind +- name: add stats configuration + when: bind_stats_channels is defined + template: + src: stats.j2 + dest: /etc/bind/named.conf.stats + notify: reload bind + +- name: remove stats configuration + when: bind_stats_channels is not defined + file: + path: /etc/bind/named.conf.stats + state: absent + notify: reload bind + +- name: enable/disable stats configuration + lineinfile: + path: /etc/bind/named.conf + line: 'include "/etc/bind/named.conf.stats";' + state: "{{ bind_stats_channels is defined | ternary('present', 'absent') }}" + notify: reload bind + + - name: add slave zone configuration when: bind_slave_zones is defined template: diff --git a/roles/network/bind/templates/stats.j2 b/roles/network/bind/templates/stats.j2 new file mode 100644 index 00000000..06a1f514 --- /dev/null +++ b/roles/network/bind/templates/stats.j2 @@ -0,0 +1,7 @@ +// Stats + +statistics-channels { +{% for channel in bind_stats_channels %} + inet {{ channel.addr | default('*') }}{% if 'port' in channel %} port {{ channel.port }}{% endif %}{% if 'allow' in channel %} allow { {{ channel.allow | join('; ') }}; }{% endif %}; +{% endfor %} +}; -- cgit v1.2.3