-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
theme/consul-templatetheme/docsDocumentation issues and enhancementsDocumentation issues and enhancementstheme/template
Description
Nomad version
Nomad v1.11.0
BuildDate 2025-11-11T16:18:19Z
Revision 9103d93
Operating system and Environment details
DEBIAN_VERSION_FULL=13.3
Minimal VM with nomad from
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com trixie main
Issue
nomadVar is not evaluating properly in templates and results in dependency.NomadVarItem errors.
get:
Killing: Template failed: (dynamic): execute: template: :3:38: executing "" at <",">: wrong type for value; expected string; got dependency.NomadVarItem
from
{{ with nomadVar "nomad/jobs/templtest" }}
split varcsv len = {{ .varcsv | split "," | len }}
{{end}}
Reproduction steps
nomad agent -dev-connect
nomad var put -namespace default nomad/jobs/templtest var1=one var2=two varcsv=a,b,c
# Create jobfile as below
nomad job run templtest.nomad
Verify
Works well
Logs show:
My Conf
var1 = one
var2 = two
split $list len is 3
Case 1:
Replace data EOF with:
{{ $v := nomadVar "nomad/jobs/templtest" }}
var1 = {{$v.var1}}
var2 = {{$v.var2}}
Result:
Killing: Template failed: (dynamic): execute: template: :3:11: executing "" at <$v.var1>: nil pointer evaluating *dependency.NomadVarItems.var1
Case 2:
Replace data EOF with:
My Conf
{{ with nomadVar "nomad/jobs/templtest" }}
split varcsv len = {{ .varcsv | split "," | len }}
{{end}}
Result:
Killing: Template failed: (dynamic): execute: template: :3:38: executing "" at <",">: wrong type for value; expected string; got dependency.NomadVarItem
Job file
cat <<EOJ > templtest.nomad
job "templtest" {
type = "batch"
group "ttg" {
count = 1
task "ttt" {
driver = "exec"
template {
destination = "etc/conf"
data = <<-EOF
My Conf
{{ with nomadVar "nomad/jobs/templtest" }}
var1 = {{.var1}}
var2 = {{.var2}}
{{ $list := "1,2,3"}}
split $list len is {{ $list | split "," | len }}
{{ end }}
EOF
}
config {
command = "/bin/cat"
args = ["etc/conf"]
}
}
}
}
EOJ
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
theme/consul-templatetheme/docsDocumentation issues and enhancementsDocumentation issues and enhancementstheme/template
Type
Projects
Status
In Progress