Generate Nomad tokens with HashiCorp Vault
HashiCorp Vault has a secrets engine for generating short-lived Nomad tokens. As Vault has a number of authentication backends, it could provide a workflow where a user or orchestration system authenticates using an pre-existing identity service (LDAP, Okta, Amazon IAM, etc.) in order to obtain a short-lived Nomad token.
HashiCorp Vault is a standalone product with its own set of deployment and configuration best practices. You should review the [Vault Deployment Guide] before deploying it in production.
In order to configure Vault's Nomad secrets engine, you will need the following:
A Nomad cluster with bootstrapped ACL system.
A management token (You can use the bootstrap token; however, for production systems you should use an integration-specific token)
A set of policies created in Nomad
An unsealed Vault server running v0.9.3 or later
For evaluation purposes, a Vault server in "dev" mode can be used.
Configure Nomad secrets engine
Enable the nomad
secrets backend in Vault:
For older versions of Vault, you might need to use the vault mount
command instead.
Once you have the Nomad secret backend enabled, configure access with Nomad's address and management token:
Vault secrets engines have the concept of roles, which are configuration units that group one or more Vault policies to a potential identity attribute, (e.g. LDAP Group membership). The name of the role is specified on the path, while the mapping to policies is done by naming them in a comma separated list, for example:
Similarly, to create management tokens, or global tokens:
Create Vault policy
Create a Vault policy to allow different identities to get tokens associated with a particular role:
If you have an existing authentication backend (like LDAP), follow the relevant instructions to create a role available on the Authentication backends page. Otherwise, for testing purposes, a Vault token can be generated associated with the policy:
Obtain and test Nomad token
Finally obtain a Nomad Token using the existing Vault Token:
Verify that the token is created correctly in Nomad, looking it up by its accessor:
Any user or process with access to Vault can now obtain short lived Nomad Tokens in order to carry out operations, thus centralizing the access to Nomad tokens.