From 5bbb9f23e08e267ff83e007bb753e767d98ab692 Mon Sep 17 00:00:00 2001 From: Guillaume Thouvenin Date: Wed, 2 Nov 2016 15:48:12 +0100 Subject: [PATCH 1/2] Use POST instead of PUT when adding a new datasource --- _states/grafana3_datasource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_states/grafana3_datasource.py b/_states/grafana3_datasource.py index dbb3312..7d440ae 100644 --- a/_states/grafana3_datasource.py +++ b/_states/grafana3_datasource.py @@ -135,7 +135,7 @@ def present(name, timeout=profile.get('grafana_timeout', 3), ) else: - requests.put( + requests.post( '{0}/api/datasources'.format(profile['grafana_url']), data, auth=_get_auth(profile), From eed48db1721a27a35211b5447e9f21cfb4f6479a Mon Sep 17 00:00:00 2001 From: Guillaume Thouvenin Date: Wed, 2 Nov 2016 15:50:17 +0100 Subject: [PATCH 2/2] Use the right parameters to configure datasource This patch uses the user and password instead of setting basic auth that is used as credentials when connecting to the Grafana server. In our case we are using the grafana configuration on the minion to connect to Grafana. This patch also adds an option to set the datasource as the default one. --- grafana/client.sls | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/grafana/client.sls b/grafana/client.sls index 67a7c07..07c842f 100644 --- a/grafana/client.sls +++ b/grafana/client.sls @@ -19,9 +19,14 @@ grafana_client_datasource_{{ datasource_name }}: - access: proxy {%- endif %} {%- if datasource.user is defined %} - - basic_auth: true - - basic_auth_user: {{ datasource.user }} - - basic_auth_password: {{ datasource.password }} + - user: {{ datasource.user }} + - password: {{ datasource.password }} + {%- endif %} + {%- if datasource.get('is_default', false) %} + - is_default: {{ datasource.is_default }} + {%- endif %} + {%- if datasource.database is defined %} + - database: {{ datasource.database }} {%- endif %} {%- endfor %}