Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow alert resource provisioning #110

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading