diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index 241c3eb..7851c70 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -50,6 +50,6 @@ class mistral::db::postgresql( privileges => $privileges, } - ::Openstacklib::Db::Postgresql['mistral'] ~> Exec<| title == 'mistral-dbsync' |> + ::Openstacklib::Db::Postgresql['mistral'] ~> Exec<| title == 'mistral-db-sync' |> } diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 038bfaa..e64c065 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -1,15 +1,34 @@ # -# Class to execute "mistral-dbsync" +# Class to execute "mistral-db-manage 'upgrade head' and 'populate'" # class mistral::db::sync { - exec { 'mistral-dbsync': - command => $::mistral::params::dbsync_command, - path => '/usr/bin', - user => 'mistral', - logoutput => on_failure, - subscribe => File[$::mistral::params::mistral_conf], + include ::mistral::params + + Package<| tag =='mistral-common' |> ~> Exec['mistral-db-sync'] + Exec['mistral-db-sync'] ~> Service<| tag == 'mistral-service' |> + Mistral_config <||> -> Exec['mistral-db-sync'] + Mistral_config <| title == 'database/connection' |> ~> Exec['mistral-db-sync'] + + exec { 'mistral-db-sync': + command => $::mistral::params::db_sync_command, + path => '/usr/bin', + user => 'mistral', + logoutput => on_failure, + refreshonly => true, + } + + Exec['mistral-db-sync'] -> Exec['mistral-db-populate'] + Package<| tag =='mistral-common' |> ~> Exec['mistral-db-populate'] + Exec['mistral-db-populate'] ~> Service<| tag == 'mistral-service' |> + Mistral_config <||> -> Exec['mistral-db-populate'] + Mistral_config <| title == 'database/connection' |> ~> Exec['mistral-db-populate'] + exec { 'mistral-db-populate': + command => $::mistral::params::db_populate_command, + path => '/usr/bin', + user => 'mistral', + logoutput => on_failure, + refreshonly => true, } - Exec['mistral-dbsync'] ~> Service<| title == 'mistral' |> } diff --git a/manifests/params.pp b/manifests/params.pp index 68ba211..b198603 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -3,11 +3,13 @@ # Parameters for puppet-mistral # class mistral::params { + $mistral_conf_dir = '/etc/mistral' $mistral_conf = "${mistral_conf_dir}/mistral.conf" $client_package = 'python-mistralclient' $log_dir ='/var/log/mistral' - $dbsync_command = "/usr/bin/python /usr/bin/mistral-db-manage --config-file=${mistral_conf} populate" + $db_sync_command = "mistral-db-manage --config-file=${mistral_conf} upgrade head" + $db_populate_command = "mistral-db-manage --config-file=${mistral_conf} populate" $update_service_command = '/usr/bin/systemctl daemon-reload' case $::osfamily { diff --git a/spec/classes/mistral_db_sync_spec.rb b/spec/classes/mistral_db_sync_spec.rb new file mode 100644 index 0000000..a64c040 --- /dev/null +++ b/spec/classes/mistral_db_sync_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe 'mistral::db::sync' do + + shared_examples_for 'mistral-db-sync' do + + it 'runs mistral-db-manage upgrade head' do + + is_expected.to contain_exec('mistral-db-sync').with( + :command => 'mistral-db-manage --config-file=/etc/mistral/mistral.conf upgrade head', + :path => '/usr/bin', + :user => 'mistral', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + + is_expected.to contain_exec('mistral-db-populate').with( + :command => 'mistral-db-manage --config-file=/etc/mistral/mistral.conf populate', + :path => '/usr/bin', + :user => 'mistral', + :refreshonly => 'true', + :logoutput => 'on_failure' + ) + + end + + end + + context 'on a RedHat osfamily' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '7.0', + :concat_basedir => '/var/lib/puppet/concat' + } + end + + it_configures 'mistral-db-sync' + end + + context 'on a Debian osfamily' do + let :facts do + { + :operatingsystemrelease => '8.0', + :osfamily => 'Debian', + :concat_basedir => '/var/lib/puppet/concat' + } + end + + it_configures 'mistral-db-sync' + end + +end