From f79dd8a001c33eb7b9d7ca16257fc872dbab8f54 Mon Sep 17 00:00:00 2001 From: Gerard Ryan Date: Tue, 4 Dec 2018 17:43:06 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Install=20grafana-piechart-plugi?= =?UTF-8?q?n=20into=20Grafana=20PV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tasks/provision-grafana.yml | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/roles/provision-metrics-apb/tasks/provision-grafana.yml b/roles/provision-metrics-apb/tasks/provision-grafana.yml index 0f4c8e6..682724e 100644 --- a/roles/provision-metrics-apb/tasks/provision-grafana.yml +++ b/roles/provision-metrics-apb/tasks/provision-grafana.yml @@ -1,4 +1,3 @@ - - name: Create Grafana config from template template: src: grafana-config-map.ini.j2 @@ -210,3 +209,41 @@ until: org_pref_update_response.status == 200 delay: 5 register: org_pref_update_response + +- name: Get the name of the Grafana pod + shell: oc get pods -n '{{ namespace }}' --selector="deploymentconfig=grafana" -o jsonpath='{.items[0].metadata.name}' + register: grafana_pod_name + retries: 10 + until: '"grafana" in grafana_pod_name.stdout' + delay: 5 + +# +# Add plugins to PV and restart grafana +# curl -L -o piechart-panel-1.3.3.zip https://grafana.com/api/plugins/grafana-piechart-panel/versions/1.3.3/download +# + +- name: Copy Grafana piechart-panel plugin into temp directory + copy: + src: grafana-piechart-panel + dest: /tmp/grafana-piechart-panel + +- name: Copy piechart-panel plugin into grafana container + shell: oc cp /tmp/grafana-piechart-panel {{ namespace }}/{{ grafana_pod_name.stdout }}:/var/lib/grafana/plugins -c grafana + register: copy_plugin + retries: 60 + until: copy_plugin.rc == 0 + delay: 5 + +- name: Restart grafana to pick up on the new plugin (scale down) + shell: oc scale --replicas=0 --namespace={{ namespace }} dc grafana + +- name: Restart grafana to pick up on the new plugin (scale up) + shell: oc scale --replicas=1 --namespace={{ namespace }} dc grafana + delay: 10 + +- name: Wait for all grafana containers to become ready again + shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=grafana" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w + register: grafana_result + until: grafana_result.stdout.find("2") != -1 + retries: 30 + delay: 10