Skip to content

Commit

Permalink
Fix issues 230, 232, 235, and 249
Browse files Browse the repository at this point in the history
* Moved defaults to module data, and removed the params class
* Privatized all `splunk::enterprise::` and `splunk::forwarder::` install,
  config, and service classes
* Added a `$release` param, which replaces the `$version` param
  * For ensurable package_providers, the release is used as the Splunk package
    ensure, if specified
  * The release no longer defaults to a specific version and build, instead,
    the Splunk package resource defaults ensure to 'installed'
  * Added a Splunk::Release type
* Added a service_ensure param, per voxpupuli#249
* Modified splunk*_version facts to be part of splunkforwarder and splunkenterprise
  fact hashes
* Removed init.pp, which only served to confuse
* `$[enterprise,forwarder]_package_src` and `$package_source` params renamed to
  `$managed_package_source` and `$unmanaged_package_source`, for clarity
* Fixed: enterprise and forwarder password classes cross-referenced params

Fixes voxpupuli#230
Fixes voxpupuli#232
Fixes voxpupuli#235
Fixes voxpupuli#249
  • Loading branch information
nick-markowski committed Jul 31, 2019
1 parent 6e54f1a commit 14a596e
Show file tree
Hide file tree
Showing 36 changed files with 1,047 additions and 926 deletions.
57 changes: 57 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
splunk::enterprise::manage_password: false
splunk::enterprise::seed_password: false
splunk::enterprise::reset_seeded_password: false
splunk::enterprise::secret: 'hhy9DOGqli4.aZWCuGvz8stcqT2/OSJUZuyWHKc4wnJtQ6IZu2bfjeElgYmGHN9RWIT3zs5hRJcX1wGerpMNObWhFue78jZMALs3c3Mzc6CzM98/yGYdfcvWMo1HRdKn82LVeBJI5dNznlZWfzg6xdywWbeUVQZcOZtODi10hdxSJ4I3wmCv0nmkSWMVOEKHxti6QLgjfuj/MOoh8.2pM0/CqF5u6ORAzqFZ8Qf3c27uVEahy7ShxSv2K4K41z'
splunk::enterprise::password_hash: '$6$pIE/xAyP9mvBaewv$4GYFxC0SqonT6/x8qGcZXVCRLUVKODj9drDjdu/JJQ/Iw0Gg.aTkFzCjNAbaK4zcCHbphFz1g1HK18Z2bI92M0'
splunk::enterprise::password_content: ":admin:${password_hash}::Administrator:admin:changeme@example.com::"
splunk::enterprise::manage_package_source: true
splunk::enterprise::src_root: 'https://download.splunk.com'
splunk::enterprise::service_ensure: 'running'
splunk::enterprise::splunkd_port: 8089
splunk::enterprise::logging_port: 9997
splunk::enterprise::web_httpport: 8000
splunk::enterprise::server: 'splunk'
splunk::enterprise::boot_start: true
splunk::enterprise::use_default_config: true
splunk::enterprise::input_default_host: "${facts.fqdn}"
splunk::enterprise::input_connection_host: 'dns'
splunk::enterprise::splunkd_listen: '127.0.0.1'
splunk::enterprise::purge_alert_actions: false
splunk::enterprise::purge_authentication: false
splunk::enterprise::purge_authorize: false
splunk::enterprise::purge_deploymentclient: false
splunk::enterprise::purge_distsearch: false
splunk::enterprise::purge_indexes: false
splunk::enterprise::purge_inputs: false
splunk::enterprise::purge_limits: false
splunk::enterprise::purge_outputs: false
splunk::enterprise::purge_props: false
splunk::enterprise::purge_server: false
splunk::enterprise::purge_serverclass: false
splunk::enterprise::purge_transforms: false
splunk::enterprise::purge_uiprefs: false
splunk::enterprise::purge_web: false

