Error getting job struct: Error parsing job file from job.nomad:
job.nomad:58,6-8: Invalid string literal; Template sequences are not allowed in this string. To include a literal “$”, double it (as “$$”) to escape it.
It isn’t you, the example is wrong. I will raise a PR to fix this documentation shortly. This issue is tracked on GitHub is you wanted to read additional details.
I have been actively reducing the number of “templatization” passes. For me there was Jinja2, terraform (templatefile), Nomad’s HCL2.
For now, I have settled on: Jinja2-ized “.nomad” file and a one-liner nomad_job Terraform resource.
Note: If I need to use the template block inside the Nomad job, I change the delimiter characters to [[ and ]] so as not to interfere with the outer Jinja’s {{ and }}.
This has the benefit that I get to see the actual Nomad job file without the intermediate Terraform template and the double $$ escaping.
EDIT:
Q: Why Jinja? A: Legacy toolchain.
In my opinion, the outer Jinja could be replaced with Levant.