Do not define service resource when service management is disabled

Change-Id: I64d3da1c9c6e379f410cf575c874c9d8d3153bb8
This commit is contained in:
Takashi Kajinami 2022-02-10 13:12:29 +09:00
parent 574fbdbe45
commit 58eb8a1733
8 changed files with 50 additions and 57 deletions

View File

@ -184,15 +184,12 @@ Use cinder::nova::region_name instead')
include cinder::db::sync include cinder::db::sync
} }
if $manage_service {
if $enabled { if $enabled {
if $manage_service {
$ensure = 'running' $ensure = 'running'
}
} else { } else {
if $manage_service {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
if $service_name == $::cinder::params::api_service { if $service_name == $::cinder::params::api_service {
service { 'cinder-api': service { 'cinder-api':
@ -218,6 +215,7 @@ Use cinder::nova::region_name instead')
fail("Invalid service_name. Either cinder-api/openstack-cinder-api for \ fail("Invalid service_name. Either cinder-api/openstack-cinder-api for \
running as a standalone service, or httpd for being run by a httpd server") running as a standalone service, or httpd for being run by a httpd server")
} }
}
cinder_config { cinder_config {
'DEFAULT/osapi_volume_listen': value => $bind_host; 'DEFAULT/osapi_volume_listen': value => $bind_host;

View File

@ -88,7 +88,6 @@ class cinder::backup (
} else { } else {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
service { 'cinder-backup': service { 'cinder-backup':
ensure => $ensure, ensure => $ensure,
@ -97,6 +96,7 @@ class cinder::backup (
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
} }
}
cinder_config { cinder_config {
'DEFAULT/backup_manager': value => $backup_manager; 'DEFAULT/backup_manager': value => $backup_manager;

View File

@ -50,7 +50,6 @@ class cinder::scheduler (
} else { } else {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
service { 'cinder-scheduler': service { 'cinder-scheduler':
ensure => $ensure, ensure => $ensure,
@ -59,4 +58,5 @@ class cinder::scheduler (
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
} }
}
} }

View File

@ -92,7 +92,6 @@ class cinder::volume (
} else { } else {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
service { 'cinder-volume': service { 'cinder-volume':
ensure => $ensure, ensure => $ensure,
@ -101,6 +100,7 @@ class cinder::volume (
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
} }
}
cinder_config { cinder_config {
'DEFAULT/cluster': value => $cluster; 'DEFAULT/cluster': value => $cluster;

View File

@ -101,7 +101,7 @@ describe 'cinder::api' do
req_params.merge({'manage_service' => false}) req_params.merge({'manage_service' => false})
end end
it 'should not change the state of the service' do it 'should not change the state of the service' do
is_expected.to contain_service('cinder-api').without_ensure is_expected.to_not contain_service('cinder-api')
end end
it 'includes cinder::db::sync' do it 'includes cinder::db::sync' do
is_expected.to contain_class('cinder::db::sync') is_expected.to contain_class('cinder::db::sync')

View File

@ -91,13 +91,8 @@ describe 'cinder::backup' do
before :each do before :each do
params.merge!(:manage_service => false) params.merge!(:manage_service => false)
end end
it 'should not change the state of the service' do it 'should not configure the service' do
is_expected.to contain_service('cinder-backup').with( is_expected.to_not contain_service('cinder-backup')
:ensure => nil,
:name => platform_params[:backup_service],
:hasstatus => true,
:tag => 'cinder-service',
)
end end
end end

View File

@ -40,7 +40,7 @@ describe 'cinder::scheduler' do
} }
end end
it { is_expected.to contain_service('cinder-scheduler').without_ensure } it { is_expected.to_not contain_service('cinder-scheduler') }
end end
end end

View File

@ -32,7 +32,7 @@ describe 'cinder::volume' do
} }
end end
it { is_expected.to contain_service('cinder-volume').without_ensure } it { is_expected.to_not contain_service('cinder-volume') }
end end
context 'with parameters overridden' do context 'with parameters overridden' do