Do not define service resource when service management is disabled
Change-Id: I30d752928e2f76efbb711cff21a85e64f09f1215
This commit is contained in:
parent
9f113400cc
commit
536c44f8cf
@ -191,14 +191,6 @@ class watcher::api (
|
||||
tag => ['openstack', 'watcher-package'],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
if $create_db_schema {
|
||||
include watcher::db::create_schema
|
||||
}
|
||||
@ -207,33 +199,41 @@ class watcher::api (
|
||||
include watcher::db::upgrade
|
||||
}
|
||||
|
||||
if $service_name == $::watcher::params::api_service_name {
|
||||
# NOTE(danpawlik) Watcher doesn't support db_sync command.
|
||||
service { 'watcher-api':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::api_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => [ 'watcher-service',
|
||||
'watcher-db-manage-create_schema',
|
||||
'watcher-db-manage-upgrade'],
|
||||
}
|
||||
} elsif $service_name == 'httpd' {
|
||||
service { 'watcher-api':
|
||||
ensure => 'stopped',
|
||||
name => $::watcher::params::api_service_name,
|
||||
enable => false,
|
||||
tag => [ 'watcher-service',
|
||||
'watcher-db-manage-create_schema',
|
||||
'watcher-db-manage-upgrade'],
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
# we need to make sure watcher-api/eventlet is stopped before trying to start apache
|
||||
Service['watcher-api'] -> Service[$service_name]
|
||||
} else {
|
||||
fail("Invalid service_name. Either watcher/openstack-watcher-api for running \
|
||||
if $service_name == $::watcher::params::api_service_name {
|
||||
# NOTE(danpawlik) Watcher doesn't support db_sync command.
|
||||
service { 'watcher-api':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::api_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => [ 'watcher-service',
|
||||
'watcher-db-manage-create_schema',
|
||||
'watcher-db-manage-upgrade'],
|
||||
}
|
||||
} elsif $service_name == 'httpd' {
|
||||
service { 'watcher-api':
|
||||
ensure => 'stopped',
|
||||
name => $::watcher::params::api_service_name,
|
||||
enable => false,
|
||||
tag => [ 'watcher-service',
|
||||
'watcher-db-manage-create_schema',
|
||||
'watcher-db-manage-upgrade'],
|
||||
}
|
||||
|
||||
# we need to make sure watcher-api/eventlet is stopped before trying to start apache
|
||||
Service['watcher-api'] -> Service[$service_name]
|
||||
} else {
|
||||
fail("Invalid service_name. Either watcher/openstack-watcher-api for running \
|
||||
as a standalone service, or httpd for being run by a httpd server")
|
||||
}
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
|
@ -62,15 +62,15 @@ class watcher::applier (
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'watcher-applier':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::applier_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['watcher-service'],
|
||||
service { 'watcher-applier':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::applier_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['watcher-service'],
|
||||
}
|
||||
}
|
||||
|
||||
watcher_config {
|
||||
|
@ -94,15 +94,15 @@ class watcher::decision_engine (
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'watcher-decision-engine':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::decision_engine_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['watcher-service'],
|
||||
service { 'watcher-decision-engine':
|
||||
ensure => $service_ensure,
|
||||
name => $::watcher::params::decision_engine_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['watcher-service'],
|
||||
}
|
||||
}
|
||||
|
||||
watcher_config {
|
||||
|
@ -4,7 +4,6 @@ describe 'watcher::api' do
|
||||
|
||||
let :params do
|
||||
{ :watcher_client_password => 'password',
|
||||
:manage_service => true,
|
||||
:enabled => true,
|
||||
:package_ensure => 'latest',
|
||||
}
|
||||
@ -36,7 +35,7 @@ describe 'watcher::api' do
|
||||
|
||||
it 'configures watcher-api service' do
|
||||
is_expected.to contain_service('watcher-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,
|
||||
@ -63,20 +62,19 @@ describe 'watcher::api' do
|
||||
before do
|
||||
params.merge!({
|
||||
:manage_service => false,
|
||||
:enabled => false })
|
||||
})
|
||||
end
|
||||
|
||||
it 'configures watcher-api service' do
|
||||
is_expected.to contain_service('watcher-api').with(
|
||||
:ensure => nil,
|
||||
:name => platform_params[:api_service_name],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => ['watcher-service',
|
||||
'watcher-db-manage-create_schema',
|
||||
'watcher-db-manage-upgrade'],
|
||||
)
|
||||
it 'should not configure watcher-api service' do
|
||||
is_expected.to_not contain_service('watcher-api')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with service disabled' do
|
||||
before do
|
||||
params.merge!({
|
||||
:enabled => false
|
||||
})
|
||||
end
|
||||
|
||||
it 'should not configure the api configurations section when disabled' do
|
||||
@ -86,7 +84,6 @@ describe 'watcher::api' do
|
||||
is_expected.to_not contain_watcher_config('api/workers')
|
||||
is_expected.to_not contain_watcher_config('api/enable_ssl_api')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'watcher clients auth section with default parameters' do
|
||||
|
@ -26,9 +26,7 @@ describe 'watcher::applier' do
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
}
|
||||
{ :enabled => true, }
|
||||
end
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
@ -36,7 +34,7 @@ describe 'watcher::applier' do
|
||||
|
||||
it 'configures watcher applier service' do
|
||||
is_expected.to contain_service('watcher-applier').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:ensure => params[:enabled] ? 'running' : 'stopped',
|
||||
:name => platform_params[:applier_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
@ -47,6 +45,18 @@ describe 'watcher::applier' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with disabled service managing' do
|
||||
let :params do
|
||||
{
|
||||
:manage_service => false,
|
||||
}
|
||||
end
|
||||
|
||||
it 'should not configure watcher-applier service' do
|
||||
is_expected.to_not contain_service('watcher-applier')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
|
@ -28,9 +28,7 @@ describe 'watcher::decision_engine' do
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => true,
|
||||
}
|
||||
{ :enabled => true }
|
||||
end
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
@ -38,7 +36,7 @@ describe 'watcher::decision_engine' do
|
||||
|
||||
it 'configures watcher decision engine service' do
|
||||
is_expected.to contain_service('watcher-decision-engine').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:ensure => params[:enabled] ? 'running' : 'stopped',
|
||||
:name => platform_params[:decision_engine_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
@ -49,6 +47,18 @@ describe 'watcher::decision_engine' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'with disabled service managing' do
|
||||
let :params do
|
||||
{
|
||||
:manage_service => false
|
||||
}
|
||||
end
|
||||
|
||||
it 'should not configure watcher-decision-engine service' do
|
||||
is_expected.to_not contain_service('watcher-decision-engine')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user