diff --git a/README.md b/README.md index ad9ac2a5d..ec4178f56 100644 --- a/README.md +++ b/README.md @@ -813,6 +813,9 @@ Enables or disables the `checker` feature. ##### `ensure` Either `present` or `absent`. Defines if the feature `checker` should be enabled. Defaults to `present`. +##### `concurrent_checks` +The maximum number of concurrent checks. Defaults to `512`. + #### Class: `icinga2::feature::mainlog` Enables or disables the `mainlog` feature. diff --git a/manifests/feature/checker.pp b/manifests/feature/checker.pp index c0ea41fbc..6fa08b7e2 100644 --- a/manifests/feature/checker.pp +++ b/manifests/feature/checker.pp @@ -7,9 +7,13 @@ # [*ensure*] # Set to present enables the feature checker, absent disabled it. Defaults to present. # +# [*concurrent_checks*] +# The maximum number of concurrent checks. Defaults to 512. +# # class icinga2::feature::checker( - $ensure = present, + $ensure = present, + $concurrent_checks = undef, ) { $conf_dir = $::icinga2::params::conf_dir @@ -18,12 +22,19 @@ validate_re($ensure, [ '^present$', '^absent$' ], "${ensure} isn't supported. Valid values are 'present' and 'absent'.") + if $concurrent_checks { validate_integer($concurrent_checks) } + + # compose attributes + $attrs = { + concurrent_checks => $concurrent_checks, + } + # create object icinga2::object { 'icinga2::object::CheckerComponent::checker': object_name => 'checker', object_type => 'CheckerComponent', - attrs => {}, - attrs_list => [], + attrs => delete_undef_values($attrs), + attrs_list => keys($attrs), target => "${conf_dir}/features-available/checker.conf", order => '10', notify => $ensure ? { diff --git a/spec/classes/checker_spec.rb b/spec/classes/checker_spec.rb index e22022057..7f6bff1c6 100644 --- a/spec/classes/checker_spec.rb +++ b/spec/classes/checker_spec.rb @@ -29,6 +29,23 @@ it { is_expected.to contain_icinga2__object('icinga2::object::CheckerComponent::checker') .with({ 'target' => '/etc/icinga2/features-available/checker.conf' }) } end + + + context "#{os} with concurrent_checks => 100" do + let(:params) { {:concurrent_checks => 100} } + + it { is_expected.to contain_concat__fragment('icinga2::object::CheckerComponent::checker') + .with({ 'target' => '/etc/icinga2/features-available/checker.conf' }) + .with_content(/concurrent_checks = 100/) } + end + + + context "#{os} with concurrent_checks => foo (not a valid integer)" do + let(:params) { {:concurrent_checks => 'foo'} } + + it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } + end + end end @@ -74,4 +91,20 @@ it { is_expected.to contain_icinga2__object('icinga2::object::CheckerComponent::checker') .with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/checker.conf' }) } end + + + context "Windows 2012 R2 with concurrent_checks => 100" do + let(:params) { {:concurrent_checks => 100} } + + it { is_expected.to contain_concat__fragment('icinga2::object::CheckerComponent::checker') + .with({ 'target' => 'C:/ProgramData/icinga2/etc/icinga2/features-available/checker.conf' }) + .with_content(/concurrent_checks = 100/) } + end + + + context "Windows 2012 R2 with concurrent_checks => foo (not a valid integer)" do + let(:params) { {:concurrent_checks => 'foo'} } + + it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) } + end end \ No newline at end of file