Files
nomad/e2e/workload_id/input/api-nomad-cli.nomad.hcl
Daniel Bennett 7519df8d06 task env: add NOMAD_UNIX_ADDR var (#25598)
for easier setup when using workload identity + task api
2025-06-11 15:56:51 -04:00

33 lines
791 B
HCL

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
job "task-api-nomad-cli" {
type = "batch"
group "grp" {
restart { attempts = 0 }
reschedule { attempts = 0 }
constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}
task "tsk" {
driver = "raw_exec"
config {
command = "bash"
// "|| true" because failure to get a var makes nomad cli exit 1,
// but for this test, "Variable not found" actually indicates successful
// API connection.
args = ["-xc", "echo $NOMAD_ADDR; nomad var get nothing || true"]
}
env {
NOMAD_ADDR = "${NOMAD_UNIX_ADDR}"
}
identity { # creates unix addr
env = true # provides NOMAD_TOKEN
}
}
}
}