Cannot pass consul kv to nomad job

I wanted to pass some consul key-value pairs to my nomad job and this is the template from the documentation that I’ve tried to use on my nomad job.

  template {
    data = <<EOF
        {{range ls "app/test"}}
        {{.Key}}={{.Value}}
        {{end}}
    EOF
        destination = "env/file.env"
        env = true
  }

I’m not getting the consul kv even though the nomad job is running without any errors. Are there other configurations on the job or perhaps on the setup that I might have missed?

Hi @lalin,

The template looks OK from an initial standpoint. Could you query that path on Consul directly using consul kv get app/test and copy the output?

Thanks,
jrasell and the Nomad team

Here is the result:
Error! No key exists at: app/test

But when I try consul kv get -recurse app/test I get this:

app/test/:
app/test/APP_NAME:consul
app/test/TEST_KEY:123

Isn’t the template used to retrieve multiple kv inside app/test?