Skip to content

Commit

Permalink
Add confd_dir parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
bodgit committed Jul 19, 2017
1 parent c2b013b commit bcef61c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@
# Add/Remove programs. Note this is distinct from the package filename
# identifier specified with windows_package_name.
# Default: 'Sensu'
#
# [*confd_dir*]
# String, Array of strings. Additional directories to load configuration
# snippets from.
# Default: undef

class sensu (
$version = 'installed',
Expand Down Expand Up @@ -552,6 +557,7 @@
$windows_choco_repo = undef,
$windows_package_name = 'Sensu',
$windows_package_title = 'sensu',
$confd_dir = undef,

### START Hiera Lookups ###
$extensions = {},
Expand Down
13 changes: 12 additions & 1 deletion manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
#
# == Parameters
#
# [*conf_dir*]
# String. The default configuration directory.
# Default: $::sensu::conf_dir
#
# [*confd_dir*]
# String, Array of strings. Additional directories to load configuration
# snippets from.
# Default: $::sensu::confd_dir
#
# [*deregister_handler*]
# String. The handler to use when deregistering a client on stop.
# Default: $::sensu::deregister_handler
Expand Down Expand Up @@ -48,6 +57,8 @@
# Valid values: true, false
#
class sensu::package (
$conf_dir = $::sensu::conf_dir,
$confd_dir = $::sensu::confd_dir,
$deregister_handler = $::sensu::deregister_handler,
$deregister_on_stop = $::sensu::deregister_on_stop,
$gem_path = $::sensu::gem_path,
Expand Down Expand Up @@ -199,7 +210,7 @@
}
}

file { [ $::sensu::conf_dir, "${sensu::conf_dir}/handlers", "${sensu::conf_dir}/checks", "${sensu::conf_dir}/filters", "${sensu::conf_dir}/extensions", "${sensu::conf_dir}/mutators", "${sensu::conf_dir}/contacts" ]:
file { [ $conf_dir, "${conf_dir}/handlers", "${conf_dir}/checks", "${conf_dir}/filters", "${conf_dir}/extensions", "${conf_dir}/mutators", "${conf_dir}/contacts" ]:
ensure => directory,
owner => $::sensu::user,
group => $::sensu::group,
Expand Down
6 changes: 6 additions & 0 deletions spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
it { should contain_file('/etc/default/sensu').without_content(%r{^CLIENT_DEREGISTER_ON_STOP=true\nCLIENT_DEREGISTER_HANDLER=.*$}) }
it { should contain_file('/etc/default/sensu').with_content(%r{^SERVICE_MAX_WAIT="10"$}) }
it { should contain_file('/etc/default/sensu').with_content(%r{^PATH=\$PATH$}) }
it { should contain_file('/etc/default/sensu').without_content(%r{^CONFD_DIR=.*$}) }
it { should_not contain_file('C:/opt/sensu/bin/sensu-client.xml') }

describe 'osfamily windows' do
Expand Down Expand Up @@ -157,6 +158,11 @@
it { should contain_file('/etc/default/sensu').with_content(%r{^PATH=/spec/tests$}) }
end

context 'confd_dir => /spec/tests' do
let(:params) { {:confd_dir => '/spec/tests' } }
it { should contain_file('/etc/default/sensu').with_content(%r{^CONFD_DIR=/etc/sensu/conf\.d,/spec/tests$}) }
end

context 'with plugins => puppet:///data/sensu/plugins/teststring.rb' do
let(:params) { {:plugins => 'puppet:///data/sensu/plugins/teststring.rb' } }
it { should contain_sensu__plugin('puppet:///data/sensu/plugins/teststring.rb').with_install_path('/etc/sensu/plugins') }
Expand Down
6 changes: 6 additions & 0 deletions spec/classes/sensu_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
it { should contain_file('/etc/default/sensu').without_content(%r{^CLIENT_DEREGISTER_ON_STOP=true\nCLIENT_DEREGISTER_HANDLER=.*$}) }
it { should contain_file('/etc/default/sensu').with_content(%r{^SERVICE_MAX_WAIT="10"$}) }
it { should contain_file('/etc/default/sensu').with_content(%r{^PATH=\$PATH$}) }
it { should contain_file('/etc/default/sensu').without_content(%r{^CONFD_DIR=.*$}) }
directories.each do |dir|
it { should contain_file(dir).with(
:ensure => 'directory',
Expand Down Expand Up @@ -465,6 +466,11 @@
it { should contain_file('/etc/default/sensu').with_content(%r{^PATH=/spec/tests$}) }
end

context 'confd_dir => /spec/tests' do
let(:params) { {:confd_dir => '/spec/tests' } }
it { should contain_file('/etc/default/sensu').with_content(%r{^CONFD_DIR=/etc/sensu/conf\.d,/spec/tests$}) }
end

describe 'spawn_limit (#727)' do
context 'default (undef)' do
it { should contain_file('/etc/sensu/conf.d/spawn.json').without_content }
Expand Down
3 changes: 3 additions & 0 deletions templates/sensu.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ CLIENT_DEREGISTER_HANDLER="<%= @deregister_handler %>"
<% end -%>
SERVICE_MAX_WAIT="<%= @init_stop_max_wait %>"
PATH=<%= @path %>
<% if @confd_dir -%>
CONFD_DIR="<%= @conf_dir %>,<%= Array(@confd_dir).join(",") %>"
<% end -%>

0 comments on commit bcef61c

Please sign in to comment.