From 44bd5cafa56998d0194931d01c1d04359f8286f1 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 14:09:13 -0500 Subject: [PATCH 1/7] Splunk environments where the majority of the configuration is handled by splunk do not necessarily like these defaults. So allow a way to not provide them. Either by setting undef or passing empty (nil) from hiera. --- manifests/forwarder.pp | 14 ++++++++++++-- spec/classes/forwarder_spec.rb | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/manifests/forwarder.pp b/manifests/forwarder.pp index daf7f49f..2deea98b 100644 --- a/manifests/forwarder.pp +++ b/manifests/forwarder.pp @@ -38,6 +38,12 @@ # If set to true, will remove any outputs.conf configuration not supplied by # Puppet from the target system. Defaults to false. # +# [*forwarder_output*] +# Hash of output configs. If undefined will not populate the outputs.conf file. +# +# [*forwarder_input*] +# Hash of input configs. If undefined will not populate the inputs.conf file. +# # Actions: # # Declares parameters to be consumed by other classes in the splunk module. @@ -112,8 +118,12 @@ # Declare inputs and outputs specific to the forwarder profile $tag_resources = { tag => 'splunk_forwarder' } - create_resources( 'splunkforwarder_input',$forwarder_input, $tag_resources) - create_resources( 'splunkforwarder_output',$forwarder_output, $tag_resources) + if $forwarder_input != undef { + create_resources( 'splunkforwarder_input',$forwarder_input, $tag_resources) + } + if $forwarder_output != undef { + create_resources( 'splunkforwarder_output',$forwarder_output, $tag_resources) + } # this is default splunkforwarder_web { 'forwarder_splunkd_port': section => 'settings', diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index f2bcb09a..a385eac1 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -8,6 +8,16 @@ context 'with defaults' do it { is_expected.to compile.with_all_deps } end + + context 'with forwarder_outputs set to undef' do + let(:params) { forwarder_outputs => :undef } + it { is_expected.to compile.with_all_deps } + end + + context 'with forwarder_inputs set to undef' do + let(:params) { forwarder_inputs => :undef } + it { is_expected.to compile.with_all_deps } + end end end end From c0c79a3d7bb1c18811e4f400bb4de130806586c8 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 14:20:59 -0500 Subject: [PATCH 2/7] missing squiglies --- spec/classes/forwarder_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index a385eac1..4b2737cd 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -10,12 +10,12 @@ end context 'with forwarder_outputs set to undef' do - let(:params) { forwarder_outputs => :undef } + let(:params) { { forwarder_outputs => :undef } } it { is_expected.to compile.with_all_deps } end context 'with forwarder_inputs set to undef' do - let(:params) { forwarder_inputs => :undef } + let(:params) { { forwarder_inputs => :undef } } it { is_expected.to compile.with_all_deps } end end From e012c02fa290172cdafd8701710d18279210b259 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 14:31:37 -0500 Subject: [PATCH 3/7] Simplify conditional check to boolean state --- manifests/forwarder.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/forwarder.pp b/manifests/forwarder.pp index 2deea98b..11bda731 100644 --- a/manifests/forwarder.pp +++ b/manifests/forwarder.pp @@ -118,10 +118,10 @@ # Declare inputs and outputs specific to the forwarder profile $tag_resources = { tag => 'splunk_forwarder' } - if $forwarder_input != undef { + if $forwarder_input { create_resources( 'splunkforwarder_input',$forwarder_input, $tag_resources) } - if $forwarder_output != undef { + if $forwarder_output { create_resources( 'splunkforwarder_output',$forwarder_output, $tag_resources) } # this is default From a6709a6217a869f5290ec93df554afef38ab2e20 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 14:33:30 -0500 Subject: [PATCH 4/7] Remove plurality in tests --- spec/classes/forwarder_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index 4b2737cd..5acb3095 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -9,13 +9,13 @@ it { is_expected.to compile.with_all_deps } end - context 'with forwarder_outputs set to undef' do - let(:params) { { forwarder_outputs => :undef } } + context 'with forwarder_output set to undef' do + let(:params) { { forwarder_output => :undef } } it { is_expected.to compile.with_all_deps } end - context 'with forwarder_inputs set to undef' do - let(:params) { { forwarder_inputs => :undef } } + context 'with forwarder_input set to undef' do + let(:params) { { forwarder_input => :undef } } it { is_expected.to compile.with_all_deps } end end From eb606f42d14d6814efdcbdaac7dc225757309580 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 14:56:14 -0500 Subject: [PATCH 5/7] Extra lines after let() --- spec/classes/forwarder_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index 5acb3095..652c0efe 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -11,11 +11,13 @@ context 'with forwarder_output set to undef' do let(:params) { { forwarder_output => :undef } } + it { is_expected.to compile.with_all_deps } end context 'with forwarder_input set to undef' do let(:params) { { forwarder_input => :undef } } + it { is_expected.to compile.with_all_deps } end end From f6e6aa7bb0f38dd84bdaa9b522e054342d4af02c Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 19:00:31 -0500 Subject: [PATCH 6/7] params are symbols too --- spec/classes/forwarder_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index 652c0efe..e002aa2f 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -10,13 +10,13 @@ end context 'with forwarder_output set to undef' do - let(:params) { { forwarder_output => :undef } } + let(:params) { { :forwarder_output => :undef } } it { is_expected.to compile.with_all_deps } end context 'with forwarder_input set to undef' do - let(:params) { { forwarder_input => :undef } } + let(:params) { { :forwarder_input => :undef } } it { is_expected.to compile.with_all_deps } end From 43c7e45e24528f2dd84fd73901f327281cd1f297 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Thu, 18 Oct 2018 20:16:36 -0500 Subject: [PATCH 7/7] really they are strings and ireally need to squash this nonsense --- spec/classes/forwarder_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index e002aa2f..2291f1a3 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -10,13 +10,13 @@ end context 'with forwarder_output set to undef' do - let(:params) { { :forwarder_output => :undef } } + let(:params) { { 'forwarder_output' => :undef } } it { is_expected.to compile.with_all_deps } end context 'with forwarder_input set to undef' do - let(:params) { { :forwarder_input => :undef } } + let(:params) { { 'forwarder_input' => :undef } } it { is_expected.to compile.with_all_deps } end