-
-
Save blinkinglight/e018af7be7fe0ddc4aa77f28567668e1 to your computer and use it in GitHub Desktop.
nomad + consul template comma separated services from tags
This file contains 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
job web { | |
datacenters = ["dc1"] | |
type = "service" | |
priority = 70 | |
group app { | |
count = 1 | |
task env { | |
driver = "exec" | |
config { | |
command = "/usr/bin/env" | |
} | |
template { | |
env = true | |
destination = "${NOMAD_SECRETS_DIR}/env" | |
data = <<EOF | |
SERVICES_FROM_TAG={{range services}}{{if in .Tags "tag-name-goes-here"}}{{$services:=service .Name "any"}}{{if gt (len $services) 0}}{{range $services}}{{.Address}}:{{.Port}},{{end}}{{end}}{{end}}{{end}} | |
EOF | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment