Avoid defining resources twice in iscsi backend

In its current form, cinder::backend::iscsi is a define, allowing to call
it multiple times, which is desirable (if a server has multiple backends).
However, some resources are defined twice if the class is called twice.
To avoid this, this patch decorates the resource definition for packages
and services with if !defined.

Change-Id: I779dfd416da6fe8bb713105ed246172ebf0aae85
This commit is contained in:
Thomas Goirand 2020-09-11 14:37:33 +02:00
parent f22af86550
commit 715263c21c

View File

@ -98,11 +98,13 @@ define cinder::backend::iscsi (
case $target_helper {
'tgtadm': {
if ! defined(Package['tgt']) {
package { 'tgt':
ensure => present,
name => $::cinder::params::tgt_package_name,
tag => 'cinder-support-package',
}
}
if($::osfamily == 'RedHat') {
file_line { 'cinder include':
@ -114,6 +116,7 @@ define cinder::backend::iscsi (
}
}
if ! defined(Service['tgtd']) {
service { 'tgtd':
ensure => running,
name => $::cinder::params::tgt_service_name,
@ -121,20 +124,25 @@ define cinder::backend::iscsi (
tag => 'cinder-support-service',
}
}
}
'lioadm': {
if ! defined(Service['target']) {
service { 'target':
ensure => running,
enable => true,
tag => 'cinder-support-service',
}
}
if ! defined(Package['targetcli']) {
package { 'targetcli':
ensure => present,
name => $::cinder::params::lio_package_name,
tag => 'cinder-support-package',
}
}
}
default: {
fail("Unsupported target helper: ${target_helper}.")