Last active
June 13, 2017 20:17
-
-
Save jkordish/141a2a841f78594a7b597a0d12a1da4b to your computer and use it in GitHub Desktop.
consul-template for generating /etc/hosts from service catalog
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
# consul-template generated | |
127.0.0.1 localhost {{with node}}{{.Node.Node}}{{end}} | |
{{with node}}{{.Node.Address}} {{.Node.Node}}{{end}} | |
::1 localhost | |
# hosts by service | |
{{range services}}}# {{.Name}}{{$Name :=.Name}}{{range $index, $service := service .Name "any" }} | |
{{.Address}} {{.Node}} {{$Name}}0{{$index | add 1}} | |
{{end}}{{end}} | |
# hosts by nodes | |
{{range nodes}}{{with node .Node}}#{{.Node.Address}} {{.Node.Node}}{{end}} | |
{{end}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment