Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nomad needs to be vault integrated in order to use vault interpolations in jobs. #380

Closed
oschistad opened this issue Oct 7, 2020 · 4 comments · Fixed by #383
Closed
Labels
type/documentation Improvements or additions to documentation type/enhancement New feature or request
Milestone

Comments

@oschistad
Copy link
Contributor

oschistad commented Oct 7, 2020

Vagrant-hashistack needs to be a good simulacrum of the runtime environment in production, and this includes proper secrets management using vault. The target environment will rely on nomad being able to interpolate secrets and place them in the environment or config files of the application, and trigger on changes by restarting the job if necessary.

This means that Nomad needs to be pre-integrated with vault, and have a token associated with a policy with sufficient privileges. A good starting point is https://learn.hashicorp.com/tutorials/nomad/vault-postgres - full docs are at https://www.nomadproject.io/docs/integrations/vault-integration

Summarized, the following should be sufficient:

  • Create a nomad-server policy in Vault
  • create a role mapping to nomad-server policy
  • During box startup, generate a token associated with nomad role
  • Add a vault stanza to the nomad config file, including vault token generated.
  • Add a test for a nomad-job interacting with vault - a simple KV lookup in secrets/ should be sufficient.
@oschistad
Copy link
Contributor Author

All that being said, the following addition to /etc/nomad.d/0_config.hcl should be sufficient to generate vault tokens and read secrets in a nomad job:

vault {
  enabled = true
  token = "master"
  address = "http://127.0.0.1:8200"
}

@oschistad oschistad changed the title Nomad needs to be vault integrated in order to use vault templating in jobs. Nomad needs to be vault integrated in order to use vault interpolations in jobs. Oct 7, 2020
@zhenik
Copy link
Contributor

zhenik commented Oct 7, 2020

@zhenik zhenik added the type/question Further information is requested label Oct 7, 2020
@oschistad
Copy link
Contributor Author

@zhenik Eventually we need to use the same policies in vagrant as in the real environment, but a good start is to simply use the master token as shown above. This will tide us over nicely until such a time as we have a working least required privilege policy for Nomad, which is likely to be a few weeks out.

@zhenik
Copy link
Contributor

zhenik commented Oct 7, 2020

@oschistad we are working on it, hopefully, next week come with an example
https://github.com/fredrikhgrelland/vagrant-hashistack-template/issues/33

Sorry for the misunderstanding, it relates to https://www.nomadproject.io/docs/integrations/vault-integration

@zhenik zhenik added type/documentation Improvements or additions to documentation type/enhancement New feature or request and removed type/question Further information is requested labels Oct 7, 2020
@zhenik zhenik linked a pull request Oct 8, 2020 that will close this issue
@zhenik zhenik added this to the 0.5.0 milestone Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/documentation Improvements or additions to documentation type/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants