Skip to content

Commit

Permalink
Fix Vault E2E TLS config (#11483)
Browse files Browse the repository at this point in the history
* Update e2e/terraform configuration for Vault and default to mtls=true
  • Loading branch information
DerekStrickland authored Dec 2, 2021
1 parent 189806f commit bfac8d8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ plugin "nomad-driver-ecs" {
}

vault {
enabled = true
address = "http://active.vault.service.consul:8200"
enabled = true
address = "http://active.vault.service.consul:8200"
}
9 changes: 9 additions & 0 deletions e2e/terraform/config/shared/nomad-tls.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ consul {
cert_file = "/etc/nomad.d/tls/agent.crt"
key_file = "/etc/nomad.d/tls/agent.key"
}

vault {
enabled = true
address = "https://active.vault.service.consul:8200"

ca_file = "/etc/nomad.d/tls/ca.crt"
cert_file = "/etc/nomad.d/tls/agent.crt"
key_file = "/etc/nomad.d/tls/agent.key"
}
6 changes: 5 additions & 1 deletion e2e/terraform/provision-nomad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ resource "null_resource" "upload_configs" {

}

// TODO: Create separate certs.
// This creates one set of certs to manage Nomad, Consul, and Vault and therefore
// puts all the required SAN entries to enable sharing certs. This is an anti-pattern
// that we should clean up.
resource "null_resource" "generate_instance_tls_certs" {
count = var.tls ? 1 : 0
depends_on = [null_resource.upload_configs]
Expand Down Expand Up @@ -180,7 +184,7 @@ openssl req -newkey rsa:2048 -nodes \
cat <<'NEOY' > keys/agent-${var.instance.public_ip}.conf
subjectAltName=DNS:${local.tls_role}.global.nomad,DNS:${local.tls_role}.dc1.consul,DNS:localhost,DNS:${var.instance.public_dns},IP:127.0.0.1,IP:${var.instance.private_ip},IP:${var.instance.public_ip}
subjectAltName=DNS:${local.tls_role}.global.nomad,DNS:${local.tls_role}.dc1.consul,DNS:localhost,DNS:${var.instance.public_dns},DNS:vault.service.consul,DNS:active.vault.service.consul,IP:127.0.0.1,IP:${var.instance.private_ip},IP:${var.instance.public_ip}
extendedKeyUsage = serverAuth, clientAuth
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
Expand Down
5 changes: 4 additions & 1 deletion e2e/terraform/scripts/bootstrap-vault.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ NOMAD_VAULT_TOKEN=$(vault token create -policy nomad-server -period 72h -orphan
cat <<EOF > "${DIR}/../keys/nomad_vault.hcl"
vault {
enabled = true
address = "http://active.vault.service.consul:8200"
address = "https://active.vault.service.consul:8200"
task_token_ttl = "1h"
create_from_role = "nomad-cluster"
token = "$NOMAD_VAULT_TOKEN"
ca_file = "/etc/vault.d/tls/ca.crt"
cert_file = "/etc/vault.d/tls/agent.crt"
key_file = "/etc/vault.d/tls/agent.key"
}
EOF
2 changes: 1 addition & 1 deletion e2e/terraform/terraform.full.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nomad_enterprise = true
nomad_acls = true
vault = true
volumes = true
tls = false
tls = true

# required to avoid picking up defaults from terraform.tfvars file
nomad_version = "" # default version for deployment
Expand Down

0 comments on commit bfac8d8

Please sign in to comment.