From: Boris Ranto Date: Sun, 25 Jun 2017 08:13:51 +0000 (+0200) Subject: ansible: Write grafana config when grafana is down X-Git-Tag: v1.0~65^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=398478ade7b0f22ba424ab6dc580d45d1f75b088;p=cephmetrics.git ansible: Write grafana config when grafana is down 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 --- diff --git a/ansible/roles/ceph-grafana/tasks/configure_grafana.yml b/ansible/roles/ceph-grafana/tasks/configure_grafana.yml index a25e01c..635668c 100644 --- a/ansible/roles/ceph-grafana/tasks/configure_grafana.yml +++ b/ansible/roles/ceph-grafana/tasks/configure_grafana.yml @@ -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: > { @@ -52,28 +86,6 @@ 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 diff --git a/ansible/roles/ceph-grafana/tasks/grafana_plugins.yml b/ansible/roles/ceph-grafana/tasks/grafana_plugins.yml index 74b845e..52de29b 100644 --- a/ansible/roles/ceph-grafana/tasks/grafana_plugins.yml +++ b/ansible/roles/ceph-grafana/tasks/grafana_plugins.yml @@ -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