Skip to content

visioncritical/consul_template

Repository files navigation

Build Status Code Quality Code Climate Cookbook Version GitHub license

Consul Template Cookbook

Installs & configures the Consul Template service.

Requirements

OS

supports 'ubuntu', '>= 12.04'
supports 'redhat', '>= 6.4'
supports 'centos', '>= 6.4'
supports 'windows'
supports 'freebsd'

Cookbooks

depends 'poise', '~> 2.6'
depends 'poise-service', '~> 1.1'
depends 'rubyzip', '~> 1.0'
depends 'nssm', '~> 1.2'

Usage

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.

Attributes

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

Resources

consul_template_config

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_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_service 'consul-template' do
  user
  group
  conf_dir
  data_dir
  environment
  nssm_params # Windows only
  program
end

consul_template

This resource is used for placing x2 files:

  1. A configuration file containing a template block in your configuration directory.
  2. 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).

Contributing

Please refer to CONTRIBUTING.md.

Extra

Other Hashicorp Cookbooks:

Thanks

Special thanks to:

About

Installs and configures Consul Template

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors