Merge "Grafana: automatically set InfuxDB datasource"
This commit is contained in:
commit
0181d88e21
@ -20,6 +20,20 @@ grafana_database_name: "grafana"
|
|||||||
grafana_database_user: "grafana"
|
grafana_database_user: "grafana"
|
||||||
grafana_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
|
grafana_database_address: "{{ kolla_internal_fqdn }}:{{ database_port }}"
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Datasource
|
||||||
|
####################
|
||||||
|
grafana_data_source:
|
||||||
|
isDefault: yes
|
||||||
|
database: "telegraf"
|
||||||
|
user: admin
|
||||||
|
password: "{{ grafana_admin_password }}"
|
||||||
|
name: "telegraf"
|
||||||
|
type: "influxdb"
|
||||||
|
url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ influxdb_http_port }}"
|
||||||
|
access: "proxy"
|
||||||
|
basicAuth: false
|
||||||
|
|
||||||
##########
|
##########
|
||||||
# Grafana
|
# Grafana
|
||||||
##########
|
##########
|
||||||
|
@ -7,3 +7,6 @@
|
|||||||
|
|
||||||
- name: Flush handlers
|
- name: Flush handlers
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- include: post_config.yml
|
||||||
|
when: inventory_hostname in groups['grafana']
|
||||||
|
21
ansible/roles/grafana/tasks/post_config.yml
Normal file
21
ansible/roles/grafana/tasks/post_config.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: Wait for grafana port
|
||||||
|
wait_for:
|
||||||
|
host: "{{ api_interface_address }}"
|
||||||
|
port: "{{ grafana_server_port }}"
|
||||||
|
|
||||||
|
- name: Enable influxdb datasource
|
||||||
|
uri:
|
||||||
|
url: "{{ internal_protocol }}://{{ api_interface_address }}:{{ grafana_server_port }}/api/datasources"
|
||||||
|
method: POST
|
||||||
|
user: admin
|
||||||
|
password: "{{ grafana_admin_password }}"
|
||||||
|
body: "{{ grafana_data_source | to_json }}"
|
||||||
|
body_format: json
|
||||||
|
force_basic_auth: yes
|
||||||
|
status_code: 200, 409
|
||||||
|
register: response
|
||||||
|
when: grafana_data_source is defined
|
||||||
|
changed_when: response.status == 200
|
||||||
|
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(""))
|
Loading…
x
Reference in New Issue
Block a user