|
18 | 18 | $splunkd_port = undef,
|
19 | 19 | $splunk_user = $splunk::params::splunk_user,
|
20 | 20 | $server_service = undef,
|
| 21 | + $version = $splunk::params::version, |
21 | 22 | ) inherits splunk::virtual {
|
22 | 23 |
|
23 | 24 | include ::splunk::params
|
24 | 25 | # Many of the resources declared here are virtual. They will be realized by
|
25 | 26 | # the appropriate including class if required.
|
26 | 27 |
|
| 28 | + |
27 | 29 | # Commands to run to enable the SplunkUniversalForwarder
|
28 | 30 | @exec { 'license_splunkforwarder':
|
29 | 31 | path => "${splunk::params::forwarder_dir}/bin",
|
|
34 | 36 | tag => 'splunk_forwarder',
|
35 | 37 | notify => Service['splunk'],
|
36 | 38 | }
|
37 |
| - @exec { 'enable_splunkforwarder': |
38 | 39 |
|
| 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': |
39 | 49 | # The path parameter can't be set because the boot-start silently fails on systemd service providers
|
40 | 50 | 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", |
42 | 52 | require => Exec['license_splunkforwarder'],
|
43 | 53 | tag => 'splunk_forwarder',
|
44 | 54 | notify => Service['splunk'],
|
|
56 | 66 | @exec { 'enable_splunk':
|
57 | 67 | # The path parameter can't be set because the boot-start silently fails on systemd service providers
|
58 | 68 | 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", |
60 | 70 | require => Exec['license_splunk'],
|
61 | 71 | tag => 'splunk_server',
|
62 | 72 | before => Service['splunk'],
|
|
0 commit comments