5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'manifests/enterprise/service/nix.pp', line 5
class splunk::enterprise::service::nix inherits splunk::enterprise::service {
if $splunk::enterprise::boot_start {
# Ensure splunk services *not* managed by the system service file are
# gracefully shut down prior to enabling boot-start. Should the service
# file be enabled while binary-managed splunk services are running, you
# will no longer be able to control the binary-managed services
# (start/stop/restart).
exec { 'stop_splunk':
command => "${splunk::enterprise::enterprise_homedir}/bin/splunk stop",
user => $splunk::enterprise::splunk_user,
creates => $splunk::enterprise::enterprise_service_file,
timeout => 0,
notify => Exec['enable_splunk'],
}
if $splunk::params::supports_systemd and $splunk::enterprise::splunk_user == 'root' {
$user_args = ''
} else {
$user_args = "-user ${splunk::enterprise::splunk_user}"
}
# This will fail if the unit file already exists. Splunk does not remove
# unit files during uninstallation, so you may be required to manually
# remove existing unit files before re-installing and enabling boot-start.
exec { 'enable_splunk':
command => "${splunk::enterprise::enterprise_homedir}/bin/splunk enable boot-start ${user_args} ${splunk::params::boot_start_args} --accept-license --answer-yes --no-prompt",
refreshonly => true,
before => Service[$splunk::enterprise::service_name],
require => Exec['stop_splunk'],
}
}
# Commands to license, disable, and start Splunk Enterprise
#
else {
# Accept the license when disabling splunk in case system service files are
# present before installing splunk. The splunk package does not remove the
# service files when uninstalled.
exec { 'disable_splunk':
command => "${splunk::enterprise::enterprise_homedir}/bin/splunk disable boot-start -user ${splunk::enterprise::splunk_user} --accept-license --answer-yes --no-prompt",
onlyif => "/usr/bin/test -f ${splunk::enterprise::enterprise_service_file}",
}
# This will start splunkd and splunkweb in legacy mode assuming
# appServerPorts is set to 0.
exec { 'license_splunk':
command => "${splunk::enterprise::enterprise_homedir}/bin/splunk start --accept-license --answer-yes --no-prompt",
user => $splunk::enterprise::splunk_user,
creates => "${splunk::enterprise::enterprise_homedir}/etc/auth/splunk.secret",
timeout => 0,
before => Service[$splunk::enterprise::service_name],
require => Exec['disable_splunk'],
}
if $facts['kernel'] == 'Linux' {
Service[$splunk::enterprise::service_name] {
provider => 'base',
}
}
else {
Service[$splunk::enterprise::service_name] {
provider => 'init',
}
}
Service[$splunk::enterprise::service_name] {
restart => "/usr/sbin/runuser -l ${splunk::enterprise::splunk_user} -c '${splunk::enterprise::enterprise_homedir}/bin/splunk restart'",
start => "/usr/sbin/runuser -l ${splunk::enterprise::splunk_user} -c '${splunk::enterprise::enterprise_homedir}/bin/splunk start'",
stop => "/usr/sbin/runuser -l ${splunk::enterprise::splunk_user} -c '${splunk::enterprise::enterprise_homedir}/bin/splunk stop'",
status => "/usr/sbin/runuser -l ${splunk::enterprise::splunk_user} -c '${splunk::enterprise::enterprise_homedir}/bin/splunk status'",
pattern => "splunkd -p ${splunk::enterprise::splunkd_port} (restart|start)",
}
}
}
|