Decouple sync_db from manage_service and enabled

We want db_sync to run even though manage_service or enabled
can be set to False.

Change-Id: Ic3472ce6a6e704a2fa035df6e1c8866b8ea6bcbc
Closes-Bug: 1452278
This commit is contained in:
Giulio Fidente 2015-05-06 13:29:19 +02:00
parent 0db42a6a60
commit c76d39605f
2 changed files with 17 additions and 15 deletions

View File

@ -356,25 +356,27 @@ class glance::registry(
'/etc/glance/glance-registry-paste.ini']:
}
if $sync_db {
Exec['glance-manage db_sync'] ~> Service['glance-registry']
exec { 'glance-manage db_sync':
command => $::glance::params::db_sync_command,
path => '/usr/bin',
user => 'glance',
refreshonly => true,
logoutput => on_failure,
subscribe => [Package[$glance::params::registry_package_name], File['/etc/glance/glance-registry.conf']],
}
}
if $manage_service {
if $enabled {
if $sync_db {
Exec['glance-manage db_sync'] ~> Service['glance-registry']
exec { 'glance-manage db_sync':
command => $::glance::params::db_sync_command,
path => '/usr/bin',
user => 'glance',
refreshonly => true,
logoutput => on_failure,
subscribe => [Package[$glance::params::registry_package_name], File['/etc/glance/glance-registry.conf']],
}
}
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
} else {
warning('Execution of db_sync does not depend on $manage_service or $enabled anymore. Please use sync_db instead.')
}
service { 'glance-registry':

View File

@ -74,9 +74,9 @@ describe 'glance::registry' do
'require' => 'Class[Glance]'
)}
it 'is_expected.to only sync the db if the service is enabled' do
it 'is_expected.to only sync the db if sync_db is enabled' do
if param_hash[:enabled] and param_hash[:sync_db]
if param_hash[:sync_db]
is_expected.to contain_exec('glance-manage db_sync').with(
'path' => '/usr/bin',
'command' => 'glance-manage --config-file=/etc/glance/glance-registry.conf db_sync',
@ -89,7 +89,7 @@ describe 'glance::registry' do
end
it 'is_expected.to not sync the db if sync_db is set to false' do
if param_hash[:enabled] and !param_hash[:sync_db]
if !param_hash[:sync_db]
is_expected.not_to contain_exec('glance-manage db_sync')
end
end