The purpose of this repository is to serve as a baseline demonstration of templating configuration out from Consul and Vault, using Consul Template and Consult.
Make sure you have Docker CE installed. Then, clone this repo and do the following:
$ docker-compose build
$ docker-compose up
This will boot three containers, one for Vault, one for Consul, and one basic Ubuntu container to execute commands against Consul and Vault. The latest version of each container will be pulled. Run docker-compose ps
to see your running containers.
- From your machine: The Consul API and UI are at http://localhost:8500
- From the Ubuntu container: The Consul API is available at http://consul:8500
The Vault root token is set to 11111111-2222-3333-4444-555555555555
.
- From your machine: The Vault API and UI are available at http://localhost:8200.
- From the Ubuntu container: The Vault API is available at http://vault:8200
Access the Ubuntu container and store some data in Consul and Vault.
$ docker exec -it consul-vault-templating_ubuntu_1 /bin/bash
$ vault kv put secret/launch_codes password=h4v3-1-b33n-pwned
$ consul kv put hello veracross
Now you are ready to template this data out.
A functioning example of Consul Template is in the consul-template
directory.
Relevant files:
consul-template/demo-template.yml.tmpl
To try it:
$ cd /demo/consul-template
$ consul-template -template "demo-template.yml.tmpl:demo-template.yml:cat demo-template.yml" -vault-renew-token=false
Consult is a ruby library, somewhat similar to Consul Template.
Relevant files:
config/consult.yml
render.rb
To try it:
$ cd /demo
$ bundle install
$ ./render.rb