Skip to content

Commit eb6b794

Browse files
author
Nikita Shalnov
committed
For versions above 7.2.1 splunk supports systems unit files. Add versioncmp to enable_splunkforwarder exec
1 parent 4fe1532 commit eb6b794

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

manifests/platform/posix.pp

+13-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
$splunkd_port = undef,
1919
$splunk_user = $splunk::params::splunk_user,
2020
$server_service = undef,
21+
$version = $splunk::params::version,
2122
) inherits splunk::virtual {
2223

2324
include ::splunk::params
2425
# Many of the resources declared here are virtual. They will be realized by
2526
# the appropriate including class if required.
2627

28+
2729
# Commands to run to enable the SplunkUniversalForwarder
2830
@exec { 'license_splunkforwarder':
2931
path => "${splunk::params::forwarder_dir}/bin",
@@ -34,11 +36,19 @@
3436
tag => 'splunk_forwarder',
3537
notify => Service['splunk'],
3638
}
37-
@exec { 'enable_splunkforwarder':
3839

40+
# If version of splunk >= 7.2.2, then command `splunk enable boot-start` creates systemd service NOT init.d file
41+
if versioncmp($version, '7.2.2') < 0 {
42+
$created_file = '/etc/init.d/splunk'
43+
}
44+
else {
45+
$created_file = '/etc/systemd/system/multi-user.target.wants'
46+
}
47+
48+
@exec { 'enable_splunkforwarder':
3949
# The path parameter can't be set because the boot-start silently fails on systemd service providers
4050
command => "${splunk::params::forwarder_dir}/bin/splunk enable boot-start -user ${splunk_user}",
41-
creates => '/etc/init.d/splunk',
51+
creates => "${created_file}/SplunkForwarder.service",
4252
require => Exec['license_splunkforwarder'],
4353
tag => 'splunk_forwarder',
4454
notify => Service['splunk'],
@@ -56,7 +66,7 @@
5666
@exec { 'enable_splunk':
5767
# The path parameter can't be set because the boot-start silently fails on systemd service providers
5868
command => "${splunk::params::server_dir}/bin/splunk enable boot-start -user ${splunk_user}",
59-
creates => '/etc/init.d/splunk',
69+
creates => "${created_file}/Splunkd.service",
6070
require => Exec['license_splunk'],
6171
tag => 'splunk_server',
6272
before => Service['splunk'],

0 commit comments

Comments
 (0)