Wrap service ensure in manage_service boolean
As it happens already for the other services, this will prevent puppet from enforcing the backup service into either running or stopped state when manage_service is false. Also adds validate_bool for 'enabled' and 'manage_service' to the api, scheduler, volume and backup services. Change-Id: Id78397bb9745513ba2736ec4169ae4b7657a66e0
This commit is contained in:
parent
be66ab5543
commit
3d0732c2c0
@ -82,11 +82,11 @@
|
||||
# Defaults to 0.0.0.0
|
||||
#
|
||||
# [*enabled*]
|
||||
# (optional) The state of the service
|
||||
# (optional) The state of the service (boolean value)
|
||||
# Defaults to true
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether to start/stop the service
|
||||
# (optional) Whether to start/stop the service (boolean value)
|
||||
# Defaults to true
|
||||
#
|
||||
# [*ratelimits*]
|
||||
@ -188,6 +188,9 @@ class cinder::api (
|
||||
include ::cinder::params
|
||||
include ::cinder::policy
|
||||
|
||||
validate_bool($manage_service)
|
||||
validate_bool($enabled)
|
||||
|
||||
Cinder_config<||> ~> Service[$service_name]
|
||||
Cinder_api_paste_ini<||> ~> Service[$service_name]
|
||||
Class['cinder::policy'] ~> Service[$service_name]
|
||||
|
@ -5,8 +5,12 @@
|
||||
# === Parameters
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) Should the service be enabled.
|
||||
# Defaults to 'true'.
|
||||
# (Optional) Should the service be enabled (boolean value)
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (Optional) Whether to start/stop the service (boolean value)
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) Ensure state for package.
|
||||
@ -51,6 +55,7 @@
|
||||
#
|
||||
class cinder::backup (
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
$package_ensure = 'present',
|
||||
$backup_topic = $::os_service_default,
|
||||
$backup_manager = $::os_service_default,
|
||||
@ -60,6 +65,9 @@ class cinder::backup (
|
||||
|
||||
include ::cinder::params
|
||||
|
||||
validate_bool($manage_service)
|
||||
validate_bool($enabled)
|
||||
|
||||
Cinder_config<||> ~> Service['cinder-backup']
|
||||
Exec<| title == 'cinder-manage db_sync' |> ~> Service['cinder-backup']
|
||||
|
||||
@ -73,10 +81,12 @@ class cinder::backup (
|
||||
}
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$ensure = 'running'
|
||||
} else {
|
||||
$ensure = 'stopped'
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$ensure = 'running'
|
||||
} else {
|
||||
$ensure = 'stopped'
|
||||
}
|
||||
}
|
||||
|
||||
service { 'cinder-backup':
|
||||
|
@ -13,12 +13,12 @@
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) The state of the service
|
||||
# Defaults to 'true'.
|
||||
# (Optional) The state of the service (boolean value)
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (Optional) Whether to start/stop the service
|
||||
# Defaults to 'true'.
|
||||
# (Optional) Whether to start/stop the service (boolean value)
|
||||
# Defaults to true.
|
||||
#
|
||||
#
|
||||
class cinder::scheduler (
|
||||
@ -30,6 +30,9 @@ class cinder::scheduler (
|
||||
|
||||
include ::cinder::params
|
||||
|
||||
validate_bool($manage_service)
|
||||
validate_bool($enabled)
|
||||
|
||||
Cinder_config<||> ~> Service['cinder-scheduler']
|
||||
Cinder_api_paste_ini<||> ~> Service['cinder-scheduler']
|
||||
Exec<| title == 'cinder-manage db_sync' |> ~> Service['cinder-scheduler']
|
||||
|
@ -7,12 +7,12 @@
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) The state of the service
|
||||
# Defaults to 'true'.
|
||||
# (Optional) The state of the service (boolean value)
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (Optional) Whether to start/stop the service.
|
||||
# Defaults to 'true'.
|
||||
# (Optional) Whether to start/stop the service (boolean value)
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*volume_clear*]
|
||||
# (Optional) Method used to wipe old volumes.
|
||||
@ -40,6 +40,9 @@ class cinder::volume (
|
||||
|
||||
include ::cinder::params
|
||||
|
||||
validate_bool($manage_service)
|
||||
validate_bool($enabled)
|
||||
|
||||
Cinder_config<||> ~> Service['cinder-volume']
|
||||
Cinder_api_paste_ini<||> ~> Service['cinder-volume']
|
||||
Exec<| title == 'cinder-manage db_sync' |> ~> Service['cinder-volume']
|
||||
|
@ -190,7 +190,7 @@ describe 'cinder::api' do
|
||||
let :params do
|
||||
{
|
||||
:keystone_password => 'dummy',
|
||||
:enabled => 'true',
|
||||
:enabled => true,
|
||||
:sync_db => false,
|
||||
}
|
||||
end
|
||||
|
@ -24,6 +24,7 @@ describe 'cinder::backup' do
|
||||
|
||||
let :default_params do
|
||||
{ :enable => true,
|
||||
:manage_service => true,
|
||||
:backup_topic => '<SERVICE DEFAULT>',
|
||||
:backup_manager => '<SERVICE DEFAULT>',
|
||||
:backup_api_class => '<SERVICE DEFAULT>',
|
||||
@ -74,6 +75,16 @@ describe 'cinder::backup' do
|
||||
is_expected.to contain_cinder_config('DEFAULT/backup_name_template').with_value(p[:backup_name_template])
|
||||
end
|
||||
end
|
||||
|
||||
context 'with manage_service false' do
|
||||
before :each do
|
||||
params.merge!(:manage_service => false)
|
||||
end
|
||||
it 'should not change the state of the service' do
|
||||
is_expected.to contain_service('cinder-backup').without_ensure
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
Loading…
x
Reference in New Issue
Block a user