From 56879dfcb2ce05affe88260cb6c8bfa61c1850a9 Mon Sep 17 00:00:00 2001 From: akrzos Date: Thu, 1 Jun 2017 15:56:51 -0400 Subject: [PATCH] Revert Ansible URI module in favor of curl. I can not get the URI module does not seem to work even with "force_basic_auth" vs just using curl while POST-ing a new datasource into Grafana API. Change-Id: Ice644fe9293bee667d75dbbd09a73eaee40cd8e6 --- ansible/install/roles/grafana/tasks/main.yml | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ansible/install/roles/grafana/tasks/main.yml b/ansible/install/roles/grafana/tasks/main.yml index 7f0f20a60..b25fd7a88 100644 --- a/ansible/install/roles/grafana/tasks/main.yml +++ b/ansible/install/roles/grafana/tasks/main.yml @@ -138,13 +138,20 @@ # # Add graphite server as a default datasource # -- name: Create Data Source on grafana server - uri: - method: POST - header: 'Content-Type: application/json' - body: "{{ lookup('template', 'data_source.json.j2') |to_json }}" - body_format: json - url: http://{{grafana_host}}:{{grafana_port}}/api/datasources - username: "{{ grafana_username }}" - password: "{{ grafana_password }}" +# (akrzos) I reverted this back to the "old" way after testing Ansible 2.3.0.0 +# which still could not POST with basic auth through uri vs curl command. +- name: Create data_source.json + template: + src: data_source.json.j2 + dest: "{{role_path}}/files/data_source.json" + connection: local + +- name: Create Data Source on grafana server + command: "curl -X POST -H 'Content-Type: application/json' -d @{{role_path}}/files/data_source.json http://{{grafana_username}}:{{grafana_password}}@{{grafana_host}}:{{grafana_port}}/api/datasources" + connection: local + tags: + - skip_ansible_lint + +- name: Remove leftover json file + file: path={{role_path}}/files/data_source.json state=absent connection: local