Consul
Render templates
This page describes to process to render templates, including common integrations on the command line.
Render the template /tmp/template.ctmpl
to /tmp/result
on disk:
$ consul-template \
-template "/tmp/template.ctmpl:/tmp/result"
Render multiple templates in the same process. The optional third argument to the template is a command that will execute each time the template changes.
$ consul-template \
-template "/tmp/nginx.ctmpl:/var/nginx/nginx.conf:nginx -s reload" \
-template "/tmp/redis.ctmpl:/var/redis/redis.conf:service redis restart" \
-template "/tmp/haproxy.ctmpl:/var/haproxy/haproxy.conf"
Render a template using a custom Consul and Vault address:
$ consul-template \
-consul-addr "10.4.4.6:8500" \
-vault-addr "https://10.5.32.5:8200" \
-template "/tmp/template.ctmpl:/tmp/result"
Render all templates and then spawn and monitor a child process as a supervisor:
$ consul-template \
-template "/tmp/in.ctmpl:/tmp/result" \
-exec "/sbin/my-server"
For more information on supervising, refer to the Consul Template Exec Mode documentation.
Instruct Consul Template to use a configuration file with the -config
flag:
$ consul-template -config "/my/config.hcl"