Hello. Currently there is no method to keep template source data and nomad.job in separate files. The only way to do this is to run some kind of preprocessing before. I think that some kind of "local_source" should be implemented for template option, i think i can create PR for this feature but would like to know first if this funtion will be useful for other users.
template {
local_source = "local-config.tpl"
destination = "local/config.cfg"
}
In this case nomad will read local-config.tpl and push it to server as EmbeddedTpl
I think #1185 will fix this issue but will leave it open until we can confirm. I'd prefer a generic HIL solution vs a new parameter in the template stanza as it would allow interpolating from local files for any values.
@alxark This isn't really recommend. If the template is larger than you are comfortable having in the job file it likely means you should be managing the template by downloading it as an artifact and not embedding it.
The problem is not about size, but maintainability. Currently there is no syntax highlight for embedded templates. But if we will have template in separate file it will be easier to support them.
Hey @alxark, that is fair but I think it can easily lead people to following bad patterns and is not something that we are currently interested in supporting. You can always keep a sentinel in place in the data section and use sed to replace the contents from your separately maintained file and then submit.
i need this feature, so i could inject env values from local .env file.
or is there any workaround like docker run --env-file ?
template {
source = ".env"
destination = ".env" // just because it's required
env = true
}
thanks
Hi @asule90, take a look at the HCL2 features in the 1.0-beta2. See https://www.nomadproject.io/docs/job-specification/hcl2
Also, this issue has been closed for quite a long time. It's generally a better idea to open a new issue (or participate in an already open discussion like https://github.com/hashicorp/nomad/pull/7883) than replying to a long-dead one.
Most helpful comment
The problem is not about size, but maintainability. Currently there is no syntax highlight for embedded templates. But if we will have template in separate file it will be easier to support them.