]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
ceph-grafana: Add notification channel 170/head
authorZack Cerza <zack@redhat.com>
Wed, 2 May 2018 16:13:00 +0000 (10:13 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 2 May 2018 16:13:00 +0000 (10:13 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
ansible/roles/ceph-grafana/tasks/add_notification_channel.yml [new file with mode: 0644]
ansible/roles/ceph-grafana/tasks/configure_grafana.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 (file)
index 0000000..6faedc2
--- /dev/null
@@ -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"
index 8b17c6a11eaf87cc11ba5a5d33c7eb101d095c23..a26ab2806b4d1bbfd96db8243f943c5ec26f2f2d 100644 (file)
     - backend.storage == "prometheus"
   tags:
     - dashboards
+
+- include: add_notification_channel.yml
+  tags:
+    - notification