Do not declare service resource when manage_service is false
Change-Id: I6e8a61b641f86b241b71b55a93abd967960e0b96
This commit is contained in:
@@ -87,41 +87,41 @@ class gnocchi::api (
|
|||||||
tag => ['openstack', 'gnocchi-package'],
|
tag => ['openstack', 'gnocchi-package'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $sync_db {
|
||||||
|
include gnocchi::db::sync
|
||||||
|
}
|
||||||
|
|
||||||
if $manage_service {
|
if $manage_service {
|
||||||
if $enabled {
|
if $enabled {
|
||||||
$service_ensure = 'running'
|
$service_ensure = 'running'
|
||||||
} else {
|
} else {
|
||||||
$service_ensure = 'stopped'
|
$service_ensure = 'stopped'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if $sync_db {
|
if $service_name == $::gnocchi::params::api_service_name {
|
||||||
include gnocchi::db::sync
|
service { 'gnocchi-api':
|
||||||
}
|
ensure => $service_ensure,
|
||||||
|
name => $::gnocchi::params::api_service_name,
|
||||||
|
enable => $enabled,
|
||||||
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||||
|
}
|
||||||
|
} elsif $service_name == 'httpd' {
|
||||||
|
service { 'gnocchi-api':
|
||||||
|
ensure => 'stopped',
|
||||||
|
name => $::gnocchi::params::api_service_name,
|
||||||
|
enable => false,
|
||||||
|
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||||
|
}
|
||||||
|
Service <| title == 'httpd' |> { tag +> 'gnocchi-service' }
|
||||||
|
|
||||||
if $service_name == $::gnocchi::params::api_service_name {
|
# we need to make sure gnocchi-api/eventlet is stopped before trying to start apache
|
||||||
service { 'gnocchi-api':
|
Service['gnocchi-api'] -> Service[$service_name]
|
||||||
ensure => $service_ensure,
|
} else {
|
||||||
name => $::gnocchi::params::api_service_name,
|
fail("Invalid service_name. Either gnocchi/openstack-gnocchi-api for running as a \
|
||||||
enable => $enabled,
|
|
||||||
hasstatus => true,
|
|
||||||
hasrestart => true,
|
|
||||||
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
|
||||||
}
|
|
||||||
} elsif $service_name == 'httpd' {
|
|
||||||
service { 'gnocchi-api':
|
|
||||||
ensure => 'stopped',
|
|
||||||
name => $::gnocchi::params::api_service_name,
|
|
||||||
enable => false,
|
|
||||||
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
|
||||||
}
|
|
||||||
Service <| title == 'httpd' |> { tag +> 'gnocchi-service' }
|
|
||||||
|
|
||||||
# we need to make sure gnocchi-api/eventlet is stopped before trying to start apache
|
|
||||||
Service['gnocchi-api'] -> Service[$service_name]
|
|
||||||
} else {
|
|
||||||
fail("Invalid service_name. Either gnocchi/openstack-gnocchi-api for running as a \
|
|
||||||
standalone service, or httpd for being run by a httpd server")
|
standalone service, or httpd for being run by a httpd server")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gnocchi_config {
|
gnocchi_config {
|
||||||
|
|||||||
@@ -87,15 +87,14 @@ class gnocchi::metricd (
|
|||||||
} else {
|
} else {
|
||||||
$service_ensure = 'stopped'
|
$service_ensure = 'stopped'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
service { 'gnocchi-metricd':
|
service { 'gnocchi-metricd':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $::gnocchi::params::metricd_service_name,
|
name => $::gnocchi::params::metricd_service_name,
|
||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,15 +48,15 @@ class gnocchi::statsd (
|
|||||||
} else {
|
} else {
|
||||||
$service_ensure = 'stopped'
|
$service_ensure = 'stopped'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
service { 'gnocchi-statsd':
|
service { 'gnocchi-statsd':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $::gnocchi::params::statsd_service_name,
|
name => $::gnocchi::params::statsd_service_name,
|
||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gnocchi_config {
|
gnocchi_config {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ describe 'gnocchi::api' do
|
|||||||
|
|
||||||
it 'configures gnocchi-api service' do
|
it 'configures gnocchi-api service' do
|
||||||
is_expected.to contain_service('gnocchi-api').with(
|
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],
|
:name => platform_params[:api_service_name],
|
||||||
:enable => params[:enabled],
|
:enable => params[:enabled],
|
||||||
:hasstatus => true,
|
:hasstatus => true,
|
||||||
@@ -99,19 +99,12 @@ describe 'gnocchi::api' do
|
|||||||
context 'with disabled service managing' do
|
context 'with disabled service managing' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({
|
||||||
:manage_service => false,
|
:manage_service => false
|
||||||
:enabled => false })
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures gnocchi-api service' do
|
it 'does not configure gnocchi-api service' do
|
||||||
is_expected.to contain_service('gnocchi-api').with(
|
is_expected.to_not contain_service('gnocchi-api')
|
||||||
:ensure => nil,
|
|
||||||
:name => platform_params[:api_service_name],
|
|
||||||
:enable => false,
|
|
||||||
:hasstatus => true,
|
|
||||||
:hasrestart => true,
|
|
||||||
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -49,19 +49,12 @@ describe 'gnocchi::metricd' do
|
|||||||
context 'with disabled service managing' do
|
context 'with disabled service managing' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({
|
||||||
:manage_service => false,
|
:manage_service => false
|
||||||
:enabled => false })
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures gnocchi-metricd service' do
|
it 'does not configure gnocchi-metricd service' do
|
||||||
is_expected.to contain_service('gnocchi-metricd').with(
|
is_expected.to_not contain_service('gnocchi-metricd')
|
||||||
:ensure => nil,
|
|
||||||
:name => platform_params[:metricd_service_name],
|
|
||||||
:enable => false,
|
|
||||||
:hasstatus => true,
|
|
||||||
:hasrestart => true,
|
|
||||||
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ describe 'gnocchi::statsd' do
|
|||||||
|
|
||||||
it 'configures gnocchi-statsd service' do
|
it 'configures gnocchi-statsd service' do
|
||||||
is_expected.to contain_service('gnocchi-statsd').with(
|
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],
|
:name => platform_params[:statsd_service_name],
|
||||||
:enable => params[:enabled],
|
:enable => params[:enabled],
|
||||||
:hasstatus => true,
|
:hasstatus => true,
|
||||||
@@ -51,19 +51,12 @@ describe 'gnocchi::statsd' do
|
|||||||
context 'with disabled service managing' do
|
context 'with disabled service managing' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({
|
||||||
:manage_service => false,
|
:manage_service => false
|
||||||
:enabled => false })
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures gnocchi-statsd service' do
|
it 'does not configure gnocchi-statsd service' do
|
||||||
is_expected.to contain_service('gnocchi-statsd').with(
|
is_expected.to_not contain_service('gnocchi-statsd')
|
||||||
:ensure => nil,
|
|
||||||
:name => platform_params[:statsd_service_name],
|
|
||||||
:enable => false,
|
|
||||||
:hasstatus => true,
|
|
||||||
:hasrestart => true,
|
|
||||||
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user