Hi,
I want to build a dynamic Nomad job for Traefik, so that it will read out all the certificate data from Vault.
I already have it working with static declarations, but now I want to make this job completely dynamic, but now am facing the problem that I can’t find a way to make the template destination dynamic:
template {
data = <<EOF
tls:
certificates:
{{ range secrets "secret/metadata/ssl-certificates/" }}
- certFile: /etc/traefik/ssl/{{ (printf "%s" .) }}.crt
keyFile: /etc/traefik/ssl/{{ (printf "%s" .) }}.key
{{ end }}
EOF
destination = "local/rules/ssl.yml"
}
template {
data = <<EOF
{{ range secrets "secret/metadata/ssl-certificates/" }}
{{ with secret (printf "secret/ssl-certificates/%s/private_key" .) }}{{ .Data.data.value }}{{ end }}
{{ end }}
EOF
destination = "local/ssl/tls.key"
}
template {
data = <<EOF
{{ range secrets "secret/metadata/ssl-certificates/" }}
{{ with secret (printf "secret/ssl-certificates/%s/certificate" .) }}{{ .Data.data.value }}{{ end }}
{{ end }}
EOF
destination = "local/ssl/tls.crt"
}
In the above snippet, I want to save the specific certificate to local/ssl/<secret_name>.crt
and local/ssl/<secret_name>.key
.
Is there a way for this to be possible?