From: Zack Cerza Date: Wed, 2 May 2018 16:13:00 +0000 (-0600) Subject: ceph-grafana: Add notification channel X-Git-Tag: v2.0~35^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a58fd5e027be18a151d33cc44e33cbde0046ad58;p=cephmetrics.git ceph-grafana: Add notification channel Signed-off-by: Zack Cerza --- 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