I am having a problem in that consul-template seems to be substituting the service "ServiceAddress" and not "Address" in my template and I wonder if anyone can tell me why.
From a bash session within my nginx container where consul-template is also running I can fetch the service definition from Consul with:
curl http://consul-server.service.consul:8500/v1/catalog/service/service1
[{"Node":"ip-172-31-24-202","Address":"172.31.24.202","ServiceID":"ip-172-31-24-202:service1:23141","ServiceName":"service1","ServiceTags":null,"ServiceAddress":"172.17.0.3","ServicePort":32809}]
My consul-template template file looks like:
{{range service "service1"}}server {{.Address}}:{{.Port}};
I would expect this to output the Address
, and not the ServiceAddress
for the service. However, the below happens:
consul-template -consul consul-server.service.consul:8500 -template "/var/templates/service1.conf.tmpl" -dry -once
server 172.17.0.3:32809