Skip to content

Commit

Permalink
Add ability to specify windows install dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanliu committed Jan 30, 2015
1 parent 1658db6 commit d51b0f4
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 40 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
*.swp
.*.sw?
.bundle
.pkg
.ruby-version
.vagrant
Gemfile.lock
modules/
spec/fixtures
16 changes: 9 additions & 7 deletions lib/puppet/provider/splunkforwarder_input/ini_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# set ini_setting as the parent provider
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
# hard code the file path (this allows purging)

def self.prefetch(resources)
catalog = resources[resources.keys.first].catalog
splunk_config = catalog.resources.find{|s| s.type == :splunk_config}
confdir = splunk_config['forwarder_confdir'] || raise(Puppet::Error, 'Unknown splunk forwarder confdir')
@file_path = File.join(confdir, 'inputs.conf')
end

def self.file_path
case Facter.value(:osfamily)
when 'windows'
'C:\Program Files\SplunkUniversalForwarder\etc\system\local\inputs.conf'
else
'/opt/splunkforwarder/etc/system/local/inputs.conf'
end
@file_path
end
end
16 changes: 9 additions & 7 deletions lib/puppet/provider/splunkforwarder_output/ini_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# set ini_setting as the parent provider
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
# hard code the file path (this allows purging)

def self.prefetch(resources)
catalog = resources[resources.keys.first].catalog
splunk_config = catalog.resources.find{|s| s.type == :splunk_config}
confdir = splunk_config['forwarder_confdir'] || raise(Puppet::Error, 'Unknown splunk forwarder confdir')
@file_path = File.join(confdir, 'outputs.conf')
end

def self.file_path
case Facter.value(:osfamily)
when 'windows'
'C:\Program Files\SplunkUniversalForwarder\etc\system\local\outputs.conf'
else
'/opt/splunkforwarder/etc/system/local/outputs.conf'
end
@file_path
end
end
16 changes: 9 additions & 7 deletions lib/puppet/provider/splunkforwarder_props/ini_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# set ini_setting as the parent provider
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
# hard code the file path (this allows purging)

def self.prefetch(resources)
catalog = resources[resources.keys.first].catalog
splunk_config = catalog.resources.find{|s| s.type == :splunk_config}
confdir = splunk_config['forwarder_confdir'] || raise(Puppet::Error, 'Unknown splunk forwarder confdir')
@file_path = File.join(confdir, 'props.conf')
end

def self.file_path
case Facter.value(:osfamily)
when 'windows'
'C:\Program Files\SplunkUniversalForwarder\etc\system\local\props.conf'
else
'/opt/splunkforwarder/etc/system/local/props.conf'
end
@file_path
end
end
16 changes: 9 additions & 7 deletions lib/puppet/provider/splunkforwarder_transforms/ini_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
# set ini_setting as the parent provider
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
# hard code the file path (this allows purging)

def self.prefetch(resources)
catalog = resources[resources.keys.first].catalog
splunk_config = catalog.resources.find{|s| s.type == :splunk_config}
confdir = splunk_config['forwarder_confdir'] || raise(Puppet::Error, 'Unknown splunk forwarder confdir')
@file_path = File.join(confdir, 'transforms.conf')
end

def self.file_path
case Facter.value(:osfamily)
when 'windows'
'C:\Program Files\SplunkUniversalForwarder\etc\system\local\transforms.conf'
else
'/opt/splunkforwarder/etc/system/local/transforms.conf'
end
@file_path
end
end
17 changes: 17 additions & 0 deletions lib/puppet/type/splunk_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Puppet::Type.newtype(:splunk_config) do
newparam(:name, :namevar => true) do
desc 'splunk config'
end

newparam(:forwarder_installdir) do
end

newparam(:forwarder_confdir) do
end

newparam(:server_installdir) do
end

