--- /dev/null
+---
+- 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"