Hello!
I have a job for which the docker image revision is stored in consul. I can’t figure out how to get it to work.
Hello!
I have a job for which the docker image revision is stored in consul. I can’t figure out how to get it to work.
job "test-job" {
datacenters = ["nomad"]
type = "service"
group "group" {
count = 1
task "task" {
driver = "docker"
config {
image = "mysql:{{key "some/consul/path/to/Revision"}}"
}
}
}
}
When I run this job I get the following error:
Parse Error
input.hcl:9,33-37: Missing newline after argument; An argument definition must end with a newline.
It’s clearly unhappy about the quotes within quotes.
So I tried this,
job "test-job" {
datacenters = ["nomad"]
type = "service"
group "group" {
count = 1
task "task" {
driver = "docker"
config {
image = "mysql:${env.Revision}"
}
template {
data = <<EOH
Revision = "{{key "some/consul/path/to/Revision"}}"
EOH
destination = "secrets/file.env"
env = true
}
}
}
}
Suddenly I can read from Consul and use it for the image revision, but this seems convoluted. What’s more if I want to use vault ( secret instead of key ) what happens ? If there is a secret, is it going to be exposed to the user space environment when it’s part of the job ?
I understand the syntax is different inside a template stanza, but I don’t understand how to do the consul lookup in the image field ( or auth or any other field inside of config ) .
Can someone point me in the right direction please?
Thanks,
David