Skip to content

Commit

Permalink
Added support for other se only parameters sensu#849
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Nov 29, 2017
1 parent a76fd04 commit 8932801
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 16 deletions.
8 changes: 7 additions & 1 deletion manifests/enterprise.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#
# @param max_open_files Value of the MAX_OPEN_FILES environment variable.
#
# @param heap_dump_path Value of the HEAP_DUMP_PATH environment variable.
#
# @param java_opts Value of the JAVA_OPTS environment variable.
#
class sensu::enterprise (
Optional[String] $deregister_handler = $::sensu::deregister_handler,
Optional[Boolean] $deregister_on_stop = $::sensu::deregister_on_stop,
Expand All @@ -42,6 +46,8 @@
Optional[Boolean] $use_embedded_ruby = $::sensu::use_embedded_ruby,
Variant[Undef,Integer,Pattern[/^(\d+)/]] $heap_size = $::sensu::heap_size,
Variant[Undef,Integer,Pattern[/^(\d+)$/]] $max_open_files = $::sensu::max_open_files,
Variant[Undef,String] $heap_dump_path = $::sensu::heap_dump_path,
Variant[Undef,String] $java_opts = $::sensu::java_opts,
Boolean $hasrestart = $::sensu::hasrestart,
){

Expand All @@ -54,7 +60,7 @@

file { '/etc/default/sensu-enterprise':
ensure => file,
content => template("${module_name}/sensu.erb"),
content => template("${module_name}/sensu-enterprise.erb"),
owner => '0',
group => '0',
mode => '0444',
Expand Down
9 changes: 7 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@
# Note: This has effect only on Sensu Enterprise.
#
# @param max_open_files Value of the MAX_OPEN_FILES environment variable.
# Note: This has effect only on Sensu Enterprise.
#
# @param heap_dump_path Value of the HEAP_DUMP_PATH environment variable.
#
# @param java_opts Value of the JAVA_OPTS environment variable.
#
class sensu (
Pattern[/^absent$/, /^installed$/, /^latest$/, /^present$/, /^[\d\.\-el]+$/] $version = 'installed',
Expand Down Expand Up @@ -429,7 +432,9 @@
String $windows_package_title = 'sensu',
Optional[Variant[Stdlib::Absolutepath,Array[Stdlib::Absolutepath]]] $confd_dir = undef,
Variant[Integer,Pattern[/^(\d+)/],Undef] $heap_size = undef,
Variant[Integer,Pattern[/^(\d+)$/],Undef] $max_open_files = undef,
Variant[Undef,Integer,Pattern[/^(\d+)$/]] $max_open_files = undef,
Variant[Undef,String] $heap_dump_path = undef,
Variant[Undef,String] $java_opts = undef,
### START Hiera Lookups###
Hash $extensions = {},
Hash $handlers = {},
Expand Down
4 changes: 0 additions & 4 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
# @param heap_size Value of the HEAP_SIZE environment variable.
# Note: This has no effect on sensu-core.
#
# @param max_open_files Value of the MAX_OPEN_FILES environment variable.
# Note: This has effect only on Sensu Enterprise.
#
# @param deregister_handler The handler to use when deregistering a client on stop.
#
# @param deregister_on_stop Whether the sensu client should deregister from the API on service stop
Expand Down Expand Up @@ -41,7 +38,6 @@
Optional[String] $conf_dir = $::sensu::conf_dir,
Variant[String,Array,Undef] $confd_dir = $::sensu::confd_dir,
Variant[Undef,Integer,Pattern[/^(\d+)/]] $heap_size = $::sensu::heap_size,
Variant[Undef,Integer,Pattern[/^(\d+)$/]] $max_open_files = $::sensu::max_open_files,
Optional[String] $deregister_handler = $::sensu::deregister_handler,
Optional[Boolean] $deregister_on_stop = $::sensu::deregister_on_stop,
Optional[String] $gem_path = $::sensu::gem_path,
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/sensu_enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@
it { should contain_file('/etc/default/sensu-enterprise').with_content(%r{^MAX_OPEN_FILES="20000"$}) }
end

context 'heap_dump_path => /tmp/test' do
let(:params) { params_base.merge({:heap_dump_path => '/tmp/test' }) }
it { should contain_file('/etc/default/sensu-enterprise').with_content(%r{^HEAP_DUMP_PATH="/tmp/test"$}) }
end

context 'java_opts => -Xms256m -Xmx512m' do
let(:params) { params_base.merge({:java_opts => '-Xms256m -Xmx512m' }) }
it { should contain_file('/etc/default/sensu-enterprise').with_content(%r{^JAVA_OPTS="-Xms256m -Xmx512m"$}) }
end

context 'with manage_services => false' do
let(:params) { {
:enterprise_user => 'sensu',
Expand Down
5 changes: 0 additions & 5 deletions spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,6 @@
it { should contain_file('/etc/default/sensu').with_content(%r{^HEAP_SIZE="256M"$}) }
end

context 'max_open_files => 10000' do
let(:params) { {:max_open_files => 10000 } }
it { should contain_file('/etc/default/sensu').with_content(%r{^MAX_OPEN_FILES="10000"$}) }
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') }
Expand Down
30 changes: 30 additions & 0 deletions templates/sensu-enterprise.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
EMBEDDED_RUBY=<%= @use_embedded_ruby %>
LOG_LEVEL=<%= @log_level %>
LOG_DIR=<%= @log_dir %>
<% if not @rubyopt.nil? -%>
RUBYOPT="<%= @rubyopt %>"
<% end -%>
<% if not @gem_path.nil? -%>
GEM_PATH="<%= @gem_path %>"
<% end -%>
<% if @deregister_on_stop -%>
CLIENT_DEREGISTER_ON_STOP=true
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 -%>
<% if @heap_size -%>
HEAP_SIZE="<%= @heap_size %>"
<% end -%>
<% if @max_open_files -%>
MAX_OPEN_FILES="<%= @max_open_files %>"
<% end -%>
<% if @heap_dump_path -%>
HEAP_DUMP_PATH="<%= @heap_dump_path %>"
<% end -%>
<% if @java_opts -%>
JAVA_OPTS="<%= @java_opts %>"
<% end -%>
3 changes: 0 additions & 3 deletions templates/sensu.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ CONFD_DIR="<%= @conf_dir %>,<%= Array(@confd_dir).join(",") %>"
<% if @heap_size -%>
HEAP_SIZE="<%= @heap_size %>"
<% end -%>
<% if @max_open_files -%>
MAX_OPEN_FILES="<%= @max_open_files %>"
<% end -%>
2 changes: 1 addition & 1 deletion tests/provision_server.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# setup module dependencies
puppet module install puppetlabs/rabbitmq
puppet module install puppet/rabbitmq

# install dependencies for sensu
yum -y install redis jq nagios-plugins-ntp
Expand Down

0 comments on commit 8932801

Please sign in to comment.