feat(grafana): provision disk alerts to ntfy

Provision Grafana Unified Alerting as code: ntfy webhook contact point
(?template=grafana), notification policy tree, and cumulative disk tiers
for HDD temperature (48-60C, <20C) plus ZFS/filesystem capacity. Lower the
smartctl exporter interval to 30m for alert responsiveness.
This commit is contained in:
Clément Désiles
2026-09-18 18:32:02 +02:00
parent c127336321
commit be73f3adfa
8 changed files with 887 additions and 2 deletions
+64
View File
@@ -269,6 +269,70 @@
mode: "0644"
notify: Restart grafana
# Alerting provisioning (Unified Alerting -> ntfy webhook)
- name: Validate ntfy alerting settings are set
ansible.builtin.assert:
that:
- grafana_ntfy_webhook_url is defined
- grafana_ntfy_webhook_url | length > 0
- grafana_ntfy_token is defined
- grafana_ntfy_token | length > 0
fail_msg: |
grafana_alerting_enabled is true but grafana_ntfy_webhook_url / grafana_ntfy_token are not set.
See roles/grafana/defaults/main.yml for configuration instructions.
success_msg: "ntfy alerting settings validated"
when: grafana_alerting_enabled
- name: Ensure Grafana alerting provisioning directory exists
ansible.builtin.file:
path: "{{ grafana_provisioning_path }}/alerting"
state: directory
owner: "{{ grafana_user }}"
group: "{{ grafana_group }}"
mode: "0755"
when: grafana_alerting_enabled
- name: Deploy Grafana alerting contact points
ansible.builtin.template:
src: alerting-contact-points.yaml.j2
dest: "{{ grafana_provisioning_path }}/alerting/contact-points.yaml"
owner: "{{ grafana_user }}"
group: "{{ grafana_group }}"
mode: "0600"
when: grafana_alerting_enabled
notify: Restart grafana
- name: Deploy Grafana alerting notification policies
ansible.builtin.copy:
src: alerting-policies.yaml
dest: "{{ grafana_provisioning_path }}/alerting/policies.yaml"
owner: "{{ grafana_user }}"
group: "{{ grafana_group }}"
mode: "0644"
when: grafana_alerting_enabled
notify: Restart grafana
- name: Deploy Grafana disk alert rules
ansible.builtin.copy:
src: alerting-rules.yaml
dest: "{{ grafana_provisioning_path }}/alerting/rules.yaml"
owner: "{{ grafana_user }}"
group: "{{ grafana_group }}"
mode: "0644"
when: grafana_alerting_enabled
notify: Restart grafana
- name: Remove Grafana alerting provisioning when disabled
ansible.builtin.file:
path: "{{ grafana_provisioning_path }}/alerting/{{ item }}"
state: absent
loop:
- contact-points.yaml
- policies.yaml
- rules.yaml
when: not grafana_alerting_enabled
notify: Restart grafana
# Service management
- name: Enable and start Grafana service
ansible.builtin.systemd: