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