#consul_template for Puppet
This fork is not backwards compatible with its upstream. The configuration mechanism has been modified to be driven by config_hash/config_defaults instead of individual parameters to provide access to the full set of options and avoid the need to make changes here as consul-template options evolve.
##Installation
###What This Module Affects
- Installs the consul-template binary (via url or package)
- Optionally installs a user to run it under
- Installs a configuration file (/etc/consul-template/config.json)
- Manages the consul-template service via upstart, sysv, or systemd
##Parameters
purge_config_dirDefault: true. If enabled, removes config files no longer managed by Puppet.config_modeDefault: 0660. Mode set on config files and directories.bin_dirDefault: /usr/local/bin. Path to the consul-template binariesarchDefault: Read from facter. System architecture to use (amd64, x86_64, i386)versionDefault: 0.11.0. Version of consul-template to installinstall_methodDefault: url. When set to 'url', consul-template is downloaded and installed from source. If set to 'package', its installed using the system package manager.osDefault: Read from facter.download_urlDefault: undef. URL to download consul-template from (wheninstall_methodis set to 'url')download_url_baseDefault: https://github.com/hashicorp/consul-template/releases/download/ Base URL to download consul-template from (wheninstall_methodis set to 'url')download_extensionDefault: zip. File extension of consul-template binary to be downloaded (wheninstall_methodis set to 'url')package_nameDefault: consul-template. Name of package to installpackage_ensureDefault: latest.config_dirDefault: /etc/consul-template. Path to store the consul-template configurationextra_optionsDefault: ''. Extra options to be bassed to the consul-template agent. See https://github.com/hashicorp/consul-template#optionsservice_enableDefault: true.service_ensureDefault: running.userDefault: root. This used to be a default ofconsul-templateand this caused much out-of-box pain for people.groupDefault: root.manage_userDefault: false. Module handles creating the user.manage_groupDefault: false. Module handles creating the group.init_styleInit style to use for consul-template service.config_hashDefault: {}. Consul-template configuration options. See https://github.com/hashicorp/consul-template#optionsconfig_defaultsDefault: {}. Consul-template configuration option defaults.
##Usage
The simplest way to use this module is:
include consul_templateconsul-template options can be passed via hiera:
consul_template::config_defaults:
deduplicate:
enabled: true
log_level: info
retry: 10s
syslog: true
token: <consul token>
Or to specify class parameters:
class { 'consul_template':
service_enable => false
init_style => 'upstart',
config_hash => {
log_level => 'debug',
wait => '5s:30s',
max_stale => '1s'
}
}To declare a file that you wish to populate from Consul key-values, you use the
watch define. This requires a source .ctmpl file and the file on-disk
that you want to update.
consul_template::watch { 'common':
template => 'data/common.json.ctmpl.erb',
template_vars => {
'var1' => 'foo',
'var2' => 'bar',
},
config_hash => {
destination => '/tmp/common.json',
command => 'true',
},
}##Limitations
Depends on the JSON gem, or a modern ruby.
##Development See the contributing guide
Open an issue or fork and open a Pull Request