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: Ibc184a50cf16b7048e0f7249f8894d8661bb76fe
(cherry picked from commit cb865e6e5b
)
This commit is contained in:
parent
0ec76c62a3
commit
a73d235fd9
|
@ -145,6 +145,7 @@ class aodh::api (
|
|||
warning('aodh::api::memcached_servers is deprecated, use aodh::keystone::authtoken::memcached_servers instead.')
|
||||
}
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::params
|
||||
include ::aodh::policy
|
||||
|
||||
|
@ -152,12 +153,6 @@ class aodh::api (
|
|||
include ::aodh::keystone::authtoken
|
||||
}
|
||||
|
||||
Aodh_config<||> ~> Service[$service_name]
|
||||
Class['aodh::policy'] ~> Service[$service_name]
|
||||
|
||||
Package['aodh-api'] -> Service[$service_name]
|
||||
Package['aodh-api'] -> Service['aodh-api']
|
||||
Package['aodh-api'] -> Class['aodh::policy']
|
||||
package { 'aodh-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::aodh::params::api_package_name,
|
||||
|
@ -183,7 +178,6 @@ class aodh::api (
|
|||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
require => Class['aodh::db'],
|
||||
tag => 'aodh-service',
|
||||
}
|
||||
} elsif $service_name == 'httpd' {
|
||||
|
@ -194,7 +188,6 @@ class aodh::api (
|
|||
enable => false,
|
||||
tag => 'aodh-service',
|
||||
}
|
||||
Class['aodh::db'] -> Service[$service_name]
|
||||
|
||||
# we need to make sure aodh-api/eventlet is stopped before trying to start apache
|
||||
Service['aodh-api'] -> Service[$service_name]
|
||||
|
|
|
@ -61,6 +61,8 @@ class aodh::auth (
|
|||
$auth_endpoint_type = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
aodh_config {
|
||||
'service_credentials/auth_url' : value => $auth_url;
|
||||
'service_credentials/region_name' : value => $auth_region;
|
||||
|
|
|
@ -9,6 +9,7 @@ class aodh::client (
|
|||
$ensure = 'present'
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::params
|
||||
|
||||
package { 'python-aodhclient':
|
||||
|
|
|
@ -28,6 +28,8 @@ class aodh::config (
|
|||
$aodh_api_paste_ini = {},
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
validate_hash($aodh_config)
|
||||
validate_hash($aodh_api_paste_ini)
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ class aodh::db (
|
|||
$database_max_overflow = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
$database_connection_real = pick($::aodh::database_connection, $database_connection)
|
||||
$database_idle_timeout_real = pick($::aodh::database_idle_timeout, $database_idle_timeout)
|
||||
$database_min_pool_size_real = pick($::aodh::database_min_pool_size, $database_min_pool_size)
|
||||
|
|
|
@ -53,6 +53,8 @@ class aodh::db::mysql(
|
|||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'aodh':
|
||||
|
@ -65,5 +67,8 @@ class aodh::db::mysql(
|
|||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['aodh'] ~> Exec<| title == 'aodh-db-sync' |>
|
||||
Anchor['aodh::db::begin']
|
||||
~> Class['aodh::db::mysql']
|
||||
~> Anchor['aodh::db::end']
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class aodh::db::postgresql(
|
|||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['aodh::db::postgresql'] -> Service<| title == 'aodh' |>
|
||||
include ::aodh::deps
|
||||
|
||||
::openstacklib::db::postgresql { 'aodh':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
|
@ -50,6 +50,8 @@ class aodh::db::postgresql(
|
|||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['aodh'] ~> Exec<| title == 'aodh-db-sync' |>
|
||||
Anchor['aodh::db::begin']
|
||||
~> Class['aodh::db::postgresql']
|
||||
~> Anchor['aodh::db::end']
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
class aodh::db::sync (
|
||||
$user = 'aodh',
|
||||
){
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
exec { 'aodh-db-sync':
|
||||
command => 'aodh-dbsync --config-file /etc/aodh/aodh.conf',
|
||||
path => '/usr/bin',
|
||||
|
@ -16,10 +19,12 @@ class aodh::db::sync (
|
|||
try_sleep => 5,
|
||||
tries => 10,
|
||||
logoutput => on_failure,
|
||||
subscribe => [
|
||||
Anchor['aodh::install::end'],
|
||||
Anchor['aodh::config::end'],
|
||||
Anchor['aodh::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['aodh::dbsync::end'],
|
||||
}
|
||||
|
||||
Package<| tag == 'aodh-package' |> ~> Exec['aodh-db-sync']
|
||||
Exec['aodh-db-sync'] ~> Service<| tag == 'aodh-db-sync-service' |>
|
||||
Aodh_config<||> ~> Exec['aodh-db-sync']
|
||||
Aodh_config<| title == 'database/connection' |> ~> Exec['aodh-db-sync']
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# == Class: aodh::deps
|
||||
#
|
||||
# Aodh anchors and dependency management
|
||||
#
|
||||
class aodh::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 { 'aodh::install::begin': }
|
||||
-> Package<| tag == 'aodh-package'|>
|
||||
~> anchor { 'aodh::install::end': }
|
||||
-> anchor { 'aodh::config::begin': }
|
||||
-> Aodh_config<||>
|
||||
~> anchor { 'aodh::config::end': }
|
||||
-> anchor { 'aodh::db::begin': }
|
||||
-> anchor { 'aodh::db::end': }
|
||||
~> anchor { 'aodh::dbsync::begin': }
|
||||
-> anchor { 'aodh::dbsync::end': }
|
||||
~> anchor { 'aodh::service::begin': }
|
||||
~> Service<| tag == 'aodh-service' |>
|
||||
~> anchor { 'aodh::service::end': }
|
||||
|
||||
# policy config should occur in the config block also.
|
||||
Anchor['aodh::config::begin']
|
||||
-> Openstacklib::Policy::Base<||>
|
||||
~> Anchor['aodh::config::end']
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['aodh::install::end'] ~> Anchor['aodh::service::begin']
|
||||
Anchor['aodh::config::end'] ~> Anchor['aodh::service::begin']
|
||||
}
|
|
@ -24,17 +24,15 @@ class aodh::evaluator (
|
|||
$coordination_url = undef,
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::params
|
||||
|
||||
Aodh_config<||> ~> Service['aodh-evaluator']
|
||||
|
||||
if $coordination_url {
|
||||
aodh_config {
|
||||
'coordination/backend_url' : value => $coordination_url;
|
||||
}
|
||||
}
|
||||
|
||||
Package[$::aodh::params::evaluator_package_name] -> Service['aodh-evaluator']
|
||||
ensure_resource( 'package', [$::aodh::params::evaluator_package_name],
|
||||
{ ensure => $package_ensure,
|
||||
tag => ['openstack', 'aodh-package'] }
|
||||
|
@ -48,7 +46,6 @@ class aodh::evaluator (
|
|||
}
|
||||
}
|
||||
|
||||
Package['aodh'] -> Service['aodh-evaluator']
|
||||
service { 'aodh-evaluator':
|
||||
ensure => $service_ensure,
|
||||
name => $::aodh::params::evaluator_service_name,
|
||||
|
|
|
@ -314,6 +314,7 @@ class aodh (
|
|||
$verbose = undef,
|
||||
) inherits aodh::params {
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::db
|
||||
include ::aodh::logging
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ class aodh::keystone::auth (
|
|||
$admin_url = 'http://127.0.0.1:8042',
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
keystone::resource::service_identity { 'aodh':
|
||||
configure_user => $configure_user,
|
||||
configure_user_role => $configure_user_role,
|
||||
|
|
|
@ -231,6 +231,7 @@ class aodh::keystone::authtoken(
|
|||
if is_service_default($password) and ! $::aodh::api::keystone_password {
|
||||
fail('Please set password for Aodh service user')
|
||||
}
|
||||
include ::aodh::deps
|
||||
|
||||
$username_real = pick($::aodh::api::keystone_user, $username)
|
||||
$password_real = pick($::aodh::api::keystone_password, $password)
|
||||
|
|
|
@ -19,11 +19,9 @@ class aodh::listener (
|
|||
$package_ensure = 'present',
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::params
|
||||
|
||||
Aodh_config<||> ~> Service['aodh-listener']
|
||||
|
||||
Package[$::aodh::params::listener_package_name] -> Service['aodh-listener']
|
||||
ensure_resource( 'package', [$::aodh::params::listener_package_name],
|
||||
{ ensure => $package_ensure,
|
||||
tag => ['openstack', 'aodh-package'] }
|
||||
|
@ -37,7 +35,6 @@ class aodh::listener (
|
|||
}
|
||||
}
|
||||
|
||||
Package['aodh'] -> Service['aodh-listener']
|
||||
service { 'aodh-listener':
|
||||
ensure => $service_ensure,
|
||||
name => $::aodh::params::listener_service_name,
|
||||
|
|
|
@ -116,6 +116,7 @@ class aodh::logging(
|
|||
if $verbose {
|
||||
warning('verbose is deprecated, has no effect and will be removed after Newton cycle.')
|
||||
}
|
||||
include ::aodh::deps
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use aodh::<myparam> first then aodh::logging::<myparam>.
|
||||
|
|
|
@ -19,11 +19,9 @@ class aodh::notifier (
|
|||
$package_ensure = 'present',
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::params
|
||||
|
||||
Aodh_config<||> ~> Service['aodh-notifier']
|
||||
|
||||
Package[$::aodh::params::notifier_package_name] -> Service['aodh-notifier']
|
||||
ensure_resource( 'package', [$::aodh::params::notifier_package_name],
|
||||
{ ensure => $package_ensure,
|
||||
tag => ['openstack', 'aodh-package'] }
|
||||
|
@ -37,7 +35,6 @@ class aodh::notifier (
|
|||
}
|
||||
}
|
||||
|
||||
Package['aodh'] -> Service['aodh-notifier']
|
||||
service { 'aodh-notifier':
|
||||
ensure => $service_ensure,
|
||||
name => $::aodh::params::notifier_service_name,
|
||||
|
|
|
@ -28,6 +28,8 @@ class aodh::policy (
|
|||
$policy_path = '/etc/aodh/policy.json',
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
|
|
|
@ -94,6 +94,7 @@ class aodh::wsgi::apache (
|
|||
$priority = '10',
|
||||
) {
|
||||
|
||||
include ::aodh::deps
|
||||
include ::aodh::params
|
||||
include ::apache
|
||||
include ::apache::mod::wsgi
|
||||
|
|
|
@ -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.
|
|
@ -19,6 +19,7 @@ describe 'aodh::api' do
|
|||
|
||||
shared_examples_for 'aodh-api' do
|
||||
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::params') }
|
||||
it { is_expected.to contain_class('aodh::policy') }
|
||||
|
||||
|
@ -49,10 +50,11 @@ describe 'aodh::api' do
|
|||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:require => 'Class[Aodh::Db]',
|
||||
:tag => 'aodh-service',
|
||||
)
|
||||
end
|
||||
it { is_expected.to contain_service('aodh-api').that_subscribes_to('Anchor[aodh::service::begin]')}
|
||||
it { is_expected.to contain_service('aodh-api').that_notifies('Anchor[aodh::service::end]')}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'aodh::client' do
|
|||
|
||||
shared_examples_for 'aodh client' do
|
||||
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::params') }
|
||||
|
||||
it 'installs aodh client package' do
|
||||
|
|
|
@ -4,13 +4,19 @@ describe 'aodh::db::sync' do
|
|||
|
||||
shared_examples_for 'aodh-dbsync' do
|
||||
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
|
||||
it 'runs aodh-db-sync' do
|
||||
is_expected.to contain_exec('aodh-db-sync').with(
|
||||
:command => 'aodh-dbsync --config-file /etc/aodh/aodh.conf',
|
||||
:path => '/usr/bin',
|
||||
:refreshonly => 'true',
|
||||
:user => 'aodh',
|
||||
:logoutput => 'on_failure'
|
||||
:logoutput => 'on_failure',
|
||||
:subscribe => ['Anchor[aodh::install::end]',
|
||||
'Anchor[aodh::config::end]',
|
||||
'Anchor[aodh::dbsync::begin]'],
|
||||
:notify => 'Anchor[aodh::dbsync::end]',
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -4,9 +4,13 @@ describe 'aodh' do
|
|||
|
||||
shared_examples 'aodh' do
|
||||
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::db') }
|
||||
it { is_expected.to contain_class('aodh::logging') }
|
||||
|
||||
context 'with default parameters' do
|
||||
let :params do
|
||||
{ :purge_config => false }
|
||||
{ :purge_config => false }
|
||||
end
|
||||
|
||||
it 'contains the logging class' do
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'aodh::wsgi::apache' do
|
|||
|
||||
shared_examples_for 'apache serving aodh with mod_wsgi' do
|
||||
it { is_expected.to contain_service('httpd').with_name(platform_parameters[:httpd_service_name]) }
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::params') }
|
||||
it { is_expected.to contain_class('apache') }
|
||||
it { is_expected.to contain_class('apache::mod::wsgi') }
|
||||
|
|
Loading…
Reference in New Issue