splunk::forwarder::server: 'splunk'
splunk::forwarder::service_ensure: 'running'
splunk::forwarder::manage_package_source: true
splunk::forwarder::src_root: 'https://download.splunk.com'
splunk::forwarder::boot_start: true
splunk::forwarder::use_default_config: true
splunk::forwarder::splunkd_listen: '127.0.0.1'
splunk::forwarder::splunkd_port: 8089
splunk::forwarder::logging_port: 9997
splunk::forwarder::purge_deploymentclient: false
splunk::forwarder::purge_outputs: false
splunk::forwarder::purge_inputs: false
splunk::forwarder::purge_props: false
splunk::forwarder::purge_transforms: false
splunk::forwarder::purge_web: false
splunk::forwarder::manage_password: false
splunk::forwarder::seed_password: false
splunk::forwarder::reset_seeded_password: false
splunk::forwarder::secret: 'hhy9DOGqli4.aZWCuGvz8stcqT2/OSJUZuyWHKc4wnJtQ6IZu2bfjeElgYmGHN9RWIT3zs5hRJcX1wGerpMNObWhFue78jZMALs3c3Mzc6CzM98/yGYdfcvWMo1HRdKn82LVeBJI5dNznlZWfzg6xdywWbeUVQZcOZtODi10hdxSJ4I3wmCv0nmkSWMVOEKHxti6QLgjfuj/MOoh8.2pM0/CqF5u6ORAzqFZ8Qf3c27uVEahy7ShxSv2K4K41z'
splunk::forwarder::password_hash: '$6$pIE/xAyP9mvBaewv$4GYFxC0SqonT6/x8qGcZXVCRLUVKODj9drDjdu/JJQ/Iw0Gg.aTkFzCjNAbaK4zcCHbphFz1g1HK18Z2bI92M0'
splunk::forwarder::password_content: ":admin:${password_hash}::Administrator:admin:changeme@example.com::"
splunk::forwarder::addons: {}
25 changes: 25 additions & 0 deletions data/kernel/Linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---

splunk::enterprise::package_name: 'splunk'
splunk::enterprise::splunk_user: 'root'
splunk::enterprise::staging_dir: '/opt/staging/splunk'
splunk::enterprise::homedir: '/opt/splunk'
splunk::enterprise::path_delimiter: '/'
splunk::enterprise::seed_config_file: "%{lookup('splunk::enterprise::homedir')}/etc/system/local/user-seed.conf"
splunk::enterprise::password_config_file: "%{lookup('splunk::enterprise::homedir')}/etc/passwd"
splunk::enterprise::secret_file: "%{lookup('splunk::enterprise::homedir')}/etc/splunk.secret"
splunk::enterprise::confdir: "%{lookup('splunk::enterprise::homedir')}/etc"
splunk::enterprise::src_subdir: 'linux'
splunk::enterprise::install_options: []

splunk::forwarder::package_name: 'splunkforwarder'
splunk::forwarder::staging_dir: '/opt/staging/splunk'
splunk::forwarder::path_delimiter: '/'
splunk::forwarder::homedir: '/opt/splunkforwarder'
splunk::forwarder::confdir: "%{lookup('splunk::forwarder::homedir')}/etc"
splunk::forwarder::src_subdir: 'linux'
splunk::forwarder::install_options: []
splunk::forwarder::splunk_user: 'root'
splunk::forwarder::password_config_file: "%{lookup('splunk::forwarder::homedir')}/etc/passwd"
splunk::forwarder::seed_config_file: "%{lookup('splunk::forwarder::homedir')}/etc/system/local/user-seed.conf"
splunk::forwarder::secret_file: "%{lookup('splunk::forwarder::homedir')}/etc/splunk.secret"
25 changes: 25 additions & 0 deletions data/kernel/SunOS.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---

splunk::enterprise::package_name: 'splunk'
splunk::enterprise::splunk_user: 'root'
splunk::enterprise::staging_dir: '/opt/staging/splunk'
splunk::enterprise::homedir: '/opt/splunk'
splunk::enterprise::path_delimiter: '/'
splunk::enterprise::seed_config_file: "%{lookup('splunk::enterprise::homedir')}/etc/system/local/user-seed.conf"
splunk::enterprise::password_config_file: "%{lookup('splunk::enterprise::homedir')}/etc/passwd"
splunk::enterprise::secret_file: "%{lookup('splunk::enterprise::homedir')}/etc/splunk.secret"
splunk::enterprise::confdir: "%{lookup('splunk::enterprise::homedir')}/etc"
splunk::enterprise::src_subdir: 'solaris'
splunk::enterprise::install_options: []

splunk::forwarder::package_name: 'splunkforwarder'
splunk::forwarder::staging_dir: '/opt/staging/splunk'
splunk::forwarder::path_delimiter: '/'
splunk::forwarder::homedir: '/opt/splunkforwarder'
splunk::forwarder::confdir: "%{lookup('splunk::forwarder::homedir')}/etc"
splunk::forwarder::src_subdir: 'solaris'
splunk::forwarder::install_options: []
splunk::forwarder::splunk_user: 'root'
splunk::forwarder::password_config_file: "%{lookup('splunk::forwarder::homedir')}/etc/passwd"
splunk::forwarder::seed_config_file: "%{lookup('splunk::forwarder::homedir')}/etc/system/local/user-seed.conf"
splunk::forwarder::secret_file: "%{lookup('splunk::forwarder::homedir')}/etc/splunk.secret"
37 changes: 37 additions & 0 deletions data/kernel/Windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---

splunk::enterprise::package_name: 'Splunk Enterpirse'
splunk::enterprise::splunk_user: 'Administrator'
splunk::enterprise::staging_dir: "%{facts.archive_windir}\\splunk"
splunk::enterprise::homedir: 'C:\\Program Files\\Splunk'
splunk::enterprise::path_delimiter: '\\'
splunk::enterprise::seed_config_file: "%{lookup('splunk::enterprise::homedir')}\\etc\\system\\local\\user-seed.conf"
splunk::enterprise::password_config_file: "%{lookup('splunk::enterprise::homedir')}\\etc\\passwd"
splunk::enterprise::confdir: "%{lookup('splunk::enterprise::homedir')}\\etc"
splunk::enterprise::src_subdir: 'windows'
splunk::enterprise::install_options: [
{INSTALLDIR: "%{lookup('splunk::enterprise::homedir')}"},
{SPLUNKD_PORT: "%{lookup('splunk::enterprise::splunkd_port')}"},
'ARGEETOLICENSE=Yes',
'LAUNCHSPLUNK=0']

splunk::forwarder::splunk_user: 'Administrator'
splunk::forwarder::package_name: 'UniversalForwarder'
splunk::forwarder::staging_dir: "%{facts.archive_windir}\\splunk"
splunk::forwarder::homedir: 'C:\\Program Files\\SplunkUniversalForwarder'
splunk::forwarder::confdir: "%{lookup('splunk::forwarder::homedir')}\\etc"
splunk::forwarder::src_subdir: 'windows'
splunk::forwarder::path_delimiter: '\\'
splunk::forwarder::password_config_file: "%{lookup('splunk::forwarder::homedir')}\\etc\\passwd"
splunk::forwarder::seed_config_file: "%{lookup('splunk::forwarder::homedir')}\\etc\\system\\local\\user-seed.conf"
splunk::forwarder::install_options: [
{INSTALLDIR: "%{lookup('splunk::forwarder::homedir')}"},
'AGREETOLICENSE=Yes',
'LAUNCHSPLUNK=0',
'SERVICESTARTTYPE=auto',
'WINEVENTLOG_APP_ENABLE=1',
'WINEVENTLOG_SEC_ENABLE=1',
'WINEVENTLOG_SYS_ENABLE=1',
'WINEVENTLOG_FWD_ENABLE=1',
'WINEVENTLOG_SET_ENABLE=1',
'ENABLEADMON=1']
5 changes: 5 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

splunk::enterprise::package_provider: 'dpkg'

splunk::forwarder::package_provider: 'dpkg'
5 changes: 5 additions & 0 deletions data/os/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

splunk::enterprise::package_provider: 'rpm'

splunk::forwarder::package_provider: 'rpm'
5 changes: 5 additions & 0 deletions data/os/Solaris.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

splunk::enterprise::package_provider: 'sun'

splunk::forwarder::package_provider: 'sun'
5 changes: 5 additions & 0 deletions data/os/windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

splunk::enterprise::package_provider: 'windows'

splunk::forwarder::package_provider: 'windows'
16 changes: 16 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
version: 5

defaults:
datadir: data
data_hash: yaml_data

hierarchy:
- name: "OS family"
path: "os/%{facts.os.family}.yaml"

- name: "Kernel"
path: "kernel/%{facts.kernel}.yaml"

- name: "common"
path: "common.yaml"
11 changes: 6 additions & 5 deletions lib/facter/splunk_version.rb → lib/facter/splunkenterprise.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
Facter.add(:splunk_version) do
Facter.add(:splunkenterprise) do
setcode do
value = nil
splunk_hash = {}
cmd = if File.exist?('C:/Program Files/Splunk/bin/splunk.exe')
'"C:/Program Files/Splunk/bin/splunk.exe" --version'
elsif File.exist?('/opt/splunk/bin/splunk')
'/opt/splunk/bin/splunk --version'
end
if cmd
output = Facter::Util::Resolution.exec(cmd)
if output =~ %r{^Splunk ([0-9\.]+) \(} # rubocop:disable Style/IfUnlessModifier
value = Regexp.last_match(1)
if output =~ %r{^Splunk ([0-9\.]+) \(build\s*(.*)\)}
splunk_hash['version'] = Regexp.last_match(1)
splunk_hash['build'] = Regexp.last_match(2)
end
end
value
splunk_hash
end
end
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
Facter.add(:splunkforwarder_version) do
Facter.add(:splunkforwarder) do
setcode do
value = nil
splunkforwarder_hash = {}
cmd = if File.exist?('C:/Program Files/SplunkUniversalForwarder/bin/splunk.exe')
'"C:/Program Files/SplunkUniversalForwarder/bin/splunk.exe" --version'
elsif File.exist?('/opt/splunkforwarder/bin/splunk')
'/opt/splunkforwarder/bin/splunk --version'
end
if cmd
output = Facter::Util::Resolution.exec(cmd)
if output =~ %r{^Splunk Universal Forwarder ([0-9\.]+) \(}
value = Regexp.last_match(1)
if output =~ %r{^Splunk Universal Forwarder ([0-9\.]+) \(build\s*(.*)\)}
splunkforwarder_hash['version'] = Regexp.last_match(1)
splunkforwarder_hash['build'] = Regexp.last_match(2)
end
end
value
splunkforwarder_hash
end
end
38 changes: 21 additions & 17 deletions manifests/addon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,42 @@
# A hash of inputs to be configured as part of add-on installation, alterntively you can also define splunk_input or splunkforwarder_input resouces seperately
#
define splunk::addon (
Optional[Stdlib::Absolutepath] $splunk_home = undef,
Boolean $package_manage = true,
Optional[String[1]] $splunkbase_source = undef,
Optional[String[1]] $package_name = undef,
String[1] $owner = 'splunk',
Hash $inputs = {},
Hash $inputs = {},
String[1] $owner = 'splunk',
Boolean $package_manage = true,
Optional[String[1]] $splunkbase_source = undef,
Optional[Stdlib::Absolutepath] $splunk_home = undef,
Optional[String[1]] $package_name = undef,
) {

if defined(Class['splunk::forwarder']) {
$mode = 'forwarder'
} elsif defined(Class['splunk::enterprise']) {
}
elsif defined(Class['splunk::enterprise']) {
$mode = 'enterprise'
} else {
}
else {
fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]')
}


if $splunk_home {
$_splunk_home = $splunk_home
} else {
case $mode {
'forwarder': { $_splunk_home = $splunk::params::forwarder_homedir }
'enterprise': { $_splunk_home = $splunk::params::enterprise_homedir }
default: { fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]') }
case $mode {
'forwarder' : {
$_splunk_home = pick($splunk_home, $splunk::forwarder::homedir)
$_staging_dir = $splunk::forwarder::staging_dir
}
'enterprise': {
$_splunk_home = pick($splunk_home, $splunk::enterprise::homedir)
$_staging_dir = $splunk::enterprise::staging_dir
}
default : {
fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]') }
}

if $package_manage {
if $splunkbase_source {
$archive_name = $splunkbase_source.split('/')[-1]
archive { $name:
path => "${splunk::params::staging_dir}/${archive_name}",
path => "${_staging_dir}/${archive_name}",
user => $owner,
group => $owner,
source => $splunkbase_source,
Expand Down
Loading

0 comments on commit 14a596e

Please sign in to comment.