]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
ansible: Write grafana config when grafana is down
authorBoris Ranto <branto@redhat.com>
Sun, 25 Jun 2017 08:13:51 +0000 (10:13 +0200)
committerBoris Ranto <branto@redhat.com>
Mon, 26 Jun 2017 18:10:42 +0000 (20:10 +0200)
We need to start and communcite with grafana after we push our own
config to the grafana. The old config can use different locations
e.g. for the DB and these won't get populated properly if we run
dashUpdater or post to the grafana API too early.

Signed-off-by: Boris Ranto <branto@redhat.com>
ansible/roles/ceph-grafana/tasks/configure_grafana.yml
ansible/roles/ceph-grafana/tasks/grafana_plugins.yml

index a25e01c34e9a5f738d77f0828a61f910ce793bde..635668c1dcf908bab215d9a73dbc0c5e66324d18 100644 (file)
@@ -1,10 +1,44 @@
 ---
-- name: Start Grafana
+- name: Make sure grafana is down
+  service:
+    name: grafana-server
+    state: stopped
+
+- name: Wait for grafana to be stopped
+  wait_for:
+    port: 3000
+    state: stopped
+
+- name: Write grafana.ini
+  copy:
+    src: files/grafana.ini
+    dest: /etc/grafana/grafana.ini
+    owner: root
+    group: grafana
+    mode: 0640
+  tags: [ini]
+
+- name: Set domain in grafana.ini
+  lineinfile:
+    dest: /etc/grafana/grafana.ini
+    regexp: "^domain = .*"
+    insertafter: "^;domain = .*"
+    line: "domain = {{ ansible_fqdn }}"
+  tags: [ini]
+
+- include: grafana_plugins.yml
+  when: devel_mode
+
+- name: Enable and start grafana
   service:
     name: grafana-server
     state: started
     enabled: true
 
+- name: Wait for grafana to start
+  wait_for:
+    port: 3000
+
 - set_fact:
     grafana_data_source: >
       {
     status_code: 200
   when: grafana_data_source_result is defined and grafana_data_source_result.status == 409
 
-- name: Write grafana.ini
-  copy:
-    src: files/grafana.ini
-    dest: /etc/grafana/grafana.ini
-    owner: root
-    group: grafana
-    mode: 0640
-  tags: [ini]
-  notify: Restart Grafana
-
-- name: Set domain in grafana.ini
-  lineinfile:
-    dest: /etc/grafana/grafana.ini
-    regexp: "^domain = .*"
-    insertafter: "^;domain = .*"
-    line: "domain = {{ ansible_fqdn }}"
-  tags: [ini]
-  notify: Restart Grafana
-
-- include: grafana_plugins.yml
-  when: devel_mode
-
 - name: Ship dashboard templates
   copy:
     src: files/dashboards
index 74b845e20ec9eacadb58e5ea75ec297b6da367a8..52de29b05ba28a00764a0a4ffafd6845e71f9b69 100644 (file)
@@ -26,4 +26,3 @@
 - name: Move Vonage Status Panel into place
   shell: "mv -f {{ vonage_plugin_path }}* {{ vonage_plugin_path }}"
   when: vonage_plugin.stat.exists is defined and not vonage_plugin.stat.exists
-  notify: Restart Grafana