I need to make a repeatable group that can launch a task with a different values for the same env vars. My current idea is to store an array of values (or comma separate string) in the Nomad variable that can be queried by NOMAD_ALLOC_INDEX. Seems like I absolutely can’t do that in env{}
block so I’m currently trying to make it work in template
. But I can’t figure out how to index
by NOMAD_ALLOC_INDEX
I can turn NOMAD_ALLOC_INDEX
into index using
{{ $index := env "NOMAD_ALLOC_INDEX" | parseInt }}
I can split comma separated string into array using
{{ $array := split "," (env "TASK_VALUES") }}
or
ARRAY=${split(",", var.TASK_VALUES)[...]}
But I can use $index
with neither of these two array.