From 4d4430efd68a75d29554e5d98db02735f2d0823b Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Tue, 3 Nov 2015 17:07:19 +0000 Subject: [PATCH] Allow customization of db sync command line Add parameter to heat::db::sync to allow end users to add command line parameters to the db sync command. Change-Id: Id9de1022481fbeedc3db78a3dd2e3c5f2a962e10 Partial-bug: #1472740 --- manifests/db/sync.pp | 14 ++++++++++++-- manifests/params.pp | 3 --- spec/classes/heat_db_sync_spec.rb | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 4703cf90..931339a4 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -1,13 +1,23 @@ # # Class to execute heat dbsync # -class heat::db::sync { +# ==Parameters +# +# [*extra_params*] +# (optional) String of extra command line parameters to append +# to the heat-manage db_sync command. These will be inserted +# in the command line between 'heat-manage' and 'db_sync'. +# Defaults to '--config-file /etc/heat/heat.conf' +# +class heat::db::sync( + $extra_params = '--config-file /etc/heat/heat.conf', +) { include ::heat::deps include ::heat::params exec { 'heat-dbsync': - command => $::heat::params::dbsync_command, + command => "heat-manage ${extra_params} db_sync", path => '/usr/bin', user => 'heat', refreshonly => true, diff --git a/manifests/params.pp b/manifests/params.pp index d8b4830e..3f66c953 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,9 +4,6 @@ # class heat::params { - $dbsync_command = - 'heat-manage --config-file /etc/heat/heat.conf db_sync' - case $::osfamily { 'RedHat': { # package names diff --git a/spec/classes/heat_db_sync_spec.rb b/spec/classes/heat_db_sync_spec.rb index e88da806..31314935 100644 --- a/spec/classes/heat_db_sync_spec.rb +++ b/spec/classes/heat_db_sync_spec.rb @@ -14,8 +14,27 @@ describe 'heat::db::sync' do ) end + describe 'overriding extra_params' do + let :params do + { + :extra_params => '--config-file /etc/heat/heat01.conf', + } + end + + it { + is_expected.to contain_exec('heat-dbsync').with( + :command => 'heat-manage --config-file /etc/heat/heat01.conf db_sync', + :path => '/usr/bin', + :user => 'heat', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + } + end + end + context 'on a RedHat osfamily' do let :facts do {