Call Grafana APIs only once

In multinode deployments creating default Grafana organization failed,
because Ansible attempted to call Grafana API in the context of each
host in the inventory. After creating organization via the first host,
subsequent attempts via the remaining hosts failed due to already
existing organization. This change enforces creating default
organization only once.

Other tasks using Grafana API have been enforced to be ran only once as
well.

Change-Id: I3a93a719b3c9b4e55ab226d3b22d571d9a0f489d
Signed-off-by: Bartosz Zurkowski <b.zurkowski@samsung.com>
This commit is contained in:
Bartosz Zurkowski 2018-12-16 16:23:51 +01:00
parent 404d0b1c12
commit c5d1e1d5f2

View File

@ -21,6 +21,7 @@
password: '{{ monasca_grafana_admin_password }}' password: '{{ monasca_grafana_admin_password }}'
return_content: true return_content: true
force_basic_auth: true force_basic_auth: true
run_once: True
register: monasca_grafana_orgs register: monasca_grafana_orgs
- name: Create default control plane organisation if it doesn't exist - name: Create default control plane organisation if it doesn't exist
@ -33,6 +34,7 @@
body: body:
name: '{{ monasca_grafana_control_plane_org }}' name: '{{ monasca_grafana_control_plane_org }}'
force_basic_auth: true force_basic_auth: true
run_once: True
when: monasca_grafana_control_plane_org not in monasca_grafana_orgs.json|map(attribute='name')|unique when: monasca_grafana_control_plane_org not in monasca_grafana_orgs.json|map(attribute='name')|unique
- name: Lookup Monasca Grafana control plane organisation ID - name: Lookup Monasca Grafana control plane organisation ID
@ -43,6 +45,7 @@
password: '{{ monasca_grafana_admin_password }}' password: '{{ monasca_grafana_admin_password }}'
return_content: true return_content: true
force_basic_auth: true force_basic_auth: true
run_once: True
register: monasca_grafana_conf_org register: monasca_grafana_conf_org
- name: Add {{ monasca_grafana_admin_username }} user to control plane organisation - name: Add {{ monasca_grafana_admin_username }} user to control plane organisation
@ -70,6 +73,7 @@
user: '{{ monasca_grafana_admin_username }}' user: '{{ monasca_grafana_admin_username }}'
password: '{{ monasca_grafana_admin_password }}' password: '{{ monasca_grafana_admin_password }}'
force_basic_auth: true force_basic_auth: true
run_once: True
- name: Enable Monasca Grafana datasource for control plane organisation - name: Enable Monasca Grafana datasource for control plane organisation
uri: uri: