Skip to content

Instantly share code, notes, and snippets.

@jasonrm
Created October 23, 2023 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrm/3385bb556cdf14fd06ca2519b735a572 to your computer and use it in GitHub Desktop.
Save jasonrm/3385bb556cdf14fd06ca2519b735a572 to your computer and use it in GitHub Desktop.
Nomad Template Block For Setting All Environment Variables From Nomad Variables
# Ref: https://developer.hashicorp.com/nomad/docs/job-specification/template#nomad-integration
# Ref: https://discuss.hashicorp.com/t/templates-how-to-access-tuple-key-value/53875
job "php" {
# ...
group "php" {
# ...
task "php" {
# ...
template {
data = <<EOH
{{- with nomadVar "nomad/jobs/php" -}}
{{- range .Tuples -}}
{{ .K }}={{ .V }}
{{ end }}
{{- end -}}
EOH
destination = "local/config.env"
env = true
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment