From a58fd5e027be18a151d33cc44e33cbde0046ad58 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Wed, 2 May 2018 10:13:00 -0600 Subject: [PATCH] ceph-grafana: Add notification channel Signed-off-by: Zack Cerza --- .../tasks/add_notification_channel.yml | 31 +++++++++++++++++++ .../ceph-grafana/tasks/configure_grafana.yml | 4 +++ 2 files changed, 35 insertions(+) create mode 100644 ansible/roles/ceph-grafana/tasks/add_notification_channel.yml diff --git a/ansible/roles/ceph-grafana/tasks/add_notification_channel.yml b/ansible/roles/ceph-grafana/tasks/add_notification_channel.yml new file mode 100644 index 0000000..6faedc2 --- /dev/null +++ b/ansible/roles/ceph-grafana/tasks/add_notification_channel.yml @@ -0,0 +1,31 @@ +--- +- name: Check if notification channel is present + uri: + url: "http://localhost:3000/api/alert-notifications" + method: GET + user: "{{ grafana.user }}" + password: "{{ grafana.admin_password }}" + force_basic_auth: yes + status_code: 200 + register: notifications + +- name: Create present_notifications var + set_fact: + present_notifications: {} + +- name: Set present_notifications + set_fact: + present_notifications: "{{ present_notifications.update({item.name: item.id}) }}{{ present_notifications }}" + with_items: "{{ notifications.json }}" + +- name: Add notification channel + uri: + url: "http://localhost:3000/api/alert-notifications" + method: POST + user: "{{ grafana.user }}" + password: "{{ grafana.admin_password }}" + force_basic_auth: yes + status_code: 200 + body_format: json + body: '{"name": "cephmetrics", "type": "email", "isDefault": false}' + when: "'cephmetrics' not in present_notifications" diff --git a/ansible/roles/ceph-grafana/tasks/configure_grafana.yml b/ansible/roles/ceph-grafana/tasks/configure_grafana.yml index 8b17c6a..a26ab28 100644 --- a/ansible/roles/ceph-grafana/tasks/configure_grafana.yml +++ b/ansible/roles/ceph-grafana/tasks/configure_grafana.yml @@ -142,3 +142,7 @@ - backend.storage == "prometheus" tags: - dashboards + +- include: add_notification_channel.yml + tags: + - notification -- 2.47.3