Puppet Class: consul::config
- Defined in:
- manifests/config.pp
Overview
Class consul::config
This class is called from consul::init to install the config file.
Parameters
- config_hash
-
Hash for Consul to be deployed as JSON
- purge
-
Bool. If set will make puppet remove stale config files.
- enable_beta_ui
-
Bool. Should the UI be enabled
- allow_binding_to_root_ports
-
Bool. Should binding to specified ports be allowed
- restart_on_change
-
Bool. Should the service be restarted on changes
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'manifests/config.pp', line 22
class consul::config (
Hash $config_hash = $consul::config_hash_real,
Boolean $purge = $consul::purge_config_dir,
Boolean $enable_beta_ui = $consul::enable_beta_ui,
Boolean $allow_binding_to_root_ports = $consul::allow_binding_to_root_ports,
Boolean $restart_on_change = $consul::restart_on_change,
) {
$notify_service = $restart_on_change ? {
true => Class['consul::run_service'],
default => undef,
}
if ($consul::init_style_real != 'unmanaged') {
case $consul::init_style_real {
'systemd': {
systemd::unit_file { 'consul.service':
content => template('consul/consul.systemd.erb'),
notify => $notify_service,
}
}
'sles': {
file { '/etc/init.d/consul':
ensure => file,
mode => '0555',
owner => 'root',
group => 'root',
content => template('consul/consul.sles.erb'),
}
}
'launchd': {
file { '/Library/LaunchDaemons/io.consul.daemon.plist':
ensure => file,
mode => '0644',
owner => 'root',
group => 'wheel',
content => template('consul/consul.launchd.erb'),
}
}
'freebsd': {
file { '/etc/rc.conf.d/consul':
ensure => file,
mode => '0444',
owner => 'root',
group => 'wheel',
content => template('consul/consul.freebsd-rcconf.erb'),
}
file { '/usr/local/etc/rc.d/consul':
ensure => file,
mode => '0555',
owner => 'root',
group => 'wheel',
content => template('consul/consul.freebsd.erb'),
}
}
default: {
fail("I don't know how to create an init script for style ${consul::init_style_real}")
}
}
}
file { $consul::config_dir:
ensure => 'directory',
owner => $consul::config_owner_real,
group => $consul::group_real,
purge => $purge,
recurse => $purge,
}
file { 'consul config':
ensure => file,
path => "${consul::config_dir}/${consul::config_name}",
owner => $consul::config_owner_real,
group => $consul::group_real,
mode => $consul::config_mode,
content => consul::sorted_json($config_hash, $consul::pretty_config, $consul::pretty_config_indent),
}
}
|