Matt Karmazyn

Creating Consul Templates with Chef's Template resource.

Yo Dawg Templates

# Consul

I won't go into what Consul is in the scope of this post, but it is expected you know the basics.

# consul-template

consul-template can be used to render a template using values stored in Consul. This is often used when creating configuration files which need to be updated dynamically, such as a software load balancer that needs to dynamically load the servers it is balancing.

The Flow

Example

In this example we will have an auto-scaling web server group behind an HAProxy instance.

How do we update HAProxy when a new web server is launched

# Chef

We need something to place the consul-template configuration file on the system, as well as the ctpl consul-template templates. This is where Chef comes in and lays down the ctpl file so consul-template can generate the end .conf file for HAProxy, or whatever file you are managing with consul-template.