Created
October 23, 2023 06:41
-
-
Save jasonrm/3385bb556cdf14fd06ca2519b735a572 to your computer and use it in GitHub Desktop.
Nomad Template Block For Setting All Environment Variables From Nomad Variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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