Skip to content

Commit

Permalink
Merge pull request #408 from cristianjuve/cristian/AddParams
Browse files Browse the repository at this point in the history
Add new parameters to configure consul permissions in the binary
  • Loading branch information
solarkennedy committed Feb 23, 2018
2 parents 5a17f4e + 01e4117 commit c884db5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
16 changes: 16 additions & 0 deletions manifests/init.pp
Expand Up @@ -16,6 +16,18 @@
# [*bin_dir*]
# Directory to create the symlink to the consul binary in.
#
# [*binary_group*]
# The group that the file belongs to.
#
# [*binary_mode*]
# Permissions mode for the file.
#
# [*binary_name*]
# The binary name file.
#
# [*binary_owner*]
# The user that owns the file.
#
# [*checks*]
# Hash of consul::check resources to create.
#
Expand Down Expand Up @@ -141,6 +153,10 @@
$arch = $consul::params::arch,
$archive_path = $consul::params::archive_path,
$bin_dir = $consul::params::bin_dir,
$binary_group = $consul::params::binary_group,
$binary_mode = $consul::params::binary_mode,
$binary_name = $consul::params::binary_name,
$binary_owner = $consul::params::binary_owner,
Hash $checks = $consul::params::checks,
Hash $config_defaults = $consul::params::config_defaults,
$config_dir = $consul::params::config_dir,
Expand Down
38 changes: 10 additions & 28 deletions manifests/install.pp
Expand Up @@ -4,24 +4,6 @@
#
class consul::install {

case $::operatingsystem {
'windows': {
$binary_name = 'consul.exe'
$binary_mode = '0775'
$data_dir_mode = '775'
$binary_owner = 'Administrators'
$binary_group = 'Administrators'
}
default: {
$binary_name = 'consul'
$binary_mode = '0555'
$data_dir_mode = '755'
# 0 instead of root because OS X uses "wheel".
$binary_owner = 'root'
$binary_group = 0
}
}

if $consul::data_dir {
file { $consul::data_dir:
ensure => 'directory',
Expand Down Expand Up @@ -51,27 +33,27 @@
$install_path,
"${install_path}/consul-${consul::version}"]:
ensure => directory,
owner => $binary_owner,
group => $binary_group,
mode => $binary_mode,
owner => $consul::binary_owner,
group => $consul::binary_group,
mode => $consul::binary_mode,
}
-> archive { "${install_path}/consul-${consul::version}.${consul::download_extension}":
ensure => present,
source => $consul::real_download_url,
proxy_server => $consul::proxy_server,
extract => true,
extract_path => "${install_path}/consul-${consul::version}",
creates => "${install_path}/consul-${consul::version}/${binary_name}",
creates => "${install_path}/consul-${consul::version}/${consul::binary_name}",
}
-> file {
"${install_path}/consul-${consul::version}/${binary_name}":
owner => $binary_owner,
group => $binary_group,
mode => $binary_mode;
"${consul::bin_dir}/${binary_name}":
"${install_path}/consul-${consul::version}/${consul::binary_name}":
owner => $consul::binary_owner,
group => $consul::binary_group,
mode => $consul::binary_mode;
"${consul::bin_dir}/${consul::binary_name}":
ensure => link,
notify => $do_notify_service,
target => "${install_path}/consul-${consul::version}/${binary_name}";
target => "${install_path}/consul-${consul::version}/${consul::binary_name}";
}
}
'package': {
Expand Down
16 changes: 16 additions & 0 deletions manifests/params.pp
Expand Up @@ -53,6 +53,22 @@

$os = downcase($::kernel)

case $::operatingsystem {
'windows': {
$binary_group = 'Administrators'
$binary_mode = '0755'
$binary_name = 'consul.exe'
$binary_owner = 'Administrator'
}
default: {
# 0 instead of root because OS X uses "wheel".
$binary_group = 0
$binary_mode = '0555'
$binary_name = 'consul'
$binary_owner = 'root'
}
}

if $::operatingsystem == 'Ubuntu' {
$shell = '/usr/sbin/nologin'
if versioncmp($::operatingsystemrelease, '8.04') < 1 {
Expand Down

0 comments on commit c884db5

Please sign in to comment.