Reset password api

Hi
i am installing elk stack using ansible playbook. I am able to set password using elasticsearch-reset-password for all users manually, from command line. How can i do the same using the playbook? if i run this command from playbook it will expect a password, i want to specify the password in the command itself. can i do it using curl command?

curl -X POST "localhost:9200/_security/user/elastic/_password?pretty" -H 'Content-Type: application/json' -d'
{
  "password" : "test"
}'

tried this but getting a 401 error

There is no API equivalent for the elasticsearch-reset-password tool. For API calls, you always need first authenticate. In your case, this means you need the initial password of the elastic user. You can find it in the elasticsearch.keystore file and it can be shown with the following command

./bin/elasticsearch-keystore show keystore.seed

But this requires running a command line tool. At this point, you might be better off just using the elasticsearch-reset-password CLI.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.