elastic/ansible-elasticsearch

GET requests can not have a body.

rs-garrick opened this issue · 1 comments

Updating from 7.10.2 to 7.11.0, ansible started erroring:

TASK [elastic.elasticsearch : List Native Roles] ****************************************************************************************************************************
fatal: [...]: FAILED! => {"changed": false, "content": "{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [GET /_security/role_mapping] does not support having a body"}],"type":"illegal_argument_exception","reason":"request [GET /_security/role_mapping] does not support having a body"},"status":400}", "content_length": "273", "content_type": "application/json; charset=UTF-8", "elapsed": 0, "json": {"error": {"reason": "request [GET /_security/role_mapping] does not support having a body", "root_cause": [{"reason": "request [GET /_security/role_mapping] does not support having a body", "type": "illegal_argument_exception"}], "type": "illegal_argument_exception"}, "status": 400}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "status": 400, "url": "https://localhost:9200/_security/role_mapping"}

The error actually happens in 2 places.

Here's the fix:

diff --git a/ansible/roles/elastic.elasticsearch/tasks/xpack/security/elasticsearch-security-native.yml b/ansible/roles/elastic.elasticsearch/tasks/xpack/security/elasticsearch-security-native.yml
index 9061d90..5f45b4e 100644
--- a/ansible/roles/elastic.elasticsearch/tasks/xpack/security/elasticsearch-security-native.yml
+++ b/ansible/roles/elastic.elasticsearch/tasks/xpack/security/elasticsearch-security-native.yml
@@ -149,7 +149,6 @@
   uri:
     url: "{{ es_api_uri }}/{{ es_security_api }}/role"
     method: GET
-    body_format: json
     user: "{{es_api_basic_auth_username}}"
     password: "{{es_api_basic_auth_password}}"
     force_basic_auth: yes
@@ -220,7 +219,6 @@
   uri:
     url: "{{ es_api_uri }}/{{ es_security_api }}/role_mapping"
     method: GET
-    body_format: json
     user: "{{es_api_basic_auth_username}}"
     password: "{{es_api_basic_auth_password}}"
     force_basic_auth: yes
jmlrt commented

Hi @rs-garrick, thanks for reporting it 👍
This was fixed in #779 before releasing 7.11.1 version of the role.