Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Scope all variables
  • Loading branch information
Taylan Develioglu committed Sep 15, 2016
commit e603a66e9ea024ea47042419b12bb3bdfdfe8ec6
10 changes: 5 additions & 5 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
consul_validate_checks($check_hash[check])

$escaped_id = regsubst($id,'\/','_','G')
File[$consul::config_dir] ->
File[$::consul::config_dir] ->
file { "${consul::config_dir}/check_${escaped_id}.json":
ensure => $ensure,
owner => $consul::user,
group => $consul::group,
mode => $consul::config_mode,
content => consul_sorted_json($check_hash, $consul::pretty_config, $consul::pretty_config_indent),
owner => $::consul::user,
group => $::consul::group,
mode => $::consul::config_mode,
content => consul_sorted_json($check_hash, $::consul::pretty_config, $::consul::pretty_config_indent),
} ~> Class['consul::reload_service']
}
18 changes: 9 additions & 9 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$purge = true,
) {

if $consul::init_style {
if $::consul::init_style {

case $consul::init_style {
case $::consul::init_style {
'upstart': {
file { '/etc/init/consul.conf':
mode => '0444',
Expand Down Expand Up @@ -84,20 +84,20 @@
}
}

file { $consul::config_dir:
file { $::consul::config_dir:
ensure => 'directory',
owner => $consul::user,
group => $consul::group,
owner => $::consul::user,
group => $::consul::group,
purge => $purge,
recurse => $purge,
} ->
file { 'consul config.json':
ensure => present,
path => "${consul::config_dir}/config.json",
owner => $consul::user,
group => $consul::group,
mode => $consul::config_mode,
content => consul_sorted_json($config_hash, $consul::pretty_config, $consul::pretty_config_indent),
owner => $::consul::user,
group => $::consul::group,
mode => $::consul::config_mode,
content => consul_sorted_json($config_hash, $::consul::pretty_config, $::consul::pretty_config_indent),
}

}
14 changes: 7 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@
# OS component in the name of the archive file containing the consul binary.
#
# [*package_ensure*]
# Only valid when the install_method == package. Defaults to *]latest*].
# Only valid when the install_method == package. Defaults to `latest`.
#
# [*package_name*]
# Only valid when the install_method == package. Defaults to *]consul*].
# Only valid when the install_method == package. Defaults to `consul`.
#
# [*pretty_config*]
# Generates a human readable JSON config file. Defaults to *]false*].
# Generates a human readable JSON config file. Defaults to `false`.
#
# [*pretty_config_indent*]
# Toggle indentation for human readable JSON file. Defaults to *]4*].
# Toggle indentation for human readable JSON file. Defaults to `4`.
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*restart_on_change*]
# Determines whether to restart consul agent on $config_hash changes.
# This will not affect reloads when service, check or watch configs change.
# Defaults to *]true*].
# Defaults to `true`.
#
# [*service_enable*]
# Whether to enable the consul service to start at boot.
Expand All @@ -111,10 +111,10 @@
# Base url to the location of the archive file containing the consul ui.
#
# [*ui_package_ensure*]
# Only valid when the install_method == package. Defaults to *]latest*].
# Only valid when the install_method == package. Defaults to `latest`.
#
# [*ui_package_name*]
# Only valid when the install_method == package. Defaults to *]consul_ui*].
# Only valid when the install_method == package. Defaults to `consul_ui`.
#
# [*user*]
# Name of the user that should own the consul configuration files.
Expand Down
58 changes: 29 additions & 29 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
#
class consul::install {

if $consul::data_dir {
file { $consul::data_dir:
if $::consul::data_dir {
file { $::consul::data_dir:
ensure => 'directory',
owner => $consul::user,
group => $consul::group,
owner => $::consul::user,
group => $::consul::group,
mode => '0755',
}
}

case $consul::install_method {
case $::consul::install_method {
'url': {
$install_path = $consul::archive_path
$install_path = $::consul::archive_path

# only notify if we are installing a new version (work around for switching to archive module)
if $::consul_version != $consul::version {
$do_notify_service = $consul::notify_service
if $::consul_version != $::consul::version {
$do_notify_service = $::consul::notify_service
} else {
$do_notify_service = undef
}
Expand All @@ -35,7 +35,7 @@
}->
archive { "${install_path}/consul-${consul::version}.${consul::download_extension}":
ensure => present,
source => $consul::real_download_url,
source => $::consul::real_download_url,
extract => true,
extract_path => "${install_path}/consul-${consul::version}",
creates => "${install_path}/consul-${consul::version}/consul",
Expand All @@ -51,7 +51,7 @@
target => "${install_path}/consul-${consul::version}/consul";
}

if ($consul::ui_dir and $consul::data_dir) {
if ($::consul::ui_dir and $::consul::data_dir) {

# The 'dist' dir was removed from the web_ui archive in Consul version 0.6.0
if (versioncmp($::consul::version, '0.6.0') < 0) {
Expand All @@ -67,35 +67,35 @@
}->
archive { "${install_path}/consul_web_ui-${consul::version}.zip":
ensure => present,
source => $consul::real_ui_download_url,
source => $::consul::real_ui_download_url,
extract => true,
extract_path => "${install_path}/consul-${consul::version}_web_ui",
creates => $archive_creates,
}->
file { $consul::ui_dir:
file { $::consul::ui_dir:
ensure => 'symlink',
target => $ui_symlink_target,
}
}
}
'package': {
package { $consul::package_name:
ensure => $consul::package_ensure,
package { $::consul::package_name:
ensure => $::consul::package_ensure,
}

if $consul::ui_dir {
package { $consul::ui_package_name:
ensure => $consul::ui_package_ensure,
require => Package[$consul::package_name]
if $::consul::ui_dir {
package { $::consul::ui_package_name:
ensure => $::consul::ui_package_ensure,
require => Package[$::consul::package_name]
}
}

if $consul::manage_user {
User[$consul::user] -> Package[$consul::package_name]
if $::consul::manage_user {
User[$::consul::user] -> Package[$::consul::package_name]
}

if $consul::data_dir {
Package[$consul::package_name] -> File[$consul::data_dir]
if $::consul::data_dir {
Package[$::consul::package_name] -> File[$::consul::data_dir]
}
}
'none': {}
Expand All @@ -104,19 +104,19 @@
}
}

if $consul::manage_user {
user { $consul::user:
if $::consul::manage_user {
user { $::consul::user:
ensure => 'present',
system => true,
groups => $consul::extra_groups,
groups => $::consul::extra_groups,
}

if $consul::manage_group {
Group[$consul::group] -> User[$consul::user]
if $::consul::manage_group {
Group[$::consul::group] -> User[$::consul::user]
}
}
if $consul::manage_group {
group { $consul::group:
if $::consul::manage_group {
group { $::consul::group:
ensure => 'present',
system => true,
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/reload_service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@

# Don't attempt to reload if we're not supposed to be running.
# This can happen during pre-provisioning of a node.
if $consul::manage_service == true and $consul::service_ensure == 'running' {
if $::consul::manage_service == true and $::consul::service_ensure == 'running' {

# Make sure we don't try to connect to 0.0.0.0, use 127.0.0.1 instead
# This can happen if the consul agent RPC port is bound to 0.0.0.0
if $consul::rpc_addr == '0.0.0.0' {
if $::consul::rpc_addr == '0.0.0.0' {
$rpc_addr = '127.0.0.1'
} else {
$rpc_addr = $consul::rpc_addr
$rpc_addr = $::consul::rpc_addr
}

exec { 'reload consul service':
path => [$consul::bin_dir,'/bin','/usr/bin'],
path => [$::consul::bin_dir,'/bin','/usr/bin'],
command => "consul reload -rpc-addr=${rpc_addr}:${consul::rpc_port}",
refreshonly => true,
tries => 3,
Expand Down
16 changes: 8 additions & 8 deletions manifests/run_service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
#
class consul::run_service {

$init_selector = $consul::init_style ? {
$init_selector = $::consul::init_style ? {
'launchd' => 'io.consul.daemon',
default => 'consul',
}

if $consul::manage_service == true and $consul::init_style {
if $::consul::manage_service == true and $::consul::init_style {
service { 'consul':
ensure => $consul::service_ensure,
ensure => $::consul::service_ensure,
name => $init_selector,
enable => $consul::service_enable,
provider => $consul::init_style,
enable => $::consul::service_enable,
provider => $::consul::init_style,
}
}

if $consul::join_wan {
if $::consul::join_wan {
exec { 'join consul wan':
cwd => $consul::config_dir,
path => [$consul::bin_dir,'/bin','/usr/bin'],
cwd => $::consul::config_dir,
path => [$::consul::bin_dir,'/bin','/usr/bin'],
command => "consul join -wan ${consul::join_wan}",
unless => "consul members -wan -detailed | grep -vP \"dc=${consul::config_hash_real['datacenter']}\" | grep -P 'alive'",
subscribe => Service['consul'],
Expand Down
10 changes: 5 additions & 5 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
$escaped_id = regsubst($id,'\/','_','G')
file { "${consul::config_dir}/service_${escaped_id}.json":
ensure => $ensure,
owner => $consul::user,
group => $consul::group,
mode => $consul::config_mode,
content => consul_sorted_json($service_hash, $consul::pretty_config, $consul::pretty_config_indent),
require => File[$consul::config_dir],
owner => $::consul::user,
group => $::consul::group,
mode => $::consul::config_mode,
content => consul_sorted_json($service_hash, $::consul::pretty_config, $::consul::pretty_config_indent),
require => File[$::consul::config_dir],
} ~> Class['consul::reload_service']
}
10 changes: 5 additions & 5 deletions manifests/watch.pp
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@
watches => [delete_undef_values(merge($basic_hash, $type_hash))]
}

File[$consul::config_dir] ->
File[$::consul::config_dir] ->
file { "${consul::config_dir}/watch_${id}.json":
ensure => $ensure,
owner => $consul::user,
group => $consul::group,
mode => $consul::config_mode,
content => consul_sorted_json($watch_hash, $consul::pretty_config, $consul::pretty_config_indent),
owner => $::consul::user,
group => $::consul::group,
mode => $::consul::config_mode,
content => consul_sorted_json($watch_hash, $::consul::pretty_config, $::consul::pretty_config_indent),
} ~> Class['consul::reload_service']
}