1
0
Fork 0

Allow basic auth when datasource is adding

This patch fixes an issue to use basic auth when the datasource is
adding for the first time. It also adds a delay when service is started.
This commit is contained in:
Guillaume Thouvenin 2016-11-02 09:04:42 +01:00
parent 3f044b20d6
commit 22a78bd9b5
2 changed files with 17 additions and 6 deletions

View File

@ -127,12 +127,20 @@ def present(name,
ret['changes'] = None
ret['comment'] = 'Data source {0} already up-to-date'.format(name)
else:
if profile.get('grafana_token', False):
requests.post(
'{0}/api/datasources'.format(profile['grafana_url']),
data,
headers=_get_headers(profile),
timeout=profile.get('grafana_timeout', 3),
)
else:
requests.put(
'{0}/api/datasources'.format(profile['grafana_url']),
data,
auth=_get_auth(profile),
timeout=profile.get('grafana_timeout', 3),
)
ret['result'] = True
ret['comment'] = 'New data source {0} added'.format(name)
ret['changes'] = data

View File

@ -59,6 +59,9 @@ grafana_service:
service.running:
- name: {{ server.service }}
- enable: true
# It is needed if client is trying to set datasource or dashboards before
# server is ready.
- init_delay: 5
- watch:
- file: /etc/grafana/grafana.ini