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: Ie0fa86a383a19b272a2bdaedb61ede73cad6934f
This commit is contained in:
parent
9bb0b75adc
commit
7e48371ebf
@ -68,15 +68,9 @@ class panko::api (
|
||||
$enable_proxy_headers_parsing = $::os_service_default,
|
||||
) inherits panko::params {
|
||||
|
||||
include ::panko::deps
|
||||
include ::panko::policy
|
||||
|
||||
Panko_config<||> ~> Service[$service_name]
|
||||
Panko_api_paste_ini<||> ~> Service[$service_name]
|
||||
Class['panko::policy'] ~> Service[$service_name]
|
||||
|
||||
Package['panko-api'] -> Service[$service_name]
|
||||
Package['panko-api'] -> Service['panko-api']
|
||||
Package['panko-api'] -> Class['panko::policy']
|
||||
package { 'panko-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::panko::params::api_package_name,
|
||||
@ -102,7 +96,6 @@ class panko::api (
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
require => Class['panko::db'],
|
||||
tag => ['panko-service', 'panko-db-sync-service'],
|
||||
}
|
||||
} elsif $service_name == 'httpd' {
|
||||
|
@ -28,6 +28,8 @@ class panko::config (
|
||||
$panko_api_paste_ini = {},
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
validate_hash($panko_config)
|
||||
validate_hash($panko_api_paste_ini)
|
||||
|
||||
|
@ -49,6 +49,8 @@ class panko::db (
|
||||
$database_max_overflow = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
validate_re($database_connection,
|
||||
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
|
@ -53,6 +53,8 @@ class panko::db::mysql(
|
||||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'panko':
|
||||
@ -65,5 +67,8 @@ class panko::db::mysql(
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['panko'] ~> Exec<| title == 'panko-db-sync' |>
|
||||
Anchor['panko::db::begin']
|
||||
~> Class['panko::db::mysql']
|
||||
~> Anchor['panko::db::end']
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class panko::db::postgresql(
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['panko::db::postgresql'] -> Service<| title == 'panko' |>
|
||||
include ::panko::deps
|
||||
|
||||
::openstacklib::db::postgresql { 'panko':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
@ -50,6 +50,8 @@ class panko::db::postgresql(
|
||||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['panko'] ~> Exec<| title == 'panko-db-sync' |>
|
||||
Anchor['panko::db::begin']
|
||||
~> Class['panko::db::postgresql']
|
||||
~> Anchor['panko::db::end']
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
class panko::db::sync(
|
||||
$extra_params = undef,
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
exec { 'panko-db-sync':
|
||||
command => "panko-dbsync --config-file /etc/panko/panko.conf ${extra_params}",
|
||||
path => '/usr/bin',
|
||||
@ -19,10 +22,12 @@ class panko::db::sync(
|
||||
try_sleep => 5,
|
||||
tries => 10,
|
||||
logoutput => 'on_failure',
|
||||
subscribe => [
|
||||
Anchor['panko::install::end'],
|
||||
Anchor['panko::config::end'],
|
||||
Anchor['panko::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['panko::dbsync::end'],
|
||||
}
|
||||
|
||||
Package<| tag == 'panko-package' |> ~> Exec['panko-db-sync']
|
||||
Exec['panko-db-sync'] ~> Service<| tag == 'panko-db-sync-service' |>
|
||||
Panko_config<||> ~> Exec['panko-db-sync']
|
||||
Panko_config<| title == 'database/connection' |> ~> Exec['panko-db-sync']
|
||||
}
|
||||
|
40
manifests/deps.pp
Normal file
40
manifests/deps.pp
Normal file
@ -0,0 +1,40 @@
|
||||
# == Class: panko::deps
|
||||
#
|
||||
# Panko anchors and dependency management
|
||||
#
|
||||
class panko::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 { 'panko::install::begin': }
|
||||
-> Package<| tag == 'panko-package'|>
|
||||
~> anchor { 'panko::install::end': }
|
||||
-> anchor { 'panko::config::begin': }
|
||||
-> Panko_config<||>
|
||||
~> anchor { 'panko::config::end': }
|
||||
-> anchor { 'panko::db::begin': }
|
||||
-> anchor { 'panko::db::end': }
|
||||
~> anchor { 'panko::dbsync::begin': }
|
||||
-> anchor { 'panko::dbsync::end': }
|
||||
~> anchor { 'panko::service::begin': }
|
||||
~> Service<| tag == 'panko-service' |>
|
||||
~> anchor { 'panko::service::end': }
|
||||
|
||||
# policy config should occur in the config block also.
|
||||
Anchor['panko::config::begin']
|
||||
-> Openstacklib::Policy::Base<||>
|
||||
~> Anchor['panko::config::end']
|
||||
|
||||
# api paste ini config should occur in the config block also.
|
||||
Anchor['panko::config::begin']
|
||||
-> Panko_api_paste_ini<||>
|
||||
~> Anchor['panko::config::end']
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['panko::install::end'] ~> Anchor['panko::service::begin']
|
||||
Anchor['panko::config::end'] ~> Anchor['panko::service::begin']
|
||||
}
|
@ -18,7 +18,7 @@ class panko (
|
||||
$purge_config = false,
|
||||
) inherits panko::params {
|
||||
|
||||
|
||||
include ::panko::deps
|
||||
include ::panko::logging
|
||||
|
||||
package { 'panko':
|
||||
|
@ -78,6 +78,7 @@ class panko::keystone::auth (
|
||||
$internal_url = 'http://127.0.0.1:8779',
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
keystone::resource::service_identity { 'panko':
|
||||
configure_user => $configure_user,
|
||||
|
@ -227,6 +227,8 @@ class panko::keystone::authtoken(
|
||||
$token_cache_time = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
keystone::resource::authtoken { 'panko_config':
|
||||
username => $username,
|
||||
password => $password,
|
||||
|
@ -113,6 +113,8 @@ class panko::logging(
|
||||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
oslo::log { 'panko_config':
|
||||
use_stderr => $use_stderr,
|
||||
use_syslog => $use_syslog,
|
||||
|
@ -28,6 +28,8 @@ class panko::policy (
|
||||
$policy_path = '/etc/panko/policy.json',
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
|
@ -91,6 +91,7 @@ class panko::wsgi::apache (
|
||||
$priority = '10',
|
||||
) {
|
||||
|
||||
include ::panko::deps
|
||||
include ::panko::params
|
||||
include ::apache
|
||||
include ::apache::mod::wsgi
|
||||
|
@ -22,6 +22,7 @@ describe 'panko::api' do
|
||||
|
||||
shared_examples_for 'panko-api' do
|
||||
|
||||
it { is_expected.to contain_class('panko::deps') }
|
||||
it { is_expected.to contain_class('panko::params') }
|
||||
it { is_expected.to contain_class('panko::policy') }
|
||||
|
||||
@ -54,10 +55,11 @@ describe 'panko::api' do
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:require => 'Class[Panko::Db]',
|
||||
:tag => ['panko-service', 'panko-db-sync-service'],
|
||||
)
|
||||
end
|
||||
it { is_expected.to contain_service('panko-api').that_subscribes_to('Anchor[panko::service::begin]')}
|
||||
it { is_expected.to contain_service('panko-api').that_notifies('Anchor[panko::service::end]')}
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user