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: I374c60ca08176d85c7b0c0efbdc481205d763376 Co-Authored-By: Clayton O'Neill <clayton.oneill@twcable.com>
This commit is contained in:
parent
ec7fff3dd6
commit
c31b7364db
@ -23,6 +23,7 @@
|
||||
class glare::config (
|
||||
$glare_config = {},
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
validate_hash($glare_config)
|
||||
|
||||
|
@ -42,6 +42,7 @@ class glare::db (
|
||||
$database_retry_interval = $::os_service_default,
|
||||
$database_max_overflow = $::os_service_default,
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
validate_re($database_connection,
|
||||
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
@ -52,6 +52,7 @@ class glare::db::mysql(
|
||||
$collate = 'utf8_general_ci',
|
||||
$allowed_hosts = undef
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
@ -66,4 +67,8 @@ class glare::db::mysql(
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['glare'] ~> Exec<| title == 'glare-db-sync' |>
|
||||
|
||||
Anchor['glare::db::begin']
|
||||
~> Class['glare::db::mysql']
|
||||
~> Anchor['glare::db::end']
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ class glare::db::postgresql(
|
||||
$encoding = undef,
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
Class['glare::db::postgresql'] -> Service<| title == 'glare' |>
|
||||
|
||||
@ -51,5 +52,8 @@ class glare::db::postgresql(
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['glare'] ~> Exec<| title == 'glare-db-sync' |>
|
||||
Anchor['glare::db::begin']
|
||||
~> Class['glare::db::postgresql']
|
||||
~> Anchor['glare::db::end']
|
||||
|
||||
}
|
||||
|
@ -12,14 +12,19 @@
|
||||
class glare::db::sync(
|
||||
$extra_params = '',
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
exec { 'glare-db-sync':
|
||||
command => "glare-db-manage ${extra_params} upgrade",
|
||||
user => 'glare',
|
||||
path => [ '/bin/', '/usr/bin/' , '/usr/local/bin' ],
|
||||
refreshonly => true,
|
||||
try_sleep => 5,
|
||||
tries => 10,
|
||||
subscribe => [Package['glare'], Glare_config['database/connection']],
|
||||
subscribe => [
|
||||
Anchor['glare::install::end'],
|
||||
Anchor['glare::config::end'],
|
||||
Anchor['glare::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['glare::dbsync::end'],
|
||||
}
|
||||
Exec['glare-db-sync'] ~> Service<| title == 'glare' |>
|
||||
}
|
||||
|
50
manifests/deps.pp
Normal file
50
manifests/deps.pp
Normal file
@ -0,0 +1,50 @@
|
||||
# == Class: glare::deps
|
||||
#
|
||||
# glare anchors and dependency management
|
||||
#
|
||||
class glare::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 { 'glare::install::begin': }
|
||||
-> Package<| tag == 'glare'|>
|
||||
~> anchor { 'glare::install::end': }
|
||||
-> anchor { 'glare::config::begin': }
|
||||
-> File<| tag == 'glare-config-file' |>
|
||||
~> anchor { 'glare::config::end': }
|
||||
-> anchor { 'glare::db::begin': }
|
||||
-> anchor { 'glare::db::end': }
|
||||
~> anchor { 'glare::dbsync::begin': }
|
||||
-> anchor { 'glare::dbsync::end': }
|
||||
~> anchor { 'glare::service::begin': }
|
||||
~> Service<| tag == 'glare' |>
|
||||
~> anchor { 'glare::service::end': }
|
||||
|
||||
# Ensure files are modified in the config block
|
||||
Anchor['glare::config::begin']
|
||||
-> File_line<| tag == 'glare-file-line' |>
|
||||
~> Anchor['glare::config::end']
|
||||
|
||||
# Ensure all files are in place before modifying them
|
||||
File<| tag == 'glare-config-file' |> -> File_line<| tag == 'glare-file-line' |>
|
||||
|
||||
# All other inifile providers need to be processed in the config block
|
||||
Anchor['glare::config::begin'] -> Glare_config<||> ~> Anchor['glare::config::end']
|
||||
Anchor['glare::config::begin'] -> Glare_paste_ini<||> ~> Anchor['glare::config::end']
|
||||
|
||||
# Support packages need to be installed in the install phase, but we don't
|
||||
# put them in the chain above because we don't want any false dependencies
|
||||
# between packages with the glare-package tag and the glare-support-package
|
||||
# tag. Note: the package resources here will have a 'before' relationshop on
|
||||
# the glare::install::end anchor. The line between glare-support-package and
|
||||
# glare-package should be whether or not glare services would need to be
|
||||
# restarted if the package state was changed.
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['glare::install::end'] ~> Anchor['glare::service::begin']
|
||||
Anchor['glare::config::end'] ~> Anchor['glare::service::begin']
|
||||
}
|
@ -112,10 +112,12 @@ class glare (
|
||||
include ::glare::params
|
||||
include ::glare::db
|
||||
include ::glare::logging
|
||||
include ::glare::deps
|
||||
|
||||
ensure_packages ( 'glare' , {
|
||||
ensure => $package_ensure,
|
||||
name => $::glare::params::glare_package_name,
|
||||
tag => ['openstack', 'glare-package'],
|
||||
})
|
||||
|
||||
glare_config {
|
||||
@ -171,6 +173,7 @@ class glare (
|
||||
service { 'glare':
|
||||
ensure => $service_ensure,
|
||||
name => $::glare::params::glare_service_name,
|
||||
enable => $enabled
|
||||
enable => $enabled,
|
||||
tag => 'glare',
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class glare::keystone::auth (
|
||||
$admin_url = 'http://127.0.0.1:FIXME',
|
||||
$internal_url = 'http://127.0.0.1:FIXME',
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
if $configure_user_role {
|
||||
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'glare-server' |>
|
||||
|
@ -221,6 +221,7 @@ class glare::keystone::authtoken(
|
||||
$signing_dir = $::os_service_default,
|
||||
$token_cache_time = $::os_service_default,
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
keystone::resource::authtoken { 'glare_config':
|
||||
username => $username,
|
||||
|
@ -112,6 +112,7 @@ class glare::logging(
|
||||
$instance_uuid_format = $::os_service_default,
|
||||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
oslo::log { 'glare_config':
|
||||
use_stderr => $use_stderr,
|
||||
|
@ -27,6 +27,7 @@ class glare::policy (
|
||||
$policies = {},
|
||||
$policy_path = '/etc/glare/policy.json',
|
||||
) {
|
||||
include ::glare::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user