Skip to content
Open
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
4 changes: 2 additions & 2 deletions manifests/backup/xtrabackup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
String[1] $backupmethod_package = $mysql::params::xtrabackup_package_name,
Array[String] $excludedatabases = [],
) inherits mysql::params {
stdlib::ensure_packages($backupmethod_package)
stdlib::ensure_packages($backupmethod_package, { 'ensure' => $ensure })

$backuppassword_unsensitive = if $backuppassword =~ Sensitive {
$backuppassword.unwrap
Expand Down Expand Up @@ -169,7 +169,7 @@
}

file { $backupdir:
ensure => 'directory',
ensure => $ensure ? { 'absent' => 'absent', default => 'directory' },

Check warning on line 172 in manifests/backup/xtrabackup.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

selector inside resource block (check: selector_inside_resource)
mode => $backupdirmode,
owner => $backupdirowner,
group => $backupdirgroup,
Expand Down
49 changes: 49 additions & 0 deletions spec/classes/mysql_backup_xtrabackup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,55 @@ class { 'mysql::server': }
)
end
end

package = if facts[:os]['family'] == 'RedHat'
if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') >= 0
'percona-xtrabackup-24'
else
'percona-xtrabackup'
end
elsif facts[:os]['name'] == 'Debian'
'percona-xtrabackup-24'
elsif facts[:os]['name'] == 'Ubuntu'
if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') < 0 &&
Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0
'percona-xtrabackup'
else
'percona-xtrabackup-24'
end
elsif facts[:os]['family'] == 'Suse'
'xtrabackup'
else
'percona-xtrabackup'
end

context 'with ensure => present' do
let(:params) do
{ ensure: 'present' }.merge(default_params)
end

it 'installs the backup method package' do
expect(subject).to contain_package(package).with_ensure('installed')
end

it 'manages the backup directory' do
expect(subject).to contain_file('/tmp').with_ensure('directory')
end
end

context 'with ensure => absent' do
let(:params) do
{ ensure: 'absent' }.merge(default_params)
end

it 'removes the backup method package' do
expect(subject).to contain_package(package).with_ensure('absent')
end

it 'removes the backup directory' do
expect(subject).to contain_file('/tmp').with_ensure('absent')
end
end
end
end
end
Loading