Struggling with TLS on Elasticsearch [Ansible]

Hello everyone,

I am currently deploying an Elastic Stack on Azure VM's using Ansible. The installation of the components was ofcourse a walk in the park, but I can't seem to get TLS to work properly. Whenever I try to run my playbooks, the Elasticsearch services refuses to start, resulting in a fatal error like so;

TASK [Enable and restart elasticsearch] **********************************************************************************************************************************************************************************************
fatal: [52.232.35.228]: FAILED! => {"changed": false, "msg": "Unable to start service elasticsearch: Job for elasticsearch.service failed because the control process exited with error code.\nSee \"systemctl status elasticsearch.service\" and \"journalctl -xeu elasticsearch.service\" for details.\n"}

PLAY RECAP ***************************************************************************************************************************************************************************************************************************
52.232.35.228              : ok=16   changed=5    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 

After some more investigation, I found out Elasticsearch faild to bind service as shown below;

[2025-05-19T12:06:26,352][ERROR][o.e.b.Elasticsearch      ] [52.232.35.228] fatal exception while booting Elasticsearchorg.elasticsearch.ElasticsearchException: Failed to bind service
        at org.elasticsearch.server@9.0.1/org.elasticsearch.node.NodeConstruction.prepareConstruction(NodeConstruction.java:308)
        at org.elasticsearch.server@9.0.1/org.elasticsearch.node.Node.<init>(Node.java:185)
        at org.elasticsearch.server@9.0.1/org.elasticsearch.bootstrap.Elasticsearch$2.<init>(Elasticsearch.java:426)
        at org.elasticsearch.server@9.0.1/org.elasticsearch.bootstrap.Elasticsearch.initPhase3(Elasticsearch.java:426)
        at org.elasticsearch.server@9.0.1/org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:102)

See logs for more details.

ERROR: Elasticsearch did not exit normally - check the logs at /usr/share/elasticsearch/logs/elasticsearch-cluster.log

ERROR: Elasticsearch died while starting up, with exit code 1

I'm not really sure what's going wrong here, is there anyone who has experienced this before or someone who has a solution? If any more context is needed, i'd be glad to provide this.

-Harmen

Fixed it, Elasticsearch Data folder was missing.