How would you translate this curl
request to the ansible uri module?
curl -G http://localhost:8086/query?u=admin&p=password \
--data-urlencode "q=SHOW databases"
I don't know how or were to put the --data-urlencode
part
This is what I have so far (not working):
- name: Create influx users with POST
uri:
url: "http://localhost:8086/query/?u=admin&p=password"
method: GET
body: "q=SHOW databases"
And the error I get is:
"error": "missing required parameter \"q\""
The following however, works:
- name: Create influx users with POST
uri:
url: "http://localhost:8086/ping"
method: GET
status_code: 204
EDIT: final working solution
This working example will show you the current users of your influxdb
- name: Create influx users with POST
uri:
url: "http://localhost:8086/query?q={{'SHOW USERS '|urlencode}}"
method: GET
user: admin
password: password
There is a urlencode filter in Jinja...but there is another problem. A GET
request doesn't have a body; when you run:
curl -G 'http://localhost:8086/query?u=admin&p=password' --data-urlencode "q=SHOW databases"
What actually happens is:
GET /query?u=admin&p=password&q=SHOW%20databases
So you would need to rewrite your task like this:
- name: Create influx users with POST
uri:
url: "http://localhost:8086/query/?u=admin&p=password?{{ 'q=SHOW databases'|urlencode }}"
method: GET
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With