Do not declare service resource when manage_service is false

Change-Id: I6e8a61b641f86b241b71b55a93abd967960e0b96
This commit is contained in:
Takashi Kajinami 2022-01-24 08:19:18 +09:00
parent 3748c1e06d
commit b0656ac23b
6 changed files with 56 additions and 78 deletions

View File

@ -87,17 +87,16 @@ class gnocchi::api (
tag => ['openstack', 'gnocchi-package'],
}
if $sync_db {
include gnocchi::db::sync
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
if $sync_db {
include gnocchi::db::sync
}
if $service_name == $::gnocchi::params::api_service_name {
service { 'gnocchi-api':
@ -123,6 +122,7 @@ class gnocchi::api (
fail("Invalid service_name. Either gnocchi/openstack-gnocchi-api for running as a \
standalone service, or httpd for being run by a httpd server")
}
}
gnocchi_config {
'api/max_limit': value => $max_limit;

View File

@ -87,7 +87,6 @@ class gnocchi::metricd (
} else {
$service_ensure = 'stopped'
}
}
service { 'gnocchi-metricd':
ensure => $service_ensure,
@ -97,5 +96,5 @@ class gnocchi::metricd (
hasrestart => true,
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
}
}
}

View File

@ -48,7 +48,6 @@ class gnocchi::statsd (
} else {
$service_ensure = 'stopped'
}
}
service { 'gnocchi-statsd':
ensure => $service_ensure,
@ -58,6 +57,7 @@ class gnocchi::statsd (
hasrestart => true,
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
}
}
gnocchi_config {
'statsd/resource_id' : value => $resource_id;

View File

@ -75,7 +75,7 @@ describe 'gnocchi::api' do
it 'configures gnocchi-api service' do
is_expected.to contain_service('gnocchi-api').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:ensure => params[:enabled] ? 'running' : 'stopped',
:name => platform_params[:api_service_name],
:enable => params[:enabled],
:hasstatus => true,
@ -99,19 +99,12 @@ describe 'gnocchi::api' do
context 'with disabled service managing' do
before do
params.merge!({
:manage_service => false,
:enabled => false })
:manage_service => false
})
end
it 'configures gnocchi-api service' do
is_expected.to contain_service('gnocchi-api').with(
:ensure => nil,
:name => platform_params[:api_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
)
it 'does not configure gnocchi-api service' do
is_expected.to_not contain_service('gnocchi-api')
end
end

View File

@ -49,19 +49,12 @@ describe 'gnocchi::metricd' do
context 'with disabled service managing' do
before do
params.merge!({
:manage_service => false,
:enabled => false })
:manage_service => false
})
end
it 'configures gnocchi-metricd service' do
is_expected.to contain_service('gnocchi-metricd').with(
:ensure => nil,
:name => platform_params[:metricd_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
)
it 'does not configure gnocchi-metricd service' do
is_expected.to_not contain_service('gnocchi-metricd')
end
end

View File

@ -37,7 +37,7 @@ describe 'gnocchi::statsd' do
it 'configures gnocchi-statsd service' do
is_expected.to contain_service('gnocchi-statsd').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:ensure => params[:enabled] ? 'running' : 'stopped',
:name => platform_params[:statsd_service_name],
:enable => params[:enabled],
:hasstatus => true,
@ -51,19 +51,12 @@ describe 'gnocchi::statsd' do
context 'with disabled service managing' do
before do
params.merge!({
:manage_service => false,
:enabled => false })
:manage_service => false
})
end
it 'configures gnocchi-statsd service' do
is_expected.to contain_service('gnocchi-statsd').with(
:ensure => nil,
:name => platform_params[:statsd_service_name],
:enable => false,
:hasstatus => true,
:hasrestart => true,
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
)
it 'does not configure gnocchi-statsd service' do
is_expected.to_not contain_service('gnocchi-statsd')
end
end