Skip to content

Fix Elasticsearch API responds unauthorized when using SSL

Summary

When calling any action to secure by SSL Elasticsearch, role fails with Unautorized.

Steps to reproduce

Run for example list action on secured by ssl cluster.

Expected behavior

Action should end with success.

Actual behavior

Task list indices fails.

Relevant logs and/or screenshots

TASK [include_role : elasticsearch] *********************************************************************************************************************************************************************************************
Thursday 06 February 2020  12:34:26 +0100 (0:00:00.816)       0:00:00.835 ***** 

TASK [elasticsearch : list indices] *********************************************************************************************************************************************************************************************
Thursday 06 February 2020  12:34:26 +0100 (0:00:00.030)       0:00:00.866 ***** 
fatal: [localhost]: FAILED! => {"changed": false, "content": "Authentication finally failed", "content_length": "29", "content_type": "text/plain; charset=UTF-8", "elapsed": 0, "msg": "Status code was 401 and not [200]: HTTP Error 401: Unauthorized", "redirected": false, "status": 401, "url": "https://elk02.stg.logs.apl.task.gda.pl:9200/_stats/indexing"}

PLAY RECAP **********************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

Possible fixes

Add force_basic_auth: yes to all tasks that uses elasticsearch password and username in uri module.