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:
parent
3f044b20d6
commit
22a78bd9b5
2 changed files with 17 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue