Skip to content

Commit

Permalink
Address post-merge comments on PR voxpupuli#224
Browse files Browse the repository at this point in the history
	Removes declaration of Class[splunk::params] since it should
	already be in scope and declared by either
	Class[splunk::enterprise] or Class[splunk::forwarder] and
	removes an unnecessary test of an empty hash. Modifies
	Splunk::Addon spec test to address the removal of
	Class[splunk::params].
  • Loading branch information
ody committed Apr 11, 2019
1 parent 820a15b commit 4922fd6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
45 changes: 20 additions & 25 deletions manifests/addon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
Hash $inputs = {},
) {

include splunk::params

if defined(Class['splunk::forwarder']) {
$mode = 'forwarder'
} else {
Expand All @@ -53,8 +51,7 @@

if $splunk_home {
$_splunk_home = $splunk_home
}
else {
} else {
case $mode {
'forwarder': { $_splunk_home = $splunk::params::forwarder_homedir }
'enterprise': { $_splunk_home = $splunk::params::enterprise_homedir }
Expand Down Expand Up @@ -84,30 +81,28 @@

file { "${_splunk_home}/etc/apps/${name}/local": ensure => directory }

unless $inputs.empty {
$inputs.each |$section, $attributes| {
$attributes.each |$setting, $value| {
case $mode {
'forwarder': {
splunkforwarder_input { "${name}_${section}_${setting}":
section => $section,
setting => $setting,
value => $value,
context => "apps/${name}/local",
require => File["${_splunk_home}/etc/apps/${name}/local"],
}
$inputs.each |$section, $attributes| {
$attributes.each |$setting, $value| {
case $mode {
'forwarder': {
splunkforwarder_input { "${name}_${section}_${setting}":
section => $section,
setting => $setting,
value => $value,
context => "apps/${name}/local",
require => File["${_splunk_home}/etc/apps/${name}/local"],
}
'enterprise': {
splunk_input { "${name}_${section}_${setting}":
section => $section,
setting => $setting,
value => $value,
context => "apps/${name}/local",
require => File["${_splunk_home}/etc/apps/${name}/local"],
}
}
'enterprise': {
splunk_input { "${name}_${section}_${setting}":
section => $section,
setting => $setting,
value => $value,
context => "apps/${name}/local",
require => File["${_splunk_home}/etc/apps/${name}/local"],
}
default: { fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]') }
}
default: { fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]') }
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions spec/defines/addon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

describe 'splunk::addon' do
context 'supported operating systems' do
let(:pre_condition) do
'include splunk::forwarder'
end
on_supported_os.each do |os, facts|
if os.start_with?('windows')
# Splunk Server not used supported on windows
Expand Down

0 comments on commit 4922fd6

Please sign in to comment.