Added grafana role automation.
authorLuke Hoersten <luke@hoersten.org>
Sun, 28 Jun 2020 10:32:15 -0500
changeset 52 5a5071d4eaad
parent 51 19fa7aa47bf1
child 53 9e4f750f5d36
Added grafana role automation.
prometheus/server/defaults/main.yaml
prometheus/server/tasks/main.yaml
--- a/prometheus/server/defaults/main.yaml	Sun Jun 28 09:00:01 2020 -0500
+++ b/prometheus/server/defaults/main.yaml	Sun Jun 28 10:32:15 2020 -0500
@@ -4,3 +4,6 @@
 prometheus_server_apt_packages:
   - "prometheus"
   - "grafana"
+
+prometheus_server_grafana_plugins:
+  - "flant-statusmap-panel"
--- a/prometheus/server/tasks/main.yaml	Sun Jun 28 09:00:01 2020 -0500
+++ b/prometheus/server/tasks/main.yaml	Sun Jun 28 10:32:15 2020 -0500
@@ -21,4 +21,31 @@
     - restart prometheus service
     - restart grafana service
 
-# /etc/grafana/grafana.ini
+- name: install grafana prometheus data source
+  become: yes
+  grafana_datasource:
+    name: "Prometheus"
+    ds_type: "prometheus"
+    ds_url: "http://localhost:9090"
+    grafana_url: "http://localhost:3000"
+    is_default: yes
+
+- name: install grafana plugins
+  become: yes
+  grafana_plugin: name="{{item}}"
+  loop: "{{prometheus_server_grafana_plugins}}"
+
+- name: copy dashboards to target
+  become: yes
+  copy:
+    src: "{{prometheus_server_grafana_dashboard_src}}/{{item}}"
+    dest: "/tmp/"
+    mode: "0640"
+  loop: "{{prometheus_server_grafana_dashboards}}"
+
+- name: install grafana dashboards
+  become: yes
+  grafana_dashboard:
+    grafana_url: "http://localhost:3000"
+    path: "/tmp/{{item}}"
+  loop: "{{prometheus_server_grafana_dashboards}}"