diff --git a/manifests/api.pp b/manifests/api.pp index 0d981013..40a2f199 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -60,6 +60,10 @@ # to make gnocchi-api be a web app using apache mod_wsgi. # Defaults to '$::gnocchi::params::api_service_name' # +# [*sync_db*] +# (optional) Run gnocchi-upgrade db sync on api nodes after installing the package. +# Defaults to false + class gnocchi::api ( $manage_service = true, $enabled = true, @@ -74,6 +78,7 @@ class gnocchi::api ( $workers = $::processorcount, $max_limit = 1000, $service_name = $::gnocchi::params::api_service_name, + $sync_db = false, ) inherits gnocchi::params { include ::gnocchi::policy @@ -101,6 +106,10 @@ class gnocchi::api ( } } + if $sync_db { + include ::gnocchi::db::sync + } + if $service_name == $::gnocchi::params::api_service_name { service { 'gnocchi-api': ensure => $service_ensure, diff --git a/releasenotes/notes/add-sync_db-to-gnocchi-db-class-d3fed198a27b15e0.yaml b/releasenotes/notes/add-sync_db-to-gnocchi-db-class-d3fed198a27b15e0.yaml new file mode 100644 index 00000000..c58f0e00 --- /dev/null +++ b/releasenotes/notes/add-sync_db-to-gnocchi-db-class-d3fed198a27b15e0.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - Add a sync_db option to ::gnocchi::api class. This makes it easier + to control the db sync. The sync_db param is a boolean and set to + false by default for backward compatibility so db sync is not run + out of the box. diff --git a/spec/classes/gnocchi_api_spec.rb b/spec/classes/gnocchi_api_spec.rb index c512fde5..f1cb23ca 100644 --- a/spec/classes/gnocchi_api_spec.rb +++ b/spec/classes/gnocchi_api_spec.rb @@ -69,6 +69,14 @@ describe 'gnocchi::api' do end end + context 'with sync_db set to true' do + before do + params.merge!({ + :sync_db => true}) + end + it { is_expected.to contain_class('gnocchi::db::sync') } + end + context 'with disabled service managing' do before do params.merge!({