Username and password-based enrollment - "environment variable VAR_NAME does not exist"

I am working on an automated deployment of filebeat, and one of the steps is to enroll the beat.

As per the documentation, to have this process scripted, I need to use 'Username and password-based enrollment', where the chosen method is env:VAR.

I am on CentOS 7, and these are the steps I take:

  1. export beats_pass=some_password
  2. sudo filebeat enroll KIBANA_URL --username USER --password env:beats_pass

The result is:
"environment variable beats_pass does not exist"

Doing export -p confirms the environment variable is registered.

What am I doing wrong?


With a workaround. Just set the "environment variable" as you do the sudo enroll, like so:

sudo BEATS_PASS=some_password filebeat enroll KIBANA_URL --username USER --password env:BEATS_PASS --force

PS: If you get 'empty_access token' when using the --force flag, remove contents of /var/lib/filebeat/.

Thank you for posting the solution! :smiley: