How to use the same job for different environments?

I was originally hoping that you could use the same job for local dev and production. However, that doesn’t seem to be the case, as there can be slight differences in configuration.

What do you do in this case? Do you create two jobs, one for production and one for dev? Or can you utilize templates and fill them in with environment specific values? I’m guessing it’s the latter? I wanted to see if anyone else had a better idea or solution.

Hi @iamwil :wave:

Templating is probably the best way to accomplish this.

If don’t need too much logic or customization using HCL2 might be a good start. It’s native to the Nomad CLI and can provide you with some base constructs, like variables and some basic functions.

For more complex templating Levant is a good option. It provides more powerful templates and extra functionalities, like monitoring job deployments.

We have some guides on the subject here: Use Templating with Nomad | Nomad - HashiCorp Learn