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,39 +184,37 @@ Use cinder::nova::region_name instead')
include cinder::db::sync include cinder::db::sync
} }
if $enabled { if $manage_service {
if $manage_service { if $enabled {
$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':
ensure => $ensure, ensure => $ensure,
name => $::cinder::params::api_service, name => $::cinder::params::api_service,
enable => $enabled, enable => $enabled,
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
} }
} elsif $service_name == 'httpd' { } elsif $service_name == 'httpd' {
service { 'cinder-api': service { 'cinder-api':
ensure => 'stopped', ensure => 'stopped',
name => $::cinder::params::api_service, name => $::cinder::params::api_service,
enable => false, enable => false,
tag => ['cinder-service'], tag => ['cinder-service'],
} }
Service <| title == 'httpd' |> { tag +> 'cinder-service' } Service <| title == 'httpd' |> { tag +> 'cinder-service' }
# we need to make sure cinder-api/eventlet is stopped before trying to start apache # we need to make sure cinder-api/eventlet is stopped before trying to start apache
Service['cinder-api'] -> Service[$service_name] Service['cinder-api'] -> Service[$service_name]
} else { } else {
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 {

View File

@ -88,14 +88,14 @@ class cinder::backup (
} else { } else {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
service { 'cinder-backup': service { 'cinder-backup':
ensure => $ensure, ensure => $ensure,
name => $::cinder::params::backup_service, name => $::cinder::params::backup_service,
enable => $enabled, enable => $enabled,
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
}
} }
cinder_config { cinder_config {

View File

@ -50,13 +50,13 @@ class cinder::scheduler (
} else { } else {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
service { 'cinder-scheduler': service { 'cinder-scheduler':
ensure => $ensure, ensure => $ensure,
name => $::cinder::params::scheduler_service, name => $::cinder::params::scheduler_service,
enable => $enabled, enable => $enabled,
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
}
} }
} }

View File

@ -92,14 +92,14 @@ class cinder::volume (
} else { } else {
$ensure = 'stopped' $ensure = 'stopped'
} }
}
service { 'cinder-volume': service { 'cinder-volume':
ensure => $ensure, ensure => $ensure,
name => $::cinder::params::volume_service, name => $::cinder::params::volume_service,
enable => $enabled, enable => $enabled,
hasstatus => true, hasstatus => true,
tag => 'cinder-service', tag => 'cinder-service',
}
} }
cinder_config { cinder_config {

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