From f739aa363b7d536c8f561a1a1fbe81a09719de56 Mon Sep 17 00:00:00 2001 From: Risto Laurikainen Date: Thu, 3 Aug 2017 11:52:23 +0300 Subject: [PATCH] Allow setting of the DB sync command path The magnum-db-manage command is not necessarily located under /usr/bin if Magnum is installed in e.g. a virtualenv. In cases like this, it is useful to let the module user specify a different path, such as the bin directory of a virtualenv. Change-Id: I0687683558a4a9ed445642b36b2ce7b7075e49f7 --- manifests/db/sync.pp | 7 ++++++- spec/classes/magnum_db_sync_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 5a28c75..78c0c84 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -12,16 +12,21 @@ # to the magnum-dbsync command. # Defaults to undef # +# [*exec_path*] +# (optional) The path to use for finding the magnum-db-manage binary. +# Defaults to /usr/bin +# class magnum::db::sync( $user = 'magnum', $extra_params = '--config-file /etc/magnum/magnum.conf', + $exec_path = '/usr/bin', ) { include ::magnum::deps exec { 'magnum-db-sync': command => "magnum-db-manage ${extra_params} upgrade head", - path => '/usr/bin', + path => $exec_path, user => $user, refreshonly => true, try_sleep => 5, diff --git a/spec/classes/magnum_db_sync_spec.rb b/spec/classes/magnum_db_sync_spec.rb index 2819d38..304e2ea 100644 --- a/spec/classes/magnum_db_sync_spec.rb +++ b/spec/classes/magnum_db_sync_spec.rb @@ -44,6 +44,30 @@ describe 'magnum::db::sync' do } end + describe "overriding exec_path" do + let :params do + { + :exec_path => '/opt/venvs/magnum/bin', + } + end + + it { + is_expected.to contain_exec('magnum-db-sync').with( + :command => 'magnum-db-manage --config-file /etc/magnum/magnum.conf upgrade head', + :path => '/opt/venvs/magnum/bin', + :user => 'magnum', + :refreshonly => 'true', + :try_sleep => 5, + :tries => 10, + :logoutput => 'on_failure', + :subscribe => ['Anchor[magnum::install::end]', + 'Anchor[magnum::config::end]', + 'Anchor[magnum::dbsync::begin]'], + :notify => 'Anchor[magnum::dbsync::end]', + ) + } + end + end on_supported_os({