Questions tagged [consul-template]

Consul template renders Go templates based on data queried from HashiCorp Consul.

Consul template is a simple, yet powerful tool. When initiated, it reads one or more template files and queries Consul for all data needed to render them. Typically, you run consul-template as a daemon which will fetch the initial values and then continue to watch for updates, re-rendering the template whenever there are relevant changes in the cluster.

The tag should be used for tool specific questions like daemon setup or usage of provided template functions. More general Go template questions should be tagged with instead.

75 questions
1
vote
1 answer

how to retrieve limited number of IPs when Consul service catalog is queried

Is there a way to retrieve only 3 IPs from Consul service catalog? {{if service 'web' 'passing'}} "{{range $index, $service := service 'web'}}{{if ne $index 0}},{{end}}{{.Address}}{{end}}" The above code gets all comma separated IPs (I have 100's…
wasay
  • 87
  • 1
  • 3
  • 8
1
vote
1 answer

consul template {{node}} default value no use?

My consul-template version: # ./consul-template -v consul-template v0.18.0-rc2 (652183d) I try to use the template below to test node: {{with node}}{{.Node.Node}} ({{.Node.Address}}){{range .Services}} {{.Service}} {{.Port}} ({{.Tags | join…
shawnlsa
  • 21
  • 6
1
vote
0 answers

Consul template fetching store key prefix errors using Nginx, Consul-template, and Docker

New to Nginx and consul template, but I think I have everything working except I am getting lots of noise (100 or so error messages every 15-30 seconds) in the form of errors in the logs. Seems like it is consul-template errors that it can't…
Dan
  • 181
  • 12
1
vote
1 answer

Can consul-template create config file

Now I know that consul-template can manage config file content when there's a change in k/v of consul, but what about create one? For example, a system has many users, and each user has his own config file, will consul-template able to create one…
Allen Jz
  • 101
  • 2
  • 9
1
vote
1 answer

consul-template does not work on remote machine

I have three machins like : [consul@cjportal]$ consul members Node Address Status Type Build Protocol DC portal1 192.168.11.155:8301 alive client 0.7.0 2 dc1 portal0 …
Allen Jz
  • 101
  • 2
  • 9
1
vote
1 answer

In consul-template, how to limit the number of elements over which I am ranging?

Following is my code to render the Addresses of the nodes with a service: {{range "service@datacenter" "passing"}}{{.Address}} {{end}} What I want to do is limit the number of addresses that are rendered. For example, if there are 5 nodes…
Magnus
  • 73
  • 8
1
vote
1 answer

How to pass parameters while creating consul client agent inside a Docker container?

I'm running Consul client agent inside a Docker container. I have created a docker-compose file as below: agent: hostname: sample.host.com container_name: consul_agent image: privatedockerregistry/consul-agent:0.6.4 restart: always …
meallhour
  • 13,921
  • 21
  • 60
  • 117
1
vote
1 answer

How can I tell my script to wait for consul to elect a leader before trying to add key/value pairs to it at startup?

My development environment consists of a local consul server in one container, and my application (with consul-template running) in another, all linked with docker-compose. I want for everything to spin up seamlessly and without manual intervention…
BDuelz
  • 3,890
  • 7
  • 39
  • 62
1
vote
1 answer

Reading vault secrets from consul-template

How do I query just the value of a secret key from consul template ? From vault cli I would do vault read -field=value secret/somekey and it works fine. However, in the consul-template {{secret "secret/somekey"}} returns something like {…
packetlord
  • 109
  • 1
  • 5
0
votes
0 answers

consul-template - merging maps from keys that are yaml docs

I'm trying to come up with a setup for a customer that will produce values.yaml for a helm chart using consul-template. The "brain" is that there are defaults per environment, defaults per service, and concrete values for a specific service in a…
Radagast the Brown
  • 3,156
  • 3
  • 27
  • 40
0
votes
0 answers

using consul-template with full Windows paths

I'm having trouble invoking consul-template on Windows. For example, I would like to run the command consul-template -in "c:\in.tpl:c:\out.tpl" Obviously, the colons are a problem, and I can't seem to find documentation about how to escape them. …
0
votes
0 answers

getting http: server gave HTTP response to HTTPS client when consul-template is trying to retrieve healthy nodes

In our infrastructure, we have cluster of app nodes with consul service running as consul server component. There is also another cluster of proxy nodes which have consul-template service installed. This consul-template has configuration which is…
user3379502
  • 223
  • 4
  • 22
0
votes
1 answer

ansible playbook - restarting consul-template fails

I had a ansible playbook including this code: - name: Start service systemd: daemon_reload: yes state: restarted name: "consul-template" The ansible fails with this error: fatal: [unix://var/run/docker.sock]: FAILED! => { …
Zag Gol
  • 1,038
  • 1
  • 18
  • 43
0
votes
0 answers

Error registering service : Unexpected response code: 400 (Invalid check: TTL must be > 0 for TTL checks)

I want to register my services with multiple script checks for each. I store the values in consul kv and call them with consul-template to write a JSON file as the configuration file to register services with cli “consul services register…
0
votes
0 answers

How do I resolve consul key using consul template?

I used consul template to generate the prometheus config file, and I set a key in Consul like this: 10.20.1.162:9100 env=test group=A project=t 10.20.1.160:9100 env=test group=A project=t I want the output to look like this: - targets: -…
yzhengwei
  • 67
  • 2
  • 6