Fix grafana data source registration

Make data source creation more dynamic to support a variable number of data
source of different types

Only create data sources actually deployed by kolla

Change-Id: I26a2d3c71b178562b906623ab77eaff673c81dce
This commit is contained in:
Mathias Ewald 2017-07-21 09:02:39 +00:00
parent ffc4fb3793
commit b7aef07d28
2 changed files with 15 additions and 13 deletions

View File

@ -23,16 +23,17 @@ grafana_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
#################### ####################
# Datasource # Datasource
#################### ####################
grafana_data_source: grafana_data_sources:
isDefault: yes influxdb:
database: "telegraf" enabled: "{{ enable_influxdb | bool }}"
user: admin data:
password: "{{ grafana_admin_password }}" isDefault: yes
name: "telegraf" database: "telegraf"
type: "influxdb" name: "telegraf"
url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ influxdb_http_port }}" type: "influxdb"
access: "proxy" url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ influxdb_http_port }}"
basicAuth: false access: "proxy"
basicAuth: false
########## ##########
# Grafana # Grafana

View File

@ -10,20 +10,21 @@
run_once: true run_once: true
connection: local connection: local
- name: Enable influxdb datasource - name: Enable grafana datasources
uri: uri:
url: "{{ internal_protocol }}://{{ kolla_internal_vip_address }}:{{ grafana_server_port }}/api/datasources" url: "{{ internal_protocol }}://{{ kolla_internal_vip_address }}:{{ grafana_server_port }}/api/datasources"
method: POST method: POST
user: admin user: admin
password: "{{ grafana_admin_password }}" password: "{{ grafana_admin_password }}"
body: "{{ grafana_data_source | to_json }}" body: "{{ item.value.data | to_json }}"
body_format: json body_format: json
force_basic_auth: yes force_basic_auth: yes
status_code: 200, 409 status_code: 200, 409
register: response register: response
run_once: True run_once: True
connection: local connection: local
when: grafana_data_source is defined
changed_when: response.status == 200 changed_when: response.status == 200
failed_when: response.status not in [200, 409] or failed_when: response.status not in [200, 409] or
response.status == 409 and ("Data source with same name already exists" not in response.json.message|default("")) response.status == 409 and ("Data source with same name already exists" not in response.json.message|default(""))
with_dict: "{{ grafana_data_sources }}"
when: item.value.enabled | bool