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
7
votes
4 answers

How would you use Hashicorp's Nomad 'template stanza' to generate an nginx config file through the Nomad job file?

With the assumption that Consul and Nomad has been configured to run on a pool of resource. How would you rendered a template file for the sole purpose of generating e.g. an Nginx 'default.conf' file. Using the template stanza configuration below,…
dev_a.y
  • 133
  • 2
  • 7
6
votes
2 answers

Consul deregister 'failing' services

I have consul running on Consul v0.5.2 version & services running in Mesos. Services keep moving from 1 server to another. Is there way to deregister services in consul that are in 'failing' state? I am able to get the list of services in failing…
DevOpsNewB
  • 185
  • 2
  • 14
5
votes
1 answer

consul batch KV pairs HTTP post using HTTP api (Import a huge json through HTTP API)

I have application configuration in a json with upto 80 key/value pairs per app, which are to be stored in Consul KV Store. Generally they are java keyvalue properties, I have a simple shell script, which does encode value and convert it into import…
Venu S
  • 3,251
  • 1
  • 9
  • 25
5
votes
1 answer

Can't read Service Meta with consul-template

I have a test service registered with Consul with the following service definition: { "name": "web", "tags": ["web1"], "address": "example.com", "meta": { "meta": "cluster", "acl": "host_test", "cluster": "test_cluster" }, …
seemvision
  • 242
  • 1
  • 2
  • 12
4
votes
1 answer

HAProxy & Consul-template : retry request when scaling down

I'am working on a microservice architecture based on Docker, registrator, consul and HAProxy. I'am also using Consul-template to dynamically generate the HAProxy config file. Everything works fine : When I add multiple instances of the same…
Fred Mériot
  • 4,157
  • 9
  • 33
  • 50
4
votes
2 answers

How to concatenate Service metadata for consul-template with commas

Does anyone know how to concatenate strings from consul for consul-template? If I have a service 'foo' registered in Consul { "Node": "node1", "Address": "192.168.0.1", "Port": 3333 }, { "Node": "node2", "Address": "192.168.0.2", …
Jose Leon
  • 1,615
  • 3
  • 22
  • 30
3
votes
1 answer

Consul Template - "If Service Exists" condition?

I've just inherited an Nginx proxy/app server setup that makes use of Consul and Consul Template for service discovery and registration. The Nginx proxy has a config file with an entry like this to register the downstream app…
Shadowman
  • 11,150
  • 19
  • 100
  • 198
3
votes
1 answer

How to generate a Consul template inside a Helm Chart

I have a Helm Chart for a Spring Boot application that gets its database credentials injected by the Hashicorp Vault agent injector. This is a snippet from the generated deployment manifest in the dev environment. annotations: …
jokarls
  • 330
  • 2
  • 11
3
votes
1 answer

Consul-template if else condition

I have below consul-template. {{ range service "mysql_slave.mysql" "any" }} host_name {{.Node}} command check_nrpe!check_procs_1 {{end}} I want to add if my hostname match "database-1" then command…
Kasun Rathnayaka
  • 483
  • 4
  • 15
3
votes
3 answers

Overriding a variable in a loop in consul-template

I'm using the following template in consul-template: {{ range services }} {{ $server_name := .Name | replaceAll "_" "." }} {{ range .Tags }} {{ if . | regexMatch "server_name=" }} # found matching server_name in {{ . }} {{…
raphink
  • 3,625
  • 1
  • 28
  • 39
2
votes
2 answers

Consul 1.2.1 defining health check using pipe in the command argument

I'm using Consul version 1.2.1 and trying to implement health check that runs the command: # echo ruok | nc localhost 2181 imok Therefore, I defined the health check in this json file, however, I'm unable to locate any documentation that shows how…
c.kid
  • 35
  • 5
2
votes
0 answers

external and internal loadbalancer with traefik

I am trying to set up traefik with an internal load balancer (that can contact the apps) and an external loadbalancer (that all the ingress goes through but forwards all trafik to the internal trafik server). My services themselves are registered in…
Flyhard
  • 544
  • 5
  • 26
2
votes
1 answer

Consul-Template: Looping over a k/v pair and using the result in another key

Given the Consul keys: flyway/tweedle/server: postgres flyway/beetle/server: postgres flyway/battle/server: mysql service/tweedle/repo: fox/tweedle.git service/beetle/repo: fox/beetle.git service/battle/repo: fox/battle.git I'm trying to loop…
Spanky
  • 5,608
  • 10
  • 39
  • 45
2
votes
1 answer

How to monitor a systemd service via http endpoint

I have a process I would like to monitor consul-template which is a process currently managed by systemd. I use Pandora to monitor an HTTP endpoint for my other processes, however consul-template doesn't have an HTTP endpoint. I've thought of a…
EMChamp
  • 449
  • 1
  • 7
  • 13
2
votes
3 answers

What are some concrete use-cases for Consul's Key-Value store?

We're considering using Consul's key-value store to enhance our configuration management tool (Ansible, at the moment). We're hoping to use it to solve two related problems: Preventing scatter: Some items (namely: passwords, certificates etc) are…
FuzzyAmi
  • 7,543
  • 6
  • 45
  • 79
1
2 3 4 5