Go-sockaddr/template format support in nomad consul stanza

Hello everyone,

I spent some time looking for any answer / sample code … to no avail.
All examples i found were hardcoding the consul address in the nomad config.

I am using nomad with consul and consul-template feature with haproxy.
I’ve also followed this blog post. and that one.

In nomad configuration - via the consul stanza - i indicate the consul agent address via the address property since i want to use a specific interface.

If i hardcode the consul agent IP address, all is fine.

However if i try to use the go-sockaddr/template which - as per the documentation - is supported. I have the following error :

Killing Template failed: catalog.services: Get “http://%7B%7B%20GetInterfaceIP%20"tailscale0"%20%20%7D%7D:8500/v1/catalog/services?stale=&wait=60000ms”: dial tcp: lookup {{ GetInterfaceIP “tailscale0” }}: no such host

Template Missing: catalog.services

When nomad tries to get the services catalog from consul, the address is not rendered correctly, hence the error.

Here is what i have in my nomad config file :

consul {
  address = "{{ GetInterfaceIP \"tailscale0\" }}:8500"

Note : I’m using this same {{ GetInterfaceIP "tailscale0" }} in the nomad config bind_addr attribute without any problem.

Besides this error, nomad is running correctly, consul too (i can access the UIs, check services states …).
My other service with the ‘nomad’ provider is deployed correctly.

So my question is :

Am i missing or misconfiguring something ?

My nomad version is Nomad v1.3.5

Any help would be greatly appreciated.

Hi @brahima,

Unfortunately this is a bug in the way that the Consul address is passed to the template runner. I have opened nomad issue #14627 to detail this against the repository.

jrasell and the Nomad team