Installs & configures the Consul Template service.
supports 'ubuntu', '>= 12.04'
supports 'redhat', '>= 6.4'
supports 'centos', '>= 6.4'
supports 'windows'
supports 'freebsd'
depends 'poise', '~> 2.6'
depends 'poise-service', '~> 1.1'
depends 'rubyzip', '~> 1.0'
depends 'nssm', '~> 1.2'
This cookbook was designed to expose most of configuration through node attributes. To use it, overide the attributes you need & include the default recipe in your runlist. You can alternatively customize everything by declaring the necessary resources yourself.
Key | Type | Description | Default |
---|---|---|---|
['consul_template']['service_name'] |
String | The name of the service | consul-template |
['consul_template']['version'] |
String | The version of Consul Template to install | 0.14.0 |
['consul_template']['config']['conf_dir'] |
String | The configuration directory for Consul Template | /etc/consul-template/conf.d OR C:\Program Files\consul-template\conf.d |
['consul_template']['config']['template_dir'] |
Hash | A hash of Consul Template options to pass to the consul_template_config resource (options) |
{} |
['consul_template']['service']['data_dir'] |
Hash | The data directory for Consul Template | /var/lib/consul-template OR C:\Program Files\consul-template\data |
['consul_template']['service']['environment'] |
Hash | A list of environment variables that will be set for the service (Linux only) | {} |
['consul_template']['service']['user'] |
String | The user to run the service as | consul-template |
['consul_template']['service']['group'] |
String | The group of the service user | consul-template |
['consul_template']['service']['nssm_params'] |
Hash | A hash of NSSM options to set for the service (Windows only) options | See attributes file |
consul_template_config 'consul-template' do
conf_dir
template_dir
owner
group
# https://github.com/hashicorp/consul-template#options
options
# Optional, but recommeneded
notifies :restart, "consul_template_service[#{service_name}]", :delayed
end
consul_template_installation 'consul-template' do
version
end
The following cannot be specified as a property on this resource, but they do have a direct effect on it. They're managed through node attributes.
archive_url # node['consul_template']['archive_url']
install_path # node['consul_template']['install_path']
consul_template_service 'consul-template' do
user
group
conf_dir
data_dir
environment
nssm_params # Windows only
program
end
This resource is used for placing x2 files:
- A configuration file containing a template block in your configuration directory.
- An input template file (
.ctmpl
) in your template directory.
consul_template 'example.json' do
source
cookbook
content
options
conf_dir
template_dir
owner
group
destination
command
command_timeout
perms
backup
# Optional, but recommeneded
notifies :restart, 'consul_template_service[consul-template]', :delayed
end
This resource uses the Template Content helper from the Poise cookbook. This exposes the following 4 properties:
source
- The name of the file or template (e.g.template.ctmpl.erb
).cookbook
- The name of the cookbook in which the file or template resides.options
- A hash of variables to be evaluated in the template.content
- The raw content of the file or template (used independently).
Please refer to CONTRIBUTING.md.
Special thanks to:
- John Bellone for all his work on the Consul & Vault Cookbooks.
- Noah Kantrowitz for creating the Poise suite of Cookbooks.