Automation adding the password for basic security step #2 in Elasticsearch 7

How can I automate step 2 and pass a password to the following 2 commands?

./bin/elasticsearch-keystore add

./bin/elasticsearch-keystore add

Hi @Chuck_Reynolds
Did you look at this?

To pass the settings values through standard input (stdin), use the --stdin flag:

cat /file/containing/setting/value | bin/elasticsearch-keystore add --stdin

Values for multiple settings must be separated by carriage returns or newlines.

I didn't but it doesn't really make sense to me.

Step 2 says:

If you entered a password when creating the node certificate, run the following commands to store the password in the Elasticsearch keystore:

then it tells you to enter the following command which prompts you for a password.

I would expect to run the command like this.

./bin/elasticsearch-keystore add password:password123

but that doesn't work.

I need to use ansible to automate this part of the basic security so I need to have away to pass the password with the command.

echo or write the password into a file then cat via stdin as shown... that is your only option at the moment...

When you say

What is the setting name?

in your example

echo -e "thepassword" > pw.txt
cat ./pw.txt | bin/elasticsearch-keystore add --stdin

That should work I just tested it, that is bash... whatever is the equivalent in ansible

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