Trove external dependency management

Move all dependency tracking to an external class which simplifies the
relationships and allows managing Trove without necessarily using
packages.

This change also cleans up how the client is handled to make
it more configurable and match other modules.

Finally the reference to the deprecated and non-functional
keystone::python class is dropped.

Change-Id: I943685fbeb114dead80b7465b8f5c564a0bc9fe0
This commit is contained in:
Matt Fischer 2016-03-17 18:37:31 -06:00
parent 77c50a16f1
commit 59f75e6085
24 changed files with 146 additions and 45 deletions

View File

@ -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;

View File

@ -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',
}
}

View File

@ -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'

View File

@ -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)

View File

@ -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'],
}
}

View File

@ -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']
}

View File

@ -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']
}

View File

@ -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'],
}
}

65
manifests/deps.pp Normal file
View File

@ -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']
}

View File

@ -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'],
}
}

View File

@ -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 {

View File

@ -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 }
}

View File

@ -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,

View File

@ -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::<myparam> first then trove::logging::<myparam>.
$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;
}
}

View File

@ -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;

View File

@ -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':

View File

@ -0,0 +1,5 @@
---
features:
- Dependencies are now managed in an external class.
This allows installing Trove via other methods besides
packages.

View File

@ -0,0 +1,4 @@
---
features:
- The client_package_name is now configurable.
It defaults to the name in the params class.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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