Hello, I’ve successfully used this template before to retrieve secrets from vault to nomad on a vm.
template {
data = <<EOF
{{ with secret "test/data/sample" }}
{{ range $k, $v := .Data.data }}
{{ $k }} = {{ $v }}{{ end }}{{ end }}
EOF
destination = "test/vault.env"
env = true
}
But, when I tried using it on gitlab, I got this error instead.
Template failed: (dynamic): parse: template: :2: unexpected "," in range
I was thinking that since these $k
& $v
are similar to variables, maybe they were the cause of the problem. Hence, this is my current template:
template {
data = <<EOF
{{ with secret "test/data/sample" }}
{{ range ${VAULT_KEY}, ${VAULT_VALUE} := .Data.data }}
{{ ${VAULT_KEY} }} = {{ ${VAULT_VALUE} }}{{ end }}{{ end }}
EOF
destination = "test/vault.env"
env = true
}
Yet, I’m still getting the same error.
I’ve already check the previous vm and it still works there. How can I resolve this error?