Implement templatefile()
in addition to the file()
function within jobspecs
#24749
Labels
templatefile()
in addition to the file()
function within jobspecs
#24749
Proposal
Implement Terraform's
templatefile()
function for Nomad job specs, or equivalent with support for templating as part of HCL spec.Use-cases
While Nomad has support for importing whole files as part of the
file()
function, it would be useful to be able to more directly combine it with for example HCL2 input variables and/or client attribute. This would reduce the need for using an external file templating tool to generate the jobspec, or in the case of Terraform templating, stacking bothtemplatefile()
and Nomad variable interpolation on top of each other. I've encountered cases where I've had to write$$${var}
, first to escape Terraform, then Nomad, then lastly render a file used for templating within the task.Attempted Solutions
It is possible to work around this limitation by passing variables to the
meta
block, and then accessing it via{{ env "NOMAD_META_var" }}
, however it is a messy solution in comparsion to simply passing${var}
to the file directly, especially if you want to do any more complex operations such as iterating over a list.The text was updated successfully, but these errors were encountered: