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

Add Edge Processor support #389

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions lib/puppet/type/splunk_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

newparam(:server_confdir) do
end

newparam(:edgeproc_installdir) do
end

newparam(:edgeproc_confdir) do
end
# rubocop:enable Lint/EmptyBlock

## Generate purge parameters for the splunk_config type
Expand Down
55 changes: 55 additions & 0 deletions manifests/edgeprocessor.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# @summary
# Install and configure an instance of Splunk Edge Processor. This module assumes you're using systemd.
#
# @example Basic usage
# include splunk::edgeprocessor
#
# @param splunk_user
# The user to run Splunk as
#
# @param package_url
# URL to download the Edge Processor from, expected as a tar.gz file.
#
# @param validate_package_checksum
# Boolean, will skip checksum validation of downloaded package if False
#
# @param checksum_type
# none|md5|sha1|sha2|sha256|sha384|sha512
#
# @param splunk_package_checksum
# Checksum of archive package provided by Splunk
#
# @param splunk_homedir
# Directory to install Splunk Edge Processor
#
# @param scs_group_id
# Splunk Cloud Service Edge Processor cluster ID
class splunk::edgeprocessor (
String[1] $splunk_user = $splunk::params::splunk_user,
Stdlib::HTTPSUrl $package_url = $splunk::params::edgeproc_package_src,
Boolean $validate_package_checksum = true,
String[1] $checksum_type = $splunk::params::edgeproc_package_checksum_type,
String[1] $splunk_package_checksum = $splunk::params::edgeproc_package_checksum,
Stdlib::UnixPath $splunk_homedir = $splunk::params::edgeproc_homedir,
String[1] $scs_group_id = undef,
String[1] $scs_tenant_name = undef,
String[1] $scs_environment_name = undef,
String[1] $scs_auth_token = undef,
) inherits splunk {
if (defined(Class['splunk::forwarder'])) or (defined(Class['splunk::enterprise'])) {
fail('Splunk Edge Processor provides a subset of Splunk Enterprise capabilities, and has potentially conflicting resources when included with Splunk Enterprise or Splunk Forwarder on the same node. Do not include splunk::forwarder or splunk::enterprise on the same node as splunk::edgeprocessor.'
)
}

if (($facts['kernel'] == 'Linux') and ($facts['kernelmajversion'] > '4.9')) or ($facts['kernel'] != 'Linux') {
fail('This module and the Splunk Edge Processor software is only supported on Linux systems running kernel version 4.9.x or newer.')
}

contain 'splunk::edgeprocessor::install'
contain 'splunk::edgeprocessor::config'
contain 'splunk::edgeprocessor::service'

Class['splunk::edgeprocessor::install']
-> Class['splunk::edgeprocessor::config']
~> Class['splunk::edgeprocessor::service']
}
21 changes: 21 additions & 0 deletions manifests/edgeprocessor/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @summary
# Private class declared by Class[splunk::edgeprocessor] to contain the required steps
# for successfully configuring the Splunk Edge Processor
#
class splunk::edgeprocessor::config {
#Config file with connection details for Splunk Cloud Services environment
$scs_config = "groupId: ${splunk::edgeprocessor::scs_group_id}\ntenant: ${splunk::edgeprocessor::scs_tenant_name}\nenv: ${splunk::edgeprocessor::scs_environment_name}"

file { "${splunk::edgeprocessor::splunk_homedir}/etc/config.yaml":
ensure => file,
content => $scs_config,
owner => $splunk::edgeprocessor::splunk_user,
group => $splunk::edgeprocessor::splunk_user,
}
file { "${splunk::edgeprocessor::splunk_homedir}/var/token":
ensure => file,
content => Sensitive($splunk::edgeprocessor::scs_auth_token),
owner => $splunk::edgeprocessor::splunk_user,
group => $splunk::edgeprocessor::splunk_user,
}
}
31 changes: 31 additions & 0 deletions manifests/edgeprocessor/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @summary
# Private class declared by Class[splunk::edgeprocessor] to contain the required steps
# for successfully installing the Splunk Edge Processor
#
class splunk::edgeprocessor::install (
String[1] $archive_name = regsubst($splunk::edgeprocessor::package_url, '(\\S*\\/)([^\\/]+\\.tar\\.gz$)', '\\2'),
Stdlib::UnixPath $extract_path = regsubst($splunk::edgeprocessor::splunk_homedir, '(^.*\\/)[^\\/]*.$','\\1'),
) {
#Download and unpack the Splunk Edge Processor
archive { $archive_name:
path => "/tmp/${archive_name}",
source => $splunk::edgeprocessor::package_url,
checksum => $splunk::edgeprocessor::splunk_package_checksum,
checksum_type => $splunk::edgeprocessor::checksum_type,
extract => true,
extract_path => $extract_path,
creates => $splunk::edgeprocessor::splunk_homedir,
cleanup => true,
}
file { $splunk::edgeprocessor::splunk_homedir:
ensure => directory,
recurse => true,
owner => $splunk::edgeprocessor::splunk_user,
group => $splunk::edgeprocessor::splunk_user,
}
file { "${splunk::edgeprocessor::splunk_homedir}/var/log":
ensure => directory,
owner => $splunk::edgeprocessor::splunk_user,
group => $splunk::edgeprocessor::splunk_user,
}
}
29 changes: 29 additions & 0 deletions manifests/edgeprocessor/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# @summary
# Private class declared by Class[splunk::edgeprocessor] to contain the required steps
# for successfully configuring the Systemd service to run the Splunk Edge Processor
#
class splunk::edgeprocessor::service {
#Customize the default splunk-edge.service file that comes in the archive download
$service_defaults = { 'path' => "${splunk::edgeprocessor::splunk_homedir}/etc/splunk-edge.service" }
$service_variables = { 'Service' => { 'ExecStart' => "${splunk::edgeprocessor::splunk_homedir}/bin/splunk-edge run" ,
'User' => $splunk::edgeprocessor::splunk_user , 'Group' => $splunk::edgeprocessor::splunk_user } }
inifile::create_ini_settings($service_variables, $service_defaults)

# Install Systemd unit file
file { '/etc/systemd/system/splunk-edge.service':
ensure => file,
source => "${splunk::edgeprocessor::splunk_homedir}/etc/splunk-edge.service",
notify => Exec['systemd_reload'],
}

exec { 'systemd_reload':
command => '/usr/bin/systemctl daemon-reload',
refreshonly => true,
notify => Service['splunk-edge'],
}

service { 'splunk-edge':
ensure => true,
enable => true,
}
}
13 changes: 13 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
# @param enterprise_installdir
# Optional directory in which to install and manage Splunk Enterprise
#
# @param edgeproc_installdir
# Optional directory in which to install and manage Splunk Edge Processor
#
# @param default_host
# The host property in inputs.conf. Defaults to the server's hostname.
#
Expand All @@ -109,6 +112,7 @@
String[1] $server = 'splunk',
Optional[String[1]] $forwarder_installdir = undef,
Optional[String[1]] $enterprise_installdir = undef,
Optional[String[1]] $edgeproc_installdir = undef,
Boolean $boot_start = true,
String[1] $splunk_user = $facts['os']['family'] ? {
'windows' => 'Administrator',
Expand Down Expand Up @@ -141,6 +145,7 @@
$staging_dir = '/opt/staging/splunk'
$enterprise_homedir = pick($enterprise_installdir, '/opt/splunk')
$forwarder_homedir = pick($forwarder_installdir, '/opt/splunkforwarder')
$edgeproc_homedir = pick($edgeproc_installdir, '/opt/splunk-edge')
}

$additional_windows_forwarder_install_options = if $facts['os']['family'] == 'windows' and versioncmp($version, '9.1.3') == 0 {
Expand All @@ -164,6 +169,7 @@
$forwarder_confdir = "${forwarder_homedir}/etc"
$enterprise_src_subdir = 'linux'
$enterprise_confdir = "${enterprise_homedir}/etc"
$edgeproc_confdir = "${edgeproc_homedir}/etc"
$forwarder_install_options = []
$enterprise_install_options = []
# Systemd not supported until Splunk 7.2.2
Expand Down Expand Up @@ -389,11 +395,18 @@
$forwarder_package_ensure = 'installed'
$forwarder_package_src = "${src_root}/products/universalforwarder/releases/${version}/${forwarder_src_subdir}/${forwarder_src_package}"

# Edge Processor is currently only available via download link
$edgeproc_package_src = 'https://beam.scs.splunk.com/splunk-edge/v0.0.198-689fac1f-20221119t005809/linux/splunk-edge.tar.gz'
$edgeproc_package_checksum_type = 'sha512'
$edgeproc_package_checksum = '627af0176786945270fb66496e330f28004256a329ccd48c449c262613e2fd081a67c6579bfea3f08df75bac043d8feffe0500dab60ebd0a27fc6cbb06ba7b5e'

# A meta resource so providers know where splunk is installed:
splunk_config { 'splunk':
forwarder_installdir => $forwarder_homedir,
forwarder_confdir => $forwarder_confdir,
server_installdir => $enterprise_homedir,
server_confdir => $enterprise_confdir,
edgeproc_installdir => $edgeproc_homedir,
edgeproc_confdir => $edgeproc_confdir,
}
}
Loading