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

Fix upgrading Splunk Enterprise #363

Merged
merged 1 commit into from
Mar 23, 2024
Merged
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
14 changes: 14 additions & 0 deletions manifests/enterprise/service/nix.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
timeout => 0,
notify => Exec['enable_splunk'],
}

exec { 'disable_splunk_boot_start':
subscribe => Package[$splunk::enterprise::package_name],
refreshonly => true,
command => [
"${splunk::enterprise::enterprise_homedir}/bin/splunk",
'disable',
'boot-start',
'--accept-license',
'--answer-yes',
'--no-prompt',
],
}
if $splunk::params::supports_systemd and $splunk::enterprise::splunk_user == 'root' {
$user_args = ''
} else {
Expand All @@ -29,6 +42,7 @@
refreshonly => true,
before => Service[$splunk::enterprise::service_name],
require => Exec['stop_splunk'],
subscribe => Exec['disable_splunk_boot_start'],
}
}
# Commands to license, disable, and start Splunk Enterprise
Expand Down
64 changes: 64 additions & 0 deletions spec/acceptance/splunk_enterprise_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,70 @@ class { 'splunk::enterprise': }
end
end

context 'Upgrading splunk enterprise from 9.1.0 to 9.2.0.1' do
after(:all) do
pp = <<-EOS
service { '#{service_name}': ensure => stopped }
package { 'splunk': ensure => purged }
file { '/opt/splunk': ensure => absent, force => true, require => Package['splunk'] }
file { '/etc/init.d/splunk': ensure => absent, require => Package['splunk'] }
file { '/etc/systemd/system/Splunkd.service': ensure => absent, require => Package['splunk'] }
EOS
apply_manifest(pp, catch_failures: true)
end

it 'works idempotently with no errors' do
pp = <<-EOS
class { 'splunk::params': version => '9.1.0', build => '1c86ca0bacc3' }
class { 'splunk::enterprise': }

# See https://community.splunk.com/t5/Installation/Why-am-I-getting-an-error-to-start-a-fresh-Splunk-instance-in-my/m-p/336938
file_line { 'file_locking':
path => '/opt/splunk/etc/splunk-launch.conf',
line => 'OPTIMISTIC_ABOUT_FILE_LOCKING=1',
before => Exec['enable_splunk'],
require => Package['splunk'],
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# give splunk some time to start
sleep(10)
end

describe package('splunk') do
it { is_expected.to be_installed }
end

describe service(service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

it 'upgrades to 9.2.0.1' do
pp = <<-EOS
class { 'splunk::params': version => '9.2.0.1', build => 'd8ae995bf219' }
class { 'splunk::enterprise': package_ensure => latest }

# See https://community.splunk.com/t5/Installation/Why-am-I-getting-an-error-to-start-a-fresh-Splunk-instance-in-my/m-p/336938
file_line { 'file_locking':
path => '/opt/splunk/etc/splunk-launch.conf',
line => 'OPTIMISTIC_ABOUT_FILE_LOCKING=1',
before => Exec['enable_splunk'],
require => Package['splunk'],
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# give splunk some time to start
sleep(10)
end
end

context 'default parameters' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
Expand Down