Last active
September 21, 2016 18:32
-
-
Save patrickmslatteryvt/f4110ae8130f53dce01ad2ce70e9d711 to your computer and use it in GitHub Desktop.
Ansible URI module issue with multiple data objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This works | |
- name: "Set the Couchbase cluster security settings" | |
shell: "curl -v -X POST http://{{ couchbase_host }}:{{ couchbase_cluster_port }}/settings/web \ | |
-d port={{ couchbase_cluster_port }} \ | |
-d username={{ couchbase_cluster_username }} \ | |
-d password={{ couchbase_cluster_password }}" | |
# This does not: | |
- name: "Set the Couchbase cluster security settings" | |
uri: | |
url: http://{{ couchbase_host }}:{{ couchbase_cluster_port }}/settings/web | |
method: POST | |
user: "{{ couchbase_cluster_username }}" | |
password: "{{ couchbase_cluster_password }}" | |
body: | |
port={{ couchbase_cluster_port }} | |
username={{ couchbase_cluster_username }} | |
password={{ couchbase_cluster_password }} | |
force_basic_auth: no | |
status_code: 200 | |
body_format: raw | |
# and returns: | |
{ | |
"cache_control": "no-cache", | |
"changed": false, | |
"content": "[\"All parameters must be given\"]", | |
"content_length": "32", | |
"content_type": "application/json", | |
"date": "Wed, 21 Sep 2016 17:08:49 GMT", | |
"failed": true, | |
"json": ["All parameters must be given"], | |
"msg": "Status code was not [200]: HTTP Error 400: Bad Request", | |
"pragma": "no-cache", | |
"redirected": false, | |
"server": "Couchbase Server", | |
"status": 400, | |
"url": "http://127.0.0.1:8091/settings/web" | |
} | |
# Also tried with: | |
body_format: json | |
HEADER_Content-Type: application/json | |
# That does not work either. | |
# This works | |
# POST /settings/web | |
# This command can be run only _ONCE_ against each Couchbase node, if you try it a second time you will get a HTTP 401 Unauthorized error | |
- name: "Set the Couchbase cluster security settings" | |
uri: | |
url: http://{{ couchbase_host }}:{{ couchbase_cluster_port }}/settings/web | |
method: POST | |
user: "{{ couchbase_cluster_username }}" | |
password: "{{ couchbase_cluster_password }}" | |
body: username={{ couchbase_cluster_username }}&password={{ couchbase_cluster_password }}&port={{ couchbase_cluster_port }} | |
force_basic_auth: no | |
status_code: 200 | |
body_format: raw | |
when: couchbase_service_status.state == 'started' | |
register: hostname_result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment