From ef9dc51c7490dae2645c0634bc560cf1dfed4a06 Mon Sep 17 00:00:00 2001 From: "McDonnell, Dave" Date: Fri, 24 Jun 2022 09:39:48 +1000 Subject: [PATCH] Explicitly set user on call to 'splunk enable boot-start' Fixes #310 --- manifests/forwarder/service/nix.pp | 8 +++----- spec/classes/forwarder_spec.rb | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/manifests/forwarder/service/nix.pp b/manifests/forwarder/service/nix.pp index 5bda46cd..4a9a4ae9 100644 --- a/manifests/forwarder/service/nix.pp +++ b/manifests/forwarder/service/nix.pp @@ -18,11 +18,9 @@ timeout => 0, notify => Exec['enable_splunkforwarder'], } - if $splunk::params::supports_systemd and $splunk::forwarder::splunk_user == 'root' { - $user_args = '' - } else { - $user_args = "-user ${splunk::forwarder::splunk_user}" - } + + $user_args = "-user ${splunk::forwarder::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. diff --git a/spec/classes/forwarder_spec.rb b/spec/classes/forwarder_spec.rb index 4c24af28..0b01dd43 100644 --- a/spec/classes/forwarder_spec.rb +++ b/spec/classes/forwarder_spec.rb @@ -112,7 +112,7 @@ it { is_expected.to contain_class('splunk::forwarder::service::nix') } it { is_expected.to contain_class('splunk::forwarder').with(service_name: 'SplunkForwarder') } it { is_expected.to contain_exec('stop_splunkforwarder').with(command: '/opt/splunkforwarder/bin/splunk stop') } - it { is_expected.to contain_exec('enable_splunkforwarder').with(command: '/opt/splunkforwarder/bin/splunk enable boot-start -systemd-managed 1 --accept-license --answer-yes --no-prompt') } + it { is_expected.to contain_exec('enable_splunkforwarder').with(command: '/opt/splunkforwarder/bin/splunk enable boot-start -user root -systemd-managed 1 --accept-license --answer-yes --no-prompt') } it { is_expected.not_to contain_exec('disable_splunkforwarder') } it { is_expected.not_to contain_exec('license_splunkforwarder') } it { is_expected.to contain_service('SplunkForwarder').with(ensure: 'running', enable: true, status: nil, restart: nil, start: nil, stop: nil) }