{
"SourcePath": "",
"DestPath": "local/consul.env",
"EmbeddedTmpl": "{{ with secret \"consul/creds/socat-role\" }}CONSUL_HTTP_TOKEN={{ .Data.token }}\nSTAR_SOCAT_CONSUL_TOKEN={{ .Data.token }}\n{{ end }}",
"ChangeMode": "restart",
"ChangeSignal": "",
"Splay": 5000000000,
"Perms": "0600",
"LeftDelim": "{{",
"RightDelim": "}}",
"Envvars": true,
"VaultGrace": 15000000000
}, {
"SourcePath": "",
"DestPath": "local/tokenx.env",
"EmbeddedTmpl": "{{ or (env \"CONSUL_HTTP_TOKEN\") \"12345\" }}",
"ChangeMode": "restart",
"ChangeSignal": "",
"Splay": 5000000000,
"Perms": "0600",
"LeftDelim": "{{",
"RightDelim": "}}",
"Envvars": false,
"VaultGrace": 15000000000
}
I’ve two template stanzas in my nomad job as shown above. The first one generates a consul token from secret store and in the second one I want to use the env var set by the first template. However since env function is non blocking (from what I understand) the second template always gets no value (if default is not provided) or default.
I’m wondering if there is a better way to handle such a case?