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['changes'] = None
|
||||||
ret['comment'] = 'Data source {0} already up-to-date'.format(name)
|
ret['comment'] = 'Data source {0} already up-to-date'.format(name)
|
||||||
else:
|
else:
|
||||||
requests.post(
|
if profile.get('grafana_token', False):
|
||||||
'{0}/api/datasources'.format(profile['grafana_url']),
|
requests.post(
|
||||||
data,
|
'{0}/api/datasources'.format(profile['grafana_url']),
|
||||||
headers=_get_headers(profile),
|
data,
|
||||||
timeout=profile.get('grafana_timeout', 3),
|
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['result'] = True
|
||||||
ret['comment'] = 'New data source {0} added'.format(name)
|
ret['comment'] = 'New data source {0} added'.format(name)
|
||||||
ret['changes'] = data
|
ret['changes'] = data
|
||||||
|
|
|
@ -59,6 +59,9 @@ grafana_service:
|
||||||
service.running:
|
service.running:
|
||||||
- name: {{ server.service }}
|
- name: {{ server.service }}
|
||||||
- enable: true
|
- enable: true
|
||||||
|
# It is needed if client is trying to set datasource or dashboards before
|
||||||
|
# server is ready.
|
||||||
|
- init_delay: 5
|
||||||
- watch:
|
- watch:
|
||||||
- file: /etc/grafana/grafana.ini
|
- file: /etc/grafana/grafana.ini
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue