Allow customization of db sync command line

Add  parameter to ironic::db::sync class to allow
 end-users to add command line parameters to the db_sync command.

Change-Id: I8cf3b47a99e828a338aad617d43272725c9b7419
Partial-bug: 1472740
This commit is contained in:
vsaienko 2015-09-08 13:44:00 +03:00
parent 7f09ae46c1
commit b28cafe718
2 changed files with 28 additions and 3 deletions

View File

@ -1,7 +1,16 @@
#
# Class to execute ironic dbsync
#
class ironic::db::sync {
# == Parameters
#
# [*extra_params*]
# (optional) String of extra command line parameters to append
# to the ironic-dbsync command.
# Defaults to undef
#
class ironic::db::sync(
$extra_params = undef,
) {
include ::ironic::params
@ -12,7 +21,7 @@ class ironic::db::sync {
Ironic_config<| title == 'database/connection' |> ~> Exec['ironic-dbsync']
exec { 'ironic-dbsync':
command => $::ironic::params::dbsync_command,
command => "${::ironic::params::dbsync_command} ${extra_params}",
path => '/usr/bin',
# Ubuntu packaging is running dbsync command as root during ironic-common
# postinstall script so when Puppet tries to run dbsync again, it fails

View File

@ -6,7 +6,7 @@ describe 'ironic::db::sync' do
it 'runs ironic-manage db_sync' do
is_expected.to contain_exec('ironic-dbsync').with(
:command => 'ironic-dbsync --config-file /etc/ironic/ironic.conf',
:command => 'ironic-dbsync --config-file /etc/ironic/ironic.conf ',
:path => '/usr/bin',
:user => 'root',
:refreshonly => 'true',
@ -14,8 +14,24 @@ describe 'ironic::db::sync' do
)
end
describe "overriding extra_params" do
let :params do
{
:extra_params => '--config-file /etc/ironic/ironic_01.conf',
}
end
it { is_expected.to contain_exec('ironic-dbsync').with(
:command => 'ironic-dbsync --config-file /etc/ironic/ironic.conf --config-file /etc/ironic/ironic_01.conf',
:path => '/usr/bin',
:user => 'root',
:refreshonly => true,
:logoutput => 'on_failure'
)
}
end
end
context 'on a RedHat osfamily' do
let :facts do
{