diff --git a/manifests/api.pp b/manifests/api.pp index 3a569b90..5216b5db 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -194,15 +194,12 @@ class trove::api( $auth_protocol = 'http', ) inherits trove { - require ::keystone::python + include ::trove::deps include ::trove::db + include ::trove::db::sync include ::trove::logging include ::trove::params - Trove_config<||> ~> Exec['post-trove_config'] - Trove_config<||> ~> Service['trove-api'] - Trove_api_paste_ini<||> ~> Service['trove-api'] - # basic service config trove_config { 'DEFAULT/bind_host': value => $bind_host; diff --git a/manifests/client.pp b/manifests/client.pp index 1c255290..c1a47787 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -21,20 +21,26 @@ # # === Parameters: # +# [*client_package_name*] +# (optional) The name of python trove client package +# Defaults to $trove::params::client_package_name +# # [*package_ensure*] # (optional) The state of the package # Defaults to present # # class trove::client ( - $package_ensure = present -) { + $client_package_name = $trove::params::client_package_name, + $package_ensure = present, +) inherits trove::params { - include ::trove::params + include ::trove::deps package { 'python-troveclient': ensure => $package_ensure, - name => $::trove::params::client_package_name, + name => $client_package_name, + tag => 'openstack', } } diff --git a/manifests/conductor.pp b/manifests/conductor.pp index fa69762b..a56a5155 100644 --- a/manifests/conductor.pp +++ b/manifests/conductor.pp @@ -64,11 +64,9 @@ class trove::conductor( $conductor_manager = 'trove.conductor.manager.Manager', ) inherits trove { + include ::trove::deps include ::trove::params - Trove_conductor_config<||> ~> Exec['post-trove_config'] - Trove_conductor_config<||> ~> Service['trove-conductor'] - if $::trove::database_connection { if($::trove::database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) { require 'mysql::bindings' diff --git a/manifests/config.pp b/manifests/config.pp index 93d63136..afbb15ee 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -69,6 +69,8 @@ class trove::config ( $trove_api_paste_ini = {}, ) { + include ::trove::deps + validate_hash($trove_config) validate_hash($trove_taskmanager_config) validate_hash($trove_conductor_config) diff --git a/manifests/db.pp b/manifests/db.pp index 9368ba7e..9a2a9fb2 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -43,6 +43,7 @@ class trove::db ( $database_max_overflow = 20, ) { + include ::trove::deps include ::trove::params # NOTE(spredzy): In order to keep backward compatibility we rely on the pick function @@ -85,7 +86,7 @@ class trove::db ( package {'trove-backend-package': ensure => present, name => $backend_package, - tag => 'openstack', + tag => ['openstack', 'trove-package'], } } diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 145fd783..96a7a7c4 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -59,6 +59,8 @@ class trove::db::mysql( $collate = 'utf8_general_ci', ) { + include ::trove::deps + validate_string($password) ::openstacklib::db::mysql { 'trove': @@ -71,5 +73,7 @@ class trove::db::mysql( allowed_hosts => $allowed_hosts, } - ::Openstacklib::Db::Mysql['trove'] ~> Exec<| title == 'trove-manage db_sync' |> + Anchor['trove::db::begin'] + ~> Class['trove::db::mysql'] + ~> Anchor['trove::db::end'] } diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index f9763192..73f6a43d 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -32,7 +32,9 @@ class trove::db::postgresql( $privileges = 'ALL', ) { - Class['trove::db::postgresql'] -> Service<| title == 'trove' |> + include ::trove::deps + + validate_string($password) ::openstacklib::db::postgresql { 'trove': password_hash => postgresql_password($user, $password), @@ -42,6 +44,7 @@ class trove::db::postgresql( privileges => $privileges, } - ::Openstacklib::Db::Postgresql['trove'] ~> Exec<| title == 'trove-manage db_sync' |> - + Anchor['trove::db::begin'] + ~> Class['trove::db::postgresql'] + ~> Anchor['trove::db::end'] } diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index 9d3f947e..0b9146f3 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -18,10 +18,18 @@ # Class to execute "trove-manage db_sync # class trove::db::sync { + + include ::trove::deps + exec { 'trove-manage db_sync': path => '/usr/bin', user => 'trove', refreshonly => true, - subscribe => Trove_config['database/connection'], + subscribe => [ + Anchor['trove::install::end'], + Anchor['trove::config::end'], + Anchor['trove::dbsync::begin'] + ], + notify => Anchor['trove::dbsync::end'], } } diff --git a/manifests/deps.pp b/manifests/deps.pp new file mode 100644 index 00000000..f872770c --- /dev/null +++ b/manifests/deps.pp @@ -0,0 +1,65 @@ +# == Class: trove::deps +# +# trove anchors and dependency management +# +class trove::deps { + # Setup anchors for install, config and service phases of the module. These + # anchors allow external modules to hook the begin and end of any of these + # phases. Package or service management can also be replaced by ensuring the + # package is absent or turning off service management and having the + # replacement depend on the appropriate anchors. When applicable, end tags + # should be notified so that subscribers can determine if installation, + # config or service state changed and act on that if needed. + anchor { 'trove::install::begin': } + -> Package<| tag == 'trove-package'|> + ~> anchor { 'trove::install::end': } + -> anchor { 'trove::config::begin': } + -> Trove_config<||> + ~> anchor { 'trove::config::end': } + -> anchor { 'trove::db::begin': } + -> anchor { 'trove::db::end': } + ~> anchor { 'trove::dbsync::begin': } + -> anchor { 'trove::dbsync::end': } + ~> anchor { 'trove::service::begin': } + ~> Service<| tag == 'trove-service' |> + ~> anchor { 'trove::service::end': } + + # Include all the other trove config pieces in the config block. + # Don't put them above because there's no chain between each individual part + # of the config. + Anchor['trove::config::begin'] + -> Trove_taskmanager_config<||> + ~> Anchor['trove::config::end'] + Anchor['trove::config::begin'] + -> Trove_conductor_config<||> + ~> Anchor['trove::config::end'] + Anchor['trove::config::begin'] + -> Trove_guestagent_config<||> + ~> Anchor['trove::config::end'] + + # Also include paste ini config in the config section + Anchor['trove::config::begin'] + -> Trove_api_paste_ini<||> + ~> Anchor['trove::config::end'] + + # policy config should occur in the config block also as soon as + # puppet-trove supports it. Leave commented out for now. + # Anchor['trove::config::begin'] + # -> Openstacklib::Policy::Base<||> + # ~> Anchor['trove::config::end'] + + # We need troveclient installed before marking service end so that trove + # will have clients available to create resources. This tag handles the + # troveclient but indirectly since the client is not available in + # all catalogs that don't need the client class (like many spec tests). + # Once the troveclient is installed we will setup the datastores and + # datastore_versions. Datastore_versions must come after datastores. + Package<| tag == 'openstack'|> + ~> Anchor['trove::service::end'] + -> Trove_datastore<||> + -> Trove_datastore_version<||> + + # Installation or config changes will always restart services. + Anchor['trove::install::end'] ~> Anchor['trove::service::begin'] + Anchor['trove::config::end'] ~> Anchor['trove::service::begin'] +} diff --git a/manifests/generic_service.pp b/manifests/generic_service.pp index 2201eb8b..d612ca15 100644 --- a/manifests/generic_service.pp +++ b/manifests/generic_service.pp @@ -55,19 +55,16 @@ define trove::generic_service( $ensure_package = 'present' ) { + include ::trove::deps include ::trove::params - include ::trove::db::sync $trove_title = "trove-${name}" - Exec['post-trove_config'] ~> Service<| title == $trove_title |> - Exec<| title == 'trove-manage db_sync' |> ~> Service<| title == $trove_title |> if ($package_name) { if !defined(Package[$package_name]) { package { $trove_title: ensure => $ensure_package, name => $package_name, - notify => Service[$trove_title], tag => ['openstack', 'trove-package'], } } diff --git a/manifests/guestagent.pp b/manifests/guestagent.pp index 0b719fa1..40a89976 100644 --- a/manifests/guestagent.pp +++ b/manifests/guestagent.pp @@ -69,11 +69,9 @@ class trove::guestagent( $control_exchange = 'trove' ) inherits trove { + include ::trove::deps include ::trove::params - Trove_guestagent_config<||> ~> Exec['post-trove_config'] - Trove_guestagent_config<||> ~> Service['trove-guestagent'] - # basic service config trove_guestagent_config { 'DEFAULT/verbose': value => $verbose; @@ -92,7 +90,7 @@ class trove::guestagent( trove_guestagent_config { 'DEFAULT/os_region_name': value => $::trove::os_region_name } } else { - trove_guestagent_config {'DEFAULT/os_region_name': ensure => absent } + trove_guestagent_config { 'DEFAULT/os_region_name': ensure => absent } } trove_guestagent_config { diff --git a/manifests/init.pp b/manifests/init.pp index c3b14854..55d2cbf1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -285,15 +285,9 @@ class trove( $qpid_protocol = undef, $qpid_tcp_nodelay = undef, ) { + include ::trove::deps include ::trove::params - exec { 'post-trove_config': - command => '/bin/echo "Trove config has changed"', - refreshonly => true, - } - - Trove_datastore<||> -> Trove_datastore_version<||> - if $nova_compute_url { trove_config { 'DEFAULT/nova_compute_url': value => $nova_compute_url } } diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index 8051f76d..24ff6fec 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -139,6 +139,8 @@ class trove::keystone::auth ( $admin_address = undef, ) { + include ::trove::deps + if $port { warning('The port parameter is deprecated, use public_url, internal_url and admin_url instead.') } @@ -203,7 +205,7 @@ class trove::keystone::auth ( Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| tag == 'trove-server' |> Keystone_endpoint<| title == "${region}/${real_service_name}::${service_type}" |> - ~> Service <| tag == 'trove-server' |> + ~> Service <| tag == 'trove-server' |> keystone::resource::service_identity { 'trove': configure_user => true, diff --git a/manifests/logging.pp b/manifests/logging.pp index bcb41921..d08fbdaa 100644 --- a/manifests/logging.pp +++ b/manifests/logging.pp @@ -116,6 +116,8 @@ class trove::logging( $log_date_format = $::os_service_default, ) { + include ::trove::deps + # NOTE(spredzy): In order to keep backward compatibility we rely on the pick function # to use trove:: first then trove::logging::. $use_syslog_real = pick($::trove::api::use_syslog, $use_syslog) @@ -153,4 +155,3 @@ class trove::logging( 'DEFAULT/log_date_format' : value => $log_date_format; } } - diff --git a/manifests/quota.pp b/manifests/quota.pp index 874ea58f..bed9b30d 100644 --- a/manifests/quota.pp +++ b/manifests/quota.pp @@ -33,6 +33,8 @@ class trove::quota ( $quota_driver = 'trove.quota.quota.DbQuotaDriver', ) { + include ::trove::deps + trove_config { 'DEFAULT/max_instances_per_user': value => $max_instances_per_user; 'DEFAULT/max_accepted_volume_size': value => $max_accepted_volume_size; diff --git a/manifests/taskmanager.pp b/manifests/taskmanager.pp index 48fafb1f..a4f18803 100644 --- a/manifests/taskmanager.pp +++ b/manifests/taskmanager.pp @@ -101,12 +101,9 @@ class trove::taskmanager( $taskmanager_queue = 'taskmanager', ) inherits trove { + include ::trove::deps include ::trove::params - Package[$::trove::params::taskmanager_package_name] -> Trove_taskmanager_config<||> - Trove_taskmanager_config<||> ~> Exec['post-trove_config'] - Trove_taskmanager_config<||> ~> Service['trove-taskmanager'] - if $::trove::database_connection { if($::trove::database_connection =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) { require 'mysql::bindings' @@ -303,7 +300,7 @@ class trove::taskmanager( if $use_guestagent_template { file { $guestagent_config_file: content => template('trove/trove-guestagent.conf.erb'), - require => Package[$::trove::params::taskmanager_package_name] + require => Anchor['trove::install::end'], } } else { class {'::trove::guestagent': diff --git a/releasenotes/notes/external_dependency_management-4f5c1e349d9983fb.yaml b/releasenotes/notes/external_dependency_management-4f5c1e349d9983fb.yaml new file mode 100644 index 00000000..a5eb3f98 --- /dev/null +++ b/releasenotes/notes/external_dependency_management-4f5c1e349d9983fb.yaml @@ -0,0 +1,5 @@ +--- +features: + - Dependencies are now managed in an external class. + This allows installing Trove via other methods besides + packages. diff --git a/releasenotes/notes/make_client_more_configurable-aa43f623d8c9d3c7.yaml b/releasenotes/notes/make_client_more_configurable-aa43f623d8c9d3c7.yaml new file mode 100644 index 00000000..7c1e6f57 --- /dev/null +++ b/releasenotes/notes/make_client_more_configurable-aa43f623d8c9d3c7.yaml @@ -0,0 +1,4 @@ +--- +features: + - The client_package_name is now configurable. + It defaults to the name in the params class. diff --git a/spec/classes/trove_api_spec.rb b/spec/classes/trove_api_spec.rb index 609591d5..685dd1c0 100644 --- a/spec/classes/trove_api_spec.rb +++ b/spec/classes/trove_api_spec.rb @@ -55,7 +55,7 @@ describe 'trove::api' do is_expected.to contain_package('trove-api').with( :name => platform_params[:api_package_name], :ensure => 'present', - :notify => 'Service[trove-api]' + :tag => ['openstack', 'trove-package'], ) end diff --git a/spec/classes/trove_conductor_spec.rb b/spec/classes/trove_conductor_spec.rb index a78ba4c7..99a86f21 100644 --- a/spec/classes/trove_conductor_spec.rb +++ b/spec/classes/trove_conductor_spec.rb @@ -21,7 +21,7 @@ describe 'trove::conductor' do is_expected.to contain_package('trove-conductor').with( :name => platform_params[:conductor_package_name], :ensure => 'present', - :notify => 'Service[trove-conductor]' + :tag => ['openstack', 'trove-package'], ) end diff --git a/spec/classes/trove_db_spec.rb b/spec/classes/trove_db_spec.rb index a24cbe22..c72624a8 100644 --- a/spec/classes/trove_db_spec.rb +++ b/spec/classes/trove_db_spec.rb @@ -93,7 +93,7 @@ describe 'trove::db' do is_expected.to contain_package('trove-backend-package').with( :ensure => 'present', :name => 'python-pymysql', - :tag => 'openstack' + :tag => ['openstack', 'trove-package'], ) end end diff --git a/spec/classes/trove_deps_spec.rb b/spec/classes/trove_deps_spec.rb new file mode 100644 index 00000000..aaba51ac --- /dev/null +++ b/spec/classes/trove_deps_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'trove::deps' do + + it 'set up the anchors' do + is_expected.to contain_anchor('trove::install::begin') + is_expected.to contain_anchor('trove::install::end') + is_expected.to contain_anchor('trove::config::begin') + is_expected.to contain_anchor('trove::config::end') + is_expected.to contain_anchor('trove::db::begin') + is_expected.to contain_anchor('trove::db::end') + is_expected.to contain_anchor('trove::dbsync::begin') + is_expected.to contain_anchor('trove::dbsync::end') + is_expected.to contain_anchor('trove::service::begin') + is_expected.to contain_anchor('trove::service::end') + end +end diff --git a/spec/classes/trove_guestagent_spec.rb b/spec/classes/trove_guestagent_spec.rb index 1f7e542b..8a8ac5ab 100644 --- a/spec/classes/trove_guestagent_spec.rb +++ b/spec/classes/trove_guestagent_spec.rb @@ -22,7 +22,7 @@ describe 'trove::guestagent' do is_expected.to contain_package('trove-guestagent').with( :name => platform_params[:guestagent_package_name], :ensure => 'present', - :notify => 'Service[trove-guestagent]' + :tag => ['openstack', 'trove-package'] ) end diff --git a/spec/classes/trove_taskmanager_spec.rb b/spec/classes/trove_taskmanager_spec.rb index e5f3a501..272f222a 100644 --- a/spec/classes/trove_taskmanager_spec.rb +++ b/spec/classes/trove_taskmanager_spec.rb @@ -46,7 +46,7 @@ describe 'trove::taskmanager' do is_expected.to contain_package('trove-taskmanager').with( :name => platform_params[:taskmanager_package_name], :ensure => 'present', - :notify => 'Service[trove-taskmanager]' + :tag => ['openstack', 'trove-package'] ) end