Skip to content

cli: add -kv-path flag to nomad setup vault#28183

Open
eyupcanakman wants to merge 1 commit into
hashicorp:mainfrom
eyupcanakman:feat/setup-vault-kv-path
Open

cli: add -kv-path flag to nomad setup vault#28183
eyupcanakman wants to merge 1 commit into
hashicorp:mainfrom
eyupcanakman:feat/setup-vault-kv-path

Conversation

@eyupcanakman

Copy link
Copy Markdown

Description

nomad setup vault generates the nomad-workloads policy with the KV secrets engine mount hardcoded to "secret". Clusters that mount their KV engine somewhere else, like at kv, have to hand-edit the generated policy before it works. The new -kv-path flag sets the mount the policy scopes and defaults to "secret", so runs that leave it off are unchanged.

The flag value replaces the "secret" mount in the embedded policy template, alongside the existing JWT accessor substitution, and the interactive description reflects it too. Passing -kv-path kv scopes the policy under kv/ instead of secret/. An empty or slash-only value is rejected before the command touches Vault.

jrasell confirmed on the issue that a configurable KV path makes sense.

Testing & Reproduction steps

TestSetupVaultCommand_renderVaultPolicy checks that the default mount leaves the policy byte-for-byte unchanged and that a few custom mounts rewrite all four path blocks. TestSetupVaultCommand_Run_emptyKVPath covers the empty-value guard.

I also ran the command against a Vault dev server. With no flag the created policy scopes secret/data as before, and with -kv-path kv it scopes kv/data.

Links

Closes #27915

AI usage

Per contributing/ai.md: I used an AI coding assistant while writing the flag wiring, the renderVaultPolicy helper, and the tests. I reviewed every line, confirmed the default output is unchanged, and verified the generated policy against a local Vault dev server.

@eyupcanakman eyupcanakman requested review from a team as code owners June 26, 2026 13:37
The setup vault command hardcoded the Vault KV mount to "secret" in the
generated nomad-workloads policy. Add a -kv-path flag (default "secret")
that sets the mount the policy scopes, and reject an empty value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

add flag -kvpath to nomad setup vault

2 participants