Passing a value to nomad from Consul kv

fetch the information from Consul and then submit this job to Nomad, injecting the Consul k/v value as an environment variable.

like for example i have a value in consul k/v which is

testData = "HELLO"

on the other hand, in my job.

i want the value from consul k/v to be injected to env stanza as a value.

env
CONSUL_test = <value of consul k/v testData>

is this possible?

so that when i inspect the docker env, i must see
CONSUL_test = HELLO

You can use the template stanza for this, with the option env = true

CONSUL_test={{ key "testData" }}
1 Like