Decouple $sync_db from $enabled

Having to set both $enabled and $sync_db to true for the DB sync to
happen breaks use cases when the service should stay completely
unmanaged (not enabled, not started), but DB sync should still happen.
For versatility of the module, the $enabled and $sync_db conditions
should be decoupled.

Change-Id: I2a0a76b54ebedba1ec098b8c64bd8e9684ed3099
Closes-Bug: #1452278
This commit is contained in:
Jiri Stransky
2015-05-06 18:12:17 +02:00
parent 8edb8b6e07
commit ffdd9836bd
2 changed files with 17 additions and 13 deletions

View File

@@ -172,20 +172,21 @@ class cinder::api (
} }
} }
if $enabled { if $sync_db {
if $sync_db { Cinder_config<||> ~> Exec['cinder-manage db_sync']
Cinder_config<||> ~> Exec['cinder-manage db_sync']
exec { 'cinder-manage db_sync': exec { 'cinder-manage db_sync':
command => $::cinder::params::db_sync_command, command => $::cinder::params::db_sync_command,
path => '/usr/bin', path => '/usr/bin',
user => 'cinder', user => 'cinder',
refreshonly => true, refreshonly => true,
logoutput => 'on_failure', logoutput => 'on_failure',
subscribe => Package['cinder'], subscribe => Package['cinder'],
before => Service['cinder-api'], before => Service['cinder-api'],
}
} }
}
if $enabled {
if $manage_service { if $manage_service {
$ensure = 'running' $ensure = 'running'
} }

View File

@@ -183,7 +183,7 @@ describe 'cinder::api' do
is_expected.to contain_service('cinder-api').with_ensure('stopped') is_expected.to contain_service('cinder-api').with_ensure('stopped')
end end
it 'should contain db_sync exec' do it 'should contain db_sync exec' do
is_expected.to_not contain_exec('cinder-manage db_sync') is_expected.to contain_exec('cinder-manage db_sync')
end end
end end
@@ -194,6 +194,9 @@ describe 'cinder::api' do
it 'should not change the state of the service' do it 'should not change the state of the service' do
is_expected.to contain_service('cinder-api').without_ensure is_expected.to contain_service('cinder-api').without_ensure
end end
it 'should contain db_sync exec' do
is_expected.to contain_exec('cinder-manage db_sync')
end
end end
describe 'with ratelimits' do describe 'with ratelimits' do