Skip to content

Commit

Permalink
(GH-578) etc_dir should be configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil-Friderici committed Jul 13, 2017
1 parent 422a6d2 commit b454ab9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
# Default: undef
# Valid values: sensu_gem, apt, aptitude, yum
#
# [*sensu_etc_dir*]
# String. Absolute path to the sensu etc directory.
# Default: '/etc/sensu' on RedHat and Debian
# 'C:/opt/sensu' on windows
# undef on all other platforms
#
# [*sensu_plugin_version*]
# String. Version of the sensu-plugin gem to install. Refers to the sensu-plugin
# rubygem, not the sensu-plugins community scripts
Expand Down Expand Up @@ -429,6 +435,11 @@
'windows' => 'gem',
default => undef,
},
$sensu_etc_dir = $::osfamily ? {
/(Debian|RedHat)/ => '/etc/sensu',
'windows' => 'C:/opt/sensu',
default => undef,
},
$sensu_plugin_version = 'installed',
$install_repo = true,
$enterprise = false,
Expand Down Expand Up @@ -544,6 +555,11 @@
){

validate_absolute_path($log_dir)

if $sensu_etc_dir != undef {
validate_absolute_path($sensu_etc_dir)
}

validate_bool($client, $server, $api, $manage_repo, $install_repo, $enterprise, $enterprise_dashboard, $purge_config, $safe_mode, $manage_services, $redis_reconnect_on_error, $hasrestart, $redis_auto_reconnect, $manage_mutators_dir, $deregister_on_stop)

validate_re($repo, ['^main$', '^unstable$'], "Repo must be 'main' or 'unstable'. Found: ${repo}")
Expand Down Expand Up @@ -648,7 +664,7 @@

case $::osfamily {
'Debian','RedHat': {
$etc_dir = '/etc/sensu'
$etc_dir = $sensu_etc_dir
$conf_dir = "${etc_dir}/conf.d"
$user = 'sensu'
$group = 'sensu'
Expand All @@ -659,7 +675,7 @@
}

'windows': {
$etc_dir = 'C:/opt/sensu'
$etc_dir = $sensu_etc_dir
$conf_dir = "${etc_dir}/conf.d"
$user = 'NT Authority\SYSTEM'
$group = 'Administrators'
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@

validations = {
'absolute_path' => {
:name => %w[log_dir],
:name => %w[log_dir sensu_etc_dir],
:valid => %w[/absolute/filepath /absolute/directory/],
:invalid => ['./relative/path', %w(array), { 'ha' => 'sh' }, 3, 2.42, true, false, nil],
:message => 'is not an absolute path',
Expand Down

0 comments on commit b454ab9

Please sign in to comment.