summaryrefslogtreecommitdiff
path: root/roles/network
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-11-10 19:31:09 +0100
committerChristian Pointner <equinox@spreadspace.org>2022-11-10 19:31:09 +0100
commitb5406d18de64f273cbebb3875a84bc31074f0f00 (patch)
treee8774b1cb9b6124d14f5ec76ca103a7427de2b52 /roles/network
parentadd ch-pan and ch-mimas to prometheus monitoring (diff)
prometheus: add exporter for bind
Diffstat (limited to 'roles/network')
-rw-r--r--roles/network/bind/defaults/main.yml9
-rw-r--r--roles/network/bind/tasks/main.yml22
-rw-r--r--roles/network/bind/templates/stats.j27
3 files changed, 37 insertions, 1 deletions
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 %}
+};