I don’t know if this is a Vault question or Nomad question, but I’m trying here. Admins, feel free to move this over.
Based on the docs here: Vault Integration and Retrieving Dynamic Secrets | Nomad - HashiCorp Learn I think I’m doing things correctly…but could be way off.
I have a vault policy like so:
path "kv-v2/db" {
capabilities = ["read"]
}
I add that to vault like so:
vault policy write db /ops/shared/config/db-policy.hcl
My Nomad servers have a valid vault token which was created using the steps in the doc link above. The token was put in the environment, and then Nomad was started.
My jobs have this stanza in the top level:
vault {
policies = ["db"]
change_mode = "signal"
change_signal = "SIGUSR1"
}
My template in the job is this:
template {
data = <<EOT
{{ with secret "kv-v2/db" }}
POSTGRES_USER="{{ .Data.data.user }}"
POSTGRES_PASSWORD="{{ .Data.data.pass | toJSON }}"
{{ end }}
EOT
destination = "db.env"
env = true
}
From the docs, it looks like I’m doing everything right, but when I run my jobs, they fail to run, and I get this error in the Nomad console:
Missing: vault.read(kv-v2/db)
I created the ‘db’ policy, which allows reads to kv-v2/db, and I put the ‘db’ policy in the vault stanza for the job…but it’s not working.
Any hints? Please feel free to point me to the paragraph(s) in the documentation I have missed.
Thank you!