Skip to content

Commit

Permalink
feat(Alerting): Allow alert resource provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
hypery2k committed Sep 21, 2023
1 parent d80fd5a commit 9be431e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions roles/grafana/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ grafana_alert_notifications: []
# settings:
# addresses: "[email protected]"

# Alert resources channels to configure
grafana_alert_resources: {}

# Datasources to configure
grafana_datasources: []
# - name: "Prometheus"
Expand Down
2 changes: 1 addition & 1 deletion roles/grafana/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
- grafana_configure
- grafana_notifications
- grafana_run
when: "grafana_alert_notifications | length > 0"
when: "grafana_alert_notifications | length > 0 or grafana_alert_resources | length > 0"

- name: Dashboards
ansible.builtin.include_tasks:
Expand Down
19 changes: 17 additions & 2 deletions roles/grafana/tasks/notifications.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
---
# legacy config
- name: "Create/Delete/Update alert notifications channels (provisioning)"
ansible.builtin.copy:
content: |

Check failure on line 5 in roles/grafana/tasks/notifications.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

jinja[invalid]

to_nice_yaml - 'grafana_alert_notifications' is undefined. 'grafana_alert_notifications' is undefined
apiVersion: 1
{{ grafana_alert_notifications | to_nice_yaml }}
dest: /etc/grafana/provisioning/notifiers/ansible.yml
dest: /etc/grafana/provisioning/notification/ansible.yml
owner: root
group: grafana
mode: 0640
become: true
notify: restart_grafana
when: grafana_use_provisioning
when: grafana_use_provisioning and grafana_alert_notifications | length > 0

# new alert resources
- name: "Create/Delete/Update alert resources (provisioning)"
ansible.builtin.copy:
content: |

Check failure on line 19 in roles/grafana/tasks/notifications.yml

View workflow job for this annotation

GitHub Actions / Perform Linting

jinja[invalid]

to_nice_yaml - 'grafana_alert_resources' is undefined. 'grafana_alert_resources' is undefined
apiVersion: 1
{{ grafana_alert_resources | to_nice_yaml }}
dest: /etc/grafana/provisioning/alerting/ansible.yml
owner: root
group: grafana
mode: 0640
become: true
notify: restart_grafana
when: grafana_use_provisioning and grafana_alert_resources | length > 0

0 comments on commit 9be431e

Please sign in to comment.