newparam(:server_confdir) do
end
end
40 changes: 29 additions & 11 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
# Requires: nothing
#
class splunk::params (
$version = '5.0.5',
$build = '179365',
$src_root = 'puppet:///modules/splunk',
$splunkd_port = '8089',
$logging_port = '9997',
$version = '5.0.5',
$build = '179365',
$src_root = 'puppet:///modules/splunk',
$splunkd_port = '8089',
$logging_port = '9997',
$forwarder_installdir = undef,
$server_installdir = undef,
) {

# Based on the small number of inputs above, we can construct sane defaults
Expand All @@ -80,35 +82,43 @@
# Settings common to everything
$staging_subdir = 'splunk'

if $::osfamily == 'Windows' {
$forwarder_dir = pick($forwarder_installdir, 'C:/Program Files/SplunkUniversalForwarder')
$server_dir = pick($server_installdir, 'C:/Program Files/Splunk')
} else {
$forwarder_dir = pick($forwarder_installdir, '/opt/splunkforwarder')
$server_dir = pick($server_installdir, '/opt/splunk')
}

# Settings common to a kernel
case $::kernel {
default: { fail("splunk module does not support kernel ${::kernel}") }
'Linux': {
$path_delimiter = '/'
$forwarder_src_subdir = 'universalforwarder/linux'
$forwarder_service = [ 'splunk' ]
$forwarder_confdir = '/opt/splunkforwarder/etc/system/local'
$forwarder_confdir = "${forwarder_dir}/etc/system/local"
$server_src_subdir = 'splunk/linux'
$server_service = [ 'splunk', 'splunkd', 'splunkweb' ]
$server_confdir = '/opt/splunk/etc/system/local'
$server_confdir = "${server_dir}/etc/system/local"
}
'SunOS': {
$path_delimiter = '/'
$forwarder_src_subdir = 'universalforwarder/solaris'
$forwarder_service = [ 'splunk' ]
$forwarder_confdir = '/opt/splunkforwarder/etc/system/local'
$forwarder_confdir = "${forwarder_dir}/etc/system/local"
$server_src_subdir = 'splunk/solaris'
$server_service = [ 'splunk', 'splunkd', 'splunkweb' ]
$server_confdir = '/opt/splunk/etc/system/local'
$server_confdir = "${server_dir}/etc/system/local"
}
'Windows': {
$path_delimiter = '\\'
$forwarder_src_subdir = 'universalforwarder/windows'
$forwarder_service = [ 'SplunkForwarder' ] # UNKNOWN
$forwarder_confdir = 'C:/Program Files/SplunkUniversalForwarder/etc/system/local'
$forwarder_confdir = "${forwarder_dir}/etc/system/local"
$server_src_subdir = 'splunk/windows'
$server_service = [ 'Splunkd', 'Splunkweb' ] # UNKNOWN
$server_confdir = 'C:/Program Files/Splunk/etc/system/local' # UNKNOWN
$server_confdir = "${server_dir}/etc/system/local"
$forwarder_install_options = [
'AGREETOLICENSE=Yes',
'LAUNCHSPLUNK=0',
Expand All @@ -119,6 +129,7 @@
'WINEVENTLOG_FWD_ENABLE=1',
'WINEVENTLOG_SET_ENABLE=1',
'ENABLEADMON=1',
"INSTALLDIR=\"${forwarder_dir}\"",
]
$server_install_options = [
'LAUNCHSPLUNK=1',
Expand Down Expand Up @@ -190,4 +201,11 @@
$server_pkg_src = "${src_root}/${server_src_subdir}/${server_src_pkg}"
$forwarder_pkg_src = "${src_root}/${forwarder_src_subdir}/${forwarder_src_pkg}"

# A meta resource so providers know where splunk is installed:
splunk_config { 'splunk':
forwarder_installdir => $forwarder_dir,
forwarder_confdir => $forwarder_confdir,
server_installdir => $server_dir,
server_confdir => $server_confdir,
}
}

0 comments on commit d51b0f4

Please sign in to comment.