Skip to content

Commit 51fc626

Browse files
Respect ensure when managing xtrabackup backup package
1 parent 1e55070 commit 51fc626

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

manifests/backup/xtrabackup.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
String[1] $backupmethod_package = $mysql::params::xtrabackup_package_name,
3636
Array[String] $excludedatabases = [],
3737
) inherits mysql::params {
38-
stdlib::ensure_packages($backupmethod_package)
38+
stdlib::ensure_packages($backupmethod_package, { 'ensure' => $ensure })
3939

4040
$backuppassword_unsensitive = if $backuppassword =~ Sensitive {
4141
$backuppassword.unwrap

spec/classes/mysql_backup_xtrabackup_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,47 @@ class { 'mysql::server': }
316316
)
317317
end
318318
end
319+
320+
package = if facts[:os]['family'] == 'RedHat'
321+
if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') >= 0
322+
'percona-xtrabackup-24'
323+
else
324+
'percona-xtrabackup'
325+
end
326+
elsif facts[:os]['name'] == 'Debian'
327+
'percona-xtrabackup-24'
328+
elsif facts[:os]['name'] == 'Ubuntu'
329+
if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') < 0 &&
330+
Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0
331+
'percona-xtrabackup'
332+
else
333+
'percona-xtrabackup-24'
334+
end
335+
elsif facts[:os]['family'] == 'Suse'
336+
'xtrabackup'
337+
else
338+
'percona-xtrabackup'
339+
end
340+
341+
context 'with ensure => present' do
342+
let(:params) do
343+
{ ensure: 'present' }.merge(default_params)
344+
end
345+
346+
it 'installs the backup method package' do
347+
expect(subject).to contain_package(package).with_ensure('installed')
348+
end
349+
end
350+
351+
context 'with ensure => absent' do
352+
let(:params) do
353+
{ ensure: 'absent' }.merge(default_params)
354+
end
355+
356+
it 'removes the backup method package' do
357+
expect(subject).to contain_package(package).with_ensure('absent')
358+
end
359+
end
319360
end
320361
end
321362
end

0 commit comments

Comments
 (0)