Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose splunk forwarder windows install options #14

Merged
merged 2 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.*.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
6 changes: 5 additions & 1 deletion manifests/forwarder.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
# [*splunkd_port*]
# The splunkd port. Used as a default for both splunk and splunk::forwarder.
#
# [*install_options*]
# The splunkd forwarder installation options. Only applicable for Windows.
#
# [*splunkd_listen*]
# The address on which splunkd should listen. Defaults to localhost only.
#
Expand All @@ -47,6 +50,7 @@
$package_ensure = $splunk::params::forwarder_pkg_ensure,
$logging_port = $splunk::params::logging_port,
$splunkd_port = $splunk::params::splunkd_port,
$install_options = $splunk::params::forwarder_install_options,
$splunkd_listen = '127.0.0.1',
$purge_inputs = false,
$purge_outputs = false,
Expand Down Expand Up @@ -80,7 +84,7 @@
provider => $pkg_provider,
source => $pkg_source,
before => Service[$virtual_service],
install_options => $splunk::params::forwarder_install_options,
install_options => $install_options,
tag => 'splunk_forwarder',
}
# Declare inputs and outputs specific to the forwarder profile
Expand Down
51 changes: 35 additions & 16 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@
# Requires: nothing
#
class splunk::params (
$version = '5.0.5',
$build = '179365',
$src_root = 'puppet:///modules/splunk',
$splunkd_port = '8089',
$logging_port = '9997',
$server = 'splunk'
$version = '5.0.5',
$build = '179365',
$src_root = 'puppet:///modules/splunk',
$splunkd_port = '8089',
$logging_port = '9997',
$server = 'splunk'
$forwarder_installdir = undef,
$server_installdir = undef,
) {

# Based on the small number of inputs above, we can construct sane defaults
Expand All @@ -85,40 +87,48 @@
$password_content = ':admin:$6$pIE/xAyP9mvBaewv$4GYFxC0SqonT6/x8qGcZXVCRLUVKODj9drDjdu/JJQ/Iw0Gg.aTkFzCjNAbaK4zcCHbphFz1g1HK18Z2bI92M0::Administrator:admin:changeme@example.com::'


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 {
'Linux': {
$path_delimiter = '/'
$forwarder_src_subdir = 'universalforwarder/linux'
$forwarder_service = [ 'splunk' ]
$password_config_file = '/opt/splunkforwarder/etc/passwd'
$forwarder_confdir = '/opt/splunkforwarder/etc/system/local'
$secret_file = '/opt/splunkforwarder/etc/splunk.secret'
$password_config_file = "${forwarder_dir}/etc/passwd"
$secret_file = "${forwarder_dir}/etc/splunk.secret"
$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' ]
$password_config_file = '/opt/splunkforwarder/etc/passwd'
$forwarder_confdir = '/opt/splunkforwarder/etc/system/local'
$secret_file = '/opt/splunkforwarder/etc/splunk.secret'
$password_config_file = "${forwarder_dir}/etc/passwd"
$secret_file = "${forwarder_dir}/etc/splunk.secret"
$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'
$password_config_file = 'C:/Program Files/SplunkUniversalForwarder/etc/passwd'
$secret_file = 'C:/Program Files/SplunkUniversalForwarder/etc/splunk.secret'
$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 @@ -129,6 +139,7 @@
'WINEVENTLOG_FWD_ENABLE=1',
'WINEVENTLOG_SET_ENABLE=1',
'ENABLEADMON=1',
"INSTALLDIR=\"${forwarder_dir}\"",
]
$server_install_options = [
'LAUNCHSPLUNK=1',
Expand Down Expand Up @@ -227,4 +238,12 @@
$create_password = true

$forwarder_pkg_ensure = 'installed'

# 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,
}
}