Add hooks for external install & svc management
This adds defined anchor points for external modules to hook into the software install, config and service dependency chain. This allows external modules to manage software installation (virtualenv, containers, etc) and service management (pacemaker) without needing rely on resources that may change or be renamed. Change-Id: I7f3f97a54aec888d99c7405310afef8e1f3907f0
This commit is contained in:
parent
5dc51ed24e
commit
c5544a5a66
@ -60,6 +60,7 @@ class magnum::api(
|
||||
$ssl_key_file = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
include ::magnum::params
|
||||
include ::magnum::policy
|
||||
|
||||
@ -76,9 +77,6 @@ class magnum::api(
|
||||
include ::magnum::db::sync
|
||||
}
|
||||
|
||||
Magnum_config<||> ~> Service['magnum-api']
|
||||
Class['magnum::policy'] ~> Service['magnum-api']
|
||||
|
||||
# Configure API conf
|
||||
magnum_config {
|
||||
'api/port' : value => $port;
|
||||
@ -91,8 +89,6 @@ class magnum::api(
|
||||
|
||||
# Install package
|
||||
if $::magnum::params::api_package {
|
||||
Package['magnum-api'] -> Class['magnum::policy']
|
||||
Package['magnum-api'] -> Service['magnum-api']
|
||||
package { 'magnum-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::magnum::params::api_package,
|
||||
|
@ -12,6 +12,8 @@ class magnum::certificates (
|
||||
$cert_manager_type = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
magnum_config { 'certificates/cert_manager_type':
|
||||
value => $cert_manager_type;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ class magnum::client (
|
||||
$package_ensure = present
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
include ::magnum::params
|
||||
|
||||
package { 'python-magnumclient':
|
||||
|
@ -19,6 +19,7 @@ class magnum::clients (
|
||||
$endpoint_type = 'publicURL',
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
include ::magnum::params
|
||||
|
||||
magnum_config {
|
||||
|
@ -29,10 +29,10 @@ class magnum::conductor(
|
||||
) {
|
||||
|
||||
include ::magnum::db
|
||||
include ::magnum::deps
|
||||
include ::magnum::params
|
||||
|
||||
# Install package
|
||||
Package['magnum-conductor'] -> Service['magnum-conductor']
|
||||
package { 'magnum-conductor':
|
||||
ensure => $package_ensure,
|
||||
name => $::magnum::params::conductor_package,
|
||||
|
@ -28,6 +28,8 @@ class magnum::config (
|
||||
$magnum_api_paste_ini = {},
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
validate_hash($magnum_config)
|
||||
validate_hash($magnum_api_paste_ini)
|
||||
|
||||
|
@ -49,6 +49,8 @@ class magnum::db (
|
||||
$database_db_max_retries = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
validate_re($database_connection,
|
||||
'^(mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
|
@ -47,6 +47,8 @@ class magnum::db::mysql(
|
||||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'magnum':
|
||||
@ -59,5 +61,8 @@ class magnum::db::mysql(
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['magnum'] ~> Exec<| title == 'magnum-db-sync' |>
|
||||
Anchor['magnum::db::begin']
|
||||
~> Class['magnum::db::mysql']
|
||||
~> Anchor['magnum::db::end']
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class magnum::db::postgresql(
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['magnum::db::postgresql'] -> Service<| title == 'magnum' |>
|
||||
include ::magnum::deps
|
||||
|
||||
::openstacklib::db::postgresql { 'magnum':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
@ -42,6 +42,8 @@ class magnum::db::postgresql(
|
||||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['magnum'] ~> Exec<| title == 'magnum-db-sync' |>
|
||||
Anchor['magnum::db::begin']
|
||||
~> Class['magnum::db::postgresql']
|
||||
~> Anchor['magnum::db::end']
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ class magnum::db::sync(
|
||||
$user = 'magnum',
|
||||
$extra_params = '--config-file /etc/magnum/magnum.conf',
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
exec { 'magnum-db-sync':
|
||||
command => "magnum-db-manage ${extra_params} upgrade head",
|
||||
path => '/usr/bin',
|
||||
@ -24,10 +27,12 @@ class magnum::db::sync(
|
||||
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'],
|
||||
}
|
||||
|
||||
Package<| tag == 'magnum-package' |> ~> Exec['magnum-db-sync']
|
||||
Exec['magnum-db-sync'] ~> Service<| tag == 'magnum-db-sync-service' |>
|
||||
Magnum_config<| title == 'database/connection' |> ~> Exec['magnum-db-sync']
|
||||
Magnum_config <| |> ~> Exec['magnum-db-sync']
|
||||
}
|
||||
|
35
manifests/deps.pp
Normal file
35
manifests/deps.pp
Normal file
@ -0,0 +1,35 @@
|
||||
# == Class: magnum::deps
|
||||
#
|
||||
# Magnum anchors and dependency management
|
||||
#
|
||||
class magnum::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 { 'magnum::install::begin': }
|
||||
-> Package<| tag == 'magnum-package'|>
|
||||
~> anchor { 'magnum::install::end': }
|
||||
-> anchor { 'magnum::config::begin': }
|
||||
-> Magnum_config<||>
|
||||
~> anchor { 'magnum::config::end': }
|
||||
-> anchor { 'magnum::db::begin': }
|
||||
-> anchor { 'magnum::db::end': }
|
||||
~> anchor { 'magnum::dbsync::begin': }
|
||||
-> anchor { 'magnum::dbsync::end': }
|
||||
~> anchor { 'magnum::service::begin': }
|
||||
~> Service<| tag == 'magnum-service' |>
|
||||
~> anchor { 'magnum::service::end': }
|
||||
|
||||
# policy config should occur in the config block also.
|
||||
Anchor['magnum::config::begin']
|
||||
-> Openstacklib::Policy::Base<||>
|
||||
~> Anchor['magnum::config::end']
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['magnum::install::end'] ~> Anchor['magnum::service::begin']
|
||||
Anchor['magnum::config::end'] ~> Anchor['magnum::service::begin']
|
||||
}
|
@ -96,6 +96,7 @@ class magnum(
|
||||
$rabbit_password = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
include ::magnum::params
|
||||
include ::magnum::logging
|
||||
include ::magnum::policy
|
||||
|
@ -64,7 +64,9 @@ class magnum::keystone::auth (
|
||||
$internal_url = 'http://127.0.0.1:9511/v1',
|
||||
) {
|
||||
|
||||
$real_service_name = pick($service_name, $auth_name)
|
||||
include ::magnum::deps
|
||||
|
||||
$real_service_name = pick($service_name, $auth_name)
|
||||
|
||||
if $configure_user_role {
|
||||
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'magnum-server' |>
|
||||
|
@ -219,6 +219,8 @@ class magnum::keystone::authtoken(
|
||||
$token_cache_time = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
keystone::resource::authtoken { 'magnum_config':
|
||||
username => $username,
|
||||
password => $password,
|
||||
|
@ -38,7 +38,9 @@ class magnum::keystone::domain (
|
||||
$manage_domain = true,
|
||||
$manage_user = true,
|
||||
$manage_role = true,
|
||||
) {
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
include ::magnum::params
|
||||
|
||||
if $manage_domain {
|
||||
|
@ -108,6 +108,8 @@ class magnum::logging(
|
||||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
oslo::log { 'magnum_config':
|
||||
debug => $debug,
|
||||
use_syslog => $use_syslog,
|
||||
|
@ -28,6 +28,8 @@ class magnum::policy (
|
||||
$policy_path = '/etc/magnum/policy.json',
|
||||
) {
|
||||
|
||||
include ::magnum::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
|
@ -0,0 +1,10 @@
|
||||
---
|
||||
prelude: >
|
||||
Add hooks for external install & svc management.
|
||||
features:
|
||||
- This adds defined anchor points for external modules to
|
||||
hook into the software install, config and service dependency
|
||||
chain. This allows external modules to manage software
|
||||
installation (virtualenv, containers, etc) and service management
|
||||
(pacemaker) without needing rely on resources that may change or
|
||||
be renamed.
|
@ -31,6 +31,7 @@ describe 'magnum::api' do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it { is_expected.to contain_class('magnum::deps') }
|
||||
it { is_expected.to contain_class('magnum::params') }
|
||||
it { is_expected.to contain_class('magnum::policy') }
|
||||
|
||||
@ -41,7 +42,6 @@ describe 'magnum::api' do
|
||||
:name => platform_params[:api_package],
|
||||
:tag => ['openstack', 'magnum-package'],
|
||||
)
|
||||
is_expected.to contain_package('magnum-api').with_before(/Service\[magnum-api\]/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,11 @@ describe 'magnum::db::sync' do
|
||||
:refreshonly => 'true',
|
||||
:try_sleep => 5,
|
||||
:tries => 10,
|
||||
:logoutput => 'on_failure'
|
||||
:logoutput => 'on_failure',
|
||||
:subscribe => ['Anchor[magnum::install::end]',
|
||||
'Anchor[magnum::config::end]',
|
||||
'Anchor[magnum::dbsync::begin]'],
|
||||
:notify => 'Anchor[magnum::dbsync::end]',
|
||||
)
|
||||
end
|
||||
|
||||
@ -31,7 +35,11 @@ describe 'magnum::db::sync' do
|
||||
:refreshonly => 'true',
|
||||
:try_sleep => 5,
|
||||
:tries => 10,
|
||||
:logoutput => 'on_failure'
|
||||
:logoutput => 'on_failure',
|
||||
:subscribe => ['Anchor[magnum::install::end]',
|
||||
'Anchor[magnum::config::end]',
|
||||
'Anchor[magnum::dbsync::begin]'],
|
||||
:notify => 'Anchor[magnum::dbsync::end]',
|
||||
)
|
||||
}
|
||||
end
|
||||
|
@ -11,6 +11,7 @@ describe 'magnum' do
|
||||
|
||||
it 'contains other classes' do
|
||||
is_expected.to contain_class('magnum::logging')
|
||||
is_expected.to contain_class('magnum::deps')
|
||||
is_expected.to contain_class('magnum::params')
|
||||
is_expected.to contain_class('magnum::policy')
|
||||
is_expected.to contain_class('magnum::db')
|
||||
|
Loading…
Reference in New Issue
Block a user