Skip to content

Commit 928dbec

Browse files
committed
Adding support for JWT auth to vault
In newer versions of nomad you get this warning: ``` agent: Setting a Vault token in the agent configuration is deprecated and will be removed in Nomad 1.9. Migrate your Vault configuration to use workload identity. ``` This PR adds a default idenity section the config if set, so that we don't break older nomad versions.
1 parent c99dfad commit 928dbec

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Add host_volume for nomad client (thanks @ducminhle)
44
- Update CONTRIBUTORS
55
- Update documentation
6+
- Add support for vault identity instead of using a vault_token
67

78
## 1.9.5
89

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,13 @@ in many Ansible versions, so this feature might not always work.
584584

585585
### `nomad_vault_create_from_role`
586586

587-
- Role to create tokens from
587+
- Role to create tokens from, is is a legacy setting since the prefered way to configuring it is using workload identity.
588+
- Default value: **""**
589+
590+
### `nomad_vault_default_identity`
591+
592+
- Authenticate using a JWT aud bound policy, this is the prefered way of linking nomad to vault, see the [docs](https://developer.hashicorp.com/nomad/tutorials/integrate-vault/vault-acl)
593+
To use this config set it to `vault.io` for example, default is it disabled.
588594
- Default value: **""**
589595

590596
### `nomad_vault_ca_file`

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ nomad_vault_enabled: "{{ lookup('env', 'NOMAD_VAULT_ENABLED') | default('no', tr
166166
nomad_vault_address: "{{ vault_address | default('0.0.0.0', true) }}"
167167
nomad_vault_allow_unauthenticated: true
168168
nomad_vault_create_from_role: ""
169+
nomad_vault_default_identity: ""
170+
nomad_vault_default_identity_ttl: "1h"
169171
nomad_vault_task_token_ttl: ""
170172
nomad_vault_ca_file: ""
171173
nomad_vault_ca_path: ""

templates/base.hcl.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,22 @@ vault {
7474
enabled = {{ nomad_vault_enabled | bool | lower }}
7575
address = "{{ nomad_vault_address }}"
7676
allow_unauthenticated = {{ nomad_vault_allow_unauthenticated | bool | lower }}
77+
{%if nomad_vault_create_from_role != "" %}
7778
create_from_role = "{{ nomad_vault_create_from_role }}"
79+
{% endif %}
7880
task_token_ttl = "{{ nomad_vault_task_token_ttl }}"
7981
ca_file = "{{ nomad_vault_ca_file }}"
8082
ca_path = "{{ nomad_vault_ca_path }}"
8183
cert_file = "{{ nomad_vault_cert_file }}"
8284
key_file = "{{ nomad_vault_key_file }}"
8385
tls_server_name = "{{ nomad_vault_tls_server_name }}"
8486
tls_skip_verify = {{ nomad_vault_tls_skip_verify | bool | lower }}
87+
{%if nomad_vault_default_identity != "" %}
88+
default_identity {
89+
aud = ["{{ nomad_vault_default_identity }}"]
90+
ttl = "{{ nomad_vault_default_identity_ttl }}"
91+
}
92+
{% endif %}
8593
{%if nomad_node_role != 'client' %}
8694
token = "{{ nomad_vault_token }}"
8795
{% endif %}

0 commit comments

Comments
 (0)