Elasticsearch 6.3: elasticsearch-keystore add not accepting stdin

We had some Ansible automation break when going to Elasticsearch 6.3. The ./elasticsearch-keystore add command now prompts before overwriting a value. I've attempted to suppress this using the --stdin and --silent flags to no avail. Any suggestions?

printf value | ./elasticsearch-keystore add --stdin bootstrap.password --silent

results in the following:

"stderr_lines": [
    "Exception in thread \"main\" java.lang.IllegalStateException: unable to read from standard input; is standard input open and a tty attached?",
    "\tat org.elasticsearch.cli.Terminal$SystemTerminal.readText(Terminal.java:168)",
    "\tat org.elasticsearch.cli.Terminal.promptYesNo(Terminal.java:101)",
    "\tat org.elasticsearch.common.settings.AddStringKeyStoreCommand.execute(AddStringKeyStoreCommand.java:78)",
    "\tat org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)",
    "\tat org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)",
    "\tat org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:79)",
    "\tat org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)",
    "\tat org.elasticsearch.cli.Command.main(Command.java:90)",
    "\tat org.elasticsearch.common.settings.KeyStoreCli.main(KeyStoreCli.java:41)"

The command line arguments for add in 6.3.0 can be retrieved with

./elasticsearch-keystore add -h

which shows

Add a string setting to the keystore

Non-option arguments:
setting name

Option             Description
------             -----------
-E <KeyValuePair>  Configure a setting
-f, --force        Overwrite existing setting without prompting
-h, --help         show help
-s, --silent       show minimal output
-v, --verbose      show verbose output
-x, --stdin        Read setting value from stdin

So to overwrite an existing value using input from stdin would be something like

echo "secret value" | ./elasticsearch-keystore add -xf
1 Like

Thanks Russ, too easy :slight_smile:

1 Like

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