How to use variables from template section in other sections


I am completly new to this and currently confused with the docu. Maybe someone could help me to understand how this is working :slight_smile:

We are currently using vault, nomad and consul to deploy our artefacts given from an artifactory storage in areas where kubernetes isn’t in use.

Since downloading the artefact needs credentials I created a nomad file with a template section to get the credentials (user and password) from vault. It is working fine if I want to put them into a file to use them with my artefact.

But how can I use the variables in the artefact section to auth. agains our system to download the artefact?

I didn’t fin any example of the usage of vars from template in the tutorials.

template {
data = <<EOF
art_user: {{ with secret "kv/data/artifactory/account" }}{{}}{{end}}
art_pass: {{ with secret "kv/data/artifactory/account" }}{{}}{{end}}
destination = "secure/artifactory.yml"

How do I use them here?

artifact {
source      = "https://${key art_user}:${key art_pass}@server.local/folder/folder/archiv.tar.gz"
destination = "local"

Hi @WizoneDE,

Unfortunately I think that this is currently not possible, checkout this issue for more details.

There’s a workaround described there as well, which is to use a template to render a script that will download the file.

It’s definitively not ideal, but I hope it helps for now.