hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.81k stars 1.94k forks source link

Either mention the NOMAD_TOKEN env var or automatically export NOMAD_TOKEN as part of ACL bootstrapping #10272

Open DingoEatingFuzz opened 3 years ago

DingoEatingFuzz commented 3 years ago

Proposal

Either mention the NOMAD_TOKEN env var or automatically export NOMAD_TOKEN as part of nomad acl bootstrap

$ nomad acl bootstrap
Accessor ID  = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Secret ID    = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Name         = Bootstrap Token
Type         = management
Global       = true
Policies     = n/a
Create Time  = 2021-03-31 17:08:45.468415 +0000 UTC
Create Index = 10
Modify Index = 10

Local envvar NOMAD_TOKEN has been set to Secret ID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Or

$ nomad acl bootstrap
...snipped...

To continue using Nomad, run
export NOMAD_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Use-cases

This is a missed opportunity to teach the ACL system inline rather than relying on guides/docs.

lgfa29 commented 1 year ago

Modifying the current shell by exporting a variable is not possible, so printing the message would be way to go and it provides user two important information: what is the expected environment variable name and which value they should set.

15894 discusses adding -json and -t to commands. When these flags are used the NOMAD_TOKEN message should not displayed. With a structure output option users will be able to modify their current shell session by doing something like:

$ eval "export NOMAD_TOKEN=$(nomad acl bootstrap -json | jq ".SecretID")"

Setting an environment variable is also OS specific, so instead of providing an exact command to run (which may not work for the user), the message should explain in broad terms that a NOMAD_TOKEN environment variable should be set.