Fix multiple backends with some drivers

Cinder generally supports defining multiple backends using the same
driver. This means we have to expect the case cinder::backend::foo is
used multiple times. However some of the defined types include the raw
package resources which causes duplicate declarations.

This fixes that and ensure we avoid duplication by ensure_packages.

Change-Id: I6ceee41a4e3d26bfb1782b35d3f26821964e238f
This commit is contained in:
Takashi Kajinami 2023-03-16 20:17:55 +09:00
parent cd7077a184
commit 047dc0f10e
5 changed files with 16 additions and 15 deletions

View File

@ -70,12 +70,10 @@ define cinder::backend::iscsi (
# NOTE(mnaser): Cinder requires /usr/sbin/thin_check to create volumes which
# does not get installed with Cinder (see LP#1615134).
if $facts['os']['family'] == 'Debian' {
if ! defined(Package['thin-provisioning-tools']) {
package { 'thin-provisioning-tools':
ensure => present,
tag => 'cinder-support-package',
}
}
ensure_packages( 'thin-provisioning-tools', {
ensure => present,
tag => 'cinder-support-package',
})
}
cinder_config {

View File

@ -76,16 +76,16 @@ define cinder::backend::nvmeof (
"${name}/volume_group": value => $volume_group;
}
package { 'nvmetcli':
ensure_packages ( 'nvmetcli', {
ensure => present,
name => 'nvmetcli',
tag => 'cinder-support-package',
}
})
package { 'nvme-cli':
ensure_packages ( 'nvme-cli', {
ensure => present,
name => 'nvme-cli',
tag => 'cinder-support-package',
}
})
}

View File

@ -109,10 +109,10 @@ define cinder::backend::vstorage (
}
if $manage_package {
package { 'vstorage-client':
ensure_packages( 'vstorage-client', {
ensure => present,
tag => 'cinder-support-package',
}
})
}
$mount_opts = ['-u', $mount_user_real, '-g', $mount_group, '-m', $mount_permissions]

View File

@ -32,13 +32,13 @@ describe 'cinder::backend::nvmeof' do
it { is_expected.to contain_package('nvmetcli').with(
:name => 'nvmetcli',
:ensure => 'present',
:ensure => 'installed',
:tag => 'cinder-support-package',
)}
it { is_expected.to contain_package('nvme-cli').with(
:name => 'nvme-cli',
:ensure => 'present',
:ensure => 'installed',
:tag => 'cinder-support-package',
)}
end

View File

@ -38,7 +38,10 @@ describe 'cinder::backend::vstorage' do
:value => 'cinder.volume.drivers.vzstorage.VZStorageDriver'
)}
it { is_expected.to contain_package('vstorage-client').with_ensure('present') }
it { is_expected.to contain_package('vstorage-client').with(
:ensure => 'installed',
:tag => 'cinder-support-package',
) }
it { is_expected.to contain_file('/etc/cinder/vstorage_shares.conf').with(
:content => "stor1:passw0rd [\"-u\", \"cinder\", \"-g\", \"root\", \"-m\", \"0770\"]"