Ensure nfs client is installed when nfs backup driver is used

Similarly to I291f8592ca95636e16d73c1de71a378b36618c5a , the client
package is required by the nfs backup driver as well.

Related-Bug: #2100712
Change-Id: Iedbe166fd1e9c3b9f70e06cf8f16472146e78e06
This commit is contained in:
Takashi Kajinami 2025-03-03 01:59:33 +09:00
parent 75e727dea8
commit 296b623fc3
3 changed files with 33 additions and 0 deletions

View File

@ -47,6 +47,9 @@
# (optional) Compression algorithm to use when writing backup data.
# Defaults to $facts['os_service_default']
#
# [*package_ensure*]
# (optional) Ensure state for package. Defaults to 'present'.
#
# === Author(s)
#
# Ryan Hefner <ryan.hefner@netapp.com>
@ -78,9 +81,11 @@ class cinder::backup::nfs (
$backup_mount_options = $facts['os_service_default'],
$backup_container = $facts['os_service_default'],
$backup_compression_algorithm = $facts['os_service_default'],
$package_ensure = 'present',
) {
include cinder::deps
include cinder::params
cinder_config {
'DEFAULT/backup_mount_options': value => $backup_mount_options;
@ -94,4 +99,9 @@ class cinder::backup::nfs (
'DEFAULT/backup_compression_algorithm': value => $backup_compression_algorithm;
}
ensure_packages('nfs-client', {
name => $::cinder::params::nfs_client_package_name,
ensure => $package_ensure,
})
Package<| title == 'nfs-client' |> { tag +> 'cinder-support-package' }
}

View File

@ -0,0 +1,7 @@
---
features:
- |
The ``cinder::backup::nfs`` class now ensures that the nfs client package
is installed. The new ``package_ensure`` parameter has been added so that
the package state can be customized.

View File

@ -52,6 +52,13 @@ describe 'cinder::backup::nfs' do
end
end
it 'installs nfs client' do
is_expected.to contain_package('nfs-client').with(
:name => platform_params[:nfs_client_package_name],
:ensure => 'installed',
)
end
context 'with optional parameters' do
let (:all_params) { params.merge!({
:backup_mount_options => 'sec=sys',
@ -73,6 +80,15 @@ describe 'cinder::backup::nfs' do
facts.merge(OSDefaults.get_facts())
end
let :platform_params do
case facts[:os]['family']
when 'Debian'
{ :nfs_client_package_name => 'nfs-common' }
when 'RedHat'
{ :nfs_client_package_name => 'nfs-utils' }
end
end
it_behaves_like 'cinder backup with nfs'
end
end