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
This commit is contained in:
parent
fb5961a3be
commit
cb865e6e5b
@ -57,6 +57,7 @@ class aodh::api (
|
|||||||
) inherits aodh::params {
|
) inherits aodh::params {
|
||||||
|
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::params
|
include ::aodh::params
|
||||||
include ::aodh::policy
|
include ::aodh::policy
|
||||||
|
|
||||||
@ -64,12 +65,6 @@ class aodh::api (
|
|||||||
include ::aodh::keystone::authtoken
|
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':
|
package { 'aodh-api':
|
||||||
ensure => $package_ensure,
|
ensure => $package_ensure,
|
||||||
name => $::aodh::params::api_package_name,
|
name => $::aodh::params::api_package_name,
|
||||||
@ -95,7 +90,6 @@ class aodh::api (
|
|||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
require => Class['aodh::db'],
|
|
||||||
tag => 'aodh-service',
|
tag => 'aodh-service',
|
||||||
}
|
}
|
||||||
} elsif $service_name == 'httpd' {
|
} elsif $service_name == 'httpd' {
|
||||||
@ -106,7 +100,6 @@ class aodh::api (
|
|||||||
enable => false,
|
enable => false,
|
||||||
tag => 'aodh-service',
|
tag => 'aodh-service',
|
||||||
}
|
}
|
||||||
Class['aodh::db'] -> Service[$service_name]
|
|
||||||
|
|
||||||
# we need to make sure aodh-api/eventlet is stopped before trying to start apache
|
# we need to make sure aodh-api/eventlet is stopped before trying to start apache
|
||||||
Service['aodh-api'] -> Service[$service_name]
|
Service['aodh-api'] -> Service[$service_name]
|
||||||
|
@ -61,6 +61,8 @@ class aodh::auth (
|
|||||||
$auth_endpoint_type = $::os_service_default,
|
$auth_endpoint_type = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
aodh_config {
|
aodh_config {
|
||||||
'service_credentials/auth_url' : value => $auth_url;
|
'service_credentials/auth_url' : value => $auth_url;
|
||||||
'service_credentials/region_name' : value => $auth_region;
|
'service_credentials/region_name' : value => $auth_region;
|
||||||
|
@ -9,6 +9,7 @@ class aodh::client (
|
|||||||
$ensure = 'present'
|
$ensure = 'present'
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::params
|
include ::aodh::params
|
||||||
|
|
||||||
package { 'python-aodhclient':
|
package { 'python-aodhclient':
|
||||||
|
@ -28,6 +28,8 @@ class aodh::config (
|
|||||||
$aodh_api_paste_ini = {},
|
$aodh_api_paste_ini = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
validate_hash($aodh_config)
|
validate_hash($aodh_config)
|
||||||
validate_hash($aodh_api_paste_ini)
|
validate_hash($aodh_api_paste_ini)
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ class aodh::db (
|
|||||||
$database_max_overflow = $::os_service_default,
|
$database_max_overflow = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
$database_connection_real = pick($::aodh::database_connection, $database_connection)
|
$database_connection_real = pick($::aodh::database_connection, $database_connection)
|
||||||
$database_idle_timeout_real = pick($::aodh::database_idle_timeout, $database_idle_timeout)
|
$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)
|
$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
|
$allowed_hosts = undef
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
validate_string($password)
|
validate_string($password)
|
||||||
|
|
||||||
::openstacklib::db::mysql { 'aodh':
|
::openstacklib::db::mysql { 'aodh':
|
||||||
@ -65,5 +67,8 @@ class aodh::db::mysql(
|
|||||||
allowed_hosts => $allowed_hosts,
|
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',
|
$privileges = 'ALL',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Class['aodh::db::postgresql'] -> Service<| title == 'aodh' |>
|
include ::aodh::deps
|
||||||
|
|
||||||
::openstacklib::db::postgresql { 'aodh':
|
::openstacklib::db::postgresql { 'aodh':
|
||||||
password_hash => postgresql_password($user, $password),
|
password_hash => postgresql_password($user, $password),
|
||||||
@ -50,6 +50,8 @@ class aodh::db::postgresql(
|
|||||||
privileges => $privileges,
|
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 (
|
class aodh::db::sync (
|
||||||
$user = 'aodh',
|
$user = 'aodh',
|
||||||
){
|
){
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
exec { 'aodh-db-sync':
|
exec { 'aodh-db-sync':
|
||||||
command => 'aodh-dbsync --config-file /etc/aodh/aodh.conf',
|
command => 'aodh-dbsync --config-file /etc/aodh/aodh.conf',
|
||||||
path => '/usr/bin',
|
path => '/usr/bin',
|
||||||
@ -16,10 +19,12 @@ class aodh::db::sync (
|
|||||||
try_sleep => 5,
|
try_sleep => 5,
|
||||||
tries => 10,
|
tries => 10,
|
||||||
logoutput => on_failure,
|
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']
|
|
||||||
}
|
}
|
||||||
|
35
manifests/deps.pp
Normal file
35
manifests/deps.pp
Normal file
@ -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,
|
$coordination_url = undef,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::params
|
include ::aodh::params
|
||||||
|
|
||||||
Aodh_config<||> ~> Service['aodh-evaluator']
|
|
||||||
|
|
||||||
if $coordination_url {
|
if $coordination_url {
|
||||||
aodh_config {
|
aodh_config {
|
||||||
'coordination/backend_url' : value => $coordination_url;
|
'coordination/backend_url' : value => $coordination_url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Package[$::aodh::params::evaluator_package_name] -> Service['aodh-evaluator']
|
|
||||||
ensure_resource( 'package', [$::aodh::params::evaluator_package_name],
|
ensure_resource( 'package', [$::aodh::params::evaluator_package_name],
|
||||||
{ ensure => $package_ensure,
|
{ ensure => $package_ensure,
|
||||||
tag => ['openstack', 'aodh-package'] }
|
tag => ['openstack', 'aodh-package'] }
|
||||||
@ -48,7 +46,6 @@ class aodh::evaluator (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['aodh'] -> Service['aodh-evaluator']
|
|
||||||
service { 'aodh-evaluator':
|
service { 'aodh-evaluator':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $::aodh::params::evaluator_service_name,
|
name => $::aodh::params::evaluator_service_name,
|
||||||
|
@ -309,6 +309,7 @@ class aodh (
|
|||||||
$rabbit_virtual_host = $::os_service_default,
|
$rabbit_virtual_host = $::os_service_default,
|
||||||
) inherits aodh::params {
|
) inherits aodh::params {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::db
|
include ::aodh::db
|
||||||
include ::aodh::logging
|
include ::aodh::logging
|
||||||
|
|
||||||
|
@ -65,6 +65,8 @@ class aodh::keystone::auth (
|
|||||||
$admin_url = 'http://127.0.0.1:8042',
|
$admin_url = 'http://127.0.0.1:8042',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
keystone::resource::service_identity { 'aodh':
|
keystone::resource::service_identity { 'aodh':
|
||||||
configure_user => $configure_user,
|
configure_user => $configure_user,
|
||||||
configure_user_role => $configure_user_role,
|
configure_user_role => $configure_user_role,
|
||||||
|
@ -223,6 +223,8 @@ class aodh::keystone::authtoken(
|
|||||||
$token_cache_time = $::os_service_default,
|
$token_cache_time = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
if is_service_default($password) {
|
if is_service_default($password) {
|
||||||
fail('Please set password for Aodh service user')
|
fail('Please set password for Aodh service user')
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,9 @@ class aodh::listener (
|
|||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::params
|
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_resource( 'package', [$::aodh::params::listener_package_name],
|
||||||
{ ensure => $package_ensure,
|
{ ensure => $package_ensure,
|
||||||
tag => ['openstack', 'aodh-package'] }
|
tag => ['openstack', 'aodh-package'] }
|
||||||
@ -37,7 +35,6 @@ class aodh::listener (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['aodh'] -> Service['aodh-listener']
|
|
||||||
service { 'aodh-listener':
|
service { 'aodh-listener':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $::aodh::params::listener_service_name,
|
name => $::aodh::params::listener_service_name,
|
||||||
|
@ -105,6 +105,8 @@ class aodh::logging(
|
|||||||
$log_date_format = $::os_service_default,
|
$log_date_format = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||||
# to use aodh::<myparam> first then aodh::logging::<myparam>.
|
# to use aodh::<myparam> first then aodh::logging::<myparam>.
|
||||||
$use_syslog_real = pick($::aodh::use_syslog,$use_syslog)
|
$use_syslog_real = pick($::aodh::use_syslog,$use_syslog)
|
||||||
|
@ -19,11 +19,9 @@ class aodh::notifier (
|
|||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::params
|
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_resource( 'package', [$::aodh::params::notifier_package_name],
|
||||||
{ ensure => $package_ensure,
|
{ ensure => $package_ensure,
|
||||||
tag => ['openstack', 'aodh-package'] }
|
tag => ['openstack', 'aodh-package'] }
|
||||||
@ -37,7 +35,6 @@ class aodh::notifier (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['aodh'] -> Service['aodh-notifier']
|
|
||||||
service { 'aodh-notifier':
|
service { 'aodh-notifier':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $::aodh::params::notifier_service_name,
|
name => $::aodh::params::notifier_service_name,
|
||||||
|
@ -28,6 +28,8 @@ class aodh::policy (
|
|||||||
$policy_path = '/etc/aodh/policy.json',
|
$policy_path = '/etc/aodh/policy.json',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
|
|
||||||
validate_hash($policies)
|
validate_hash($policies)
|
||||||
|
|
||||||
Openstacklib::Policy::Base {
|
Openstacklib::Policy::Base {
|
||||||
|
@ -94,6 +94,7 @@ class aodh::wsgi::apache (
|
|||||||
$priority = '10',
|
$priority = '10',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::aodh::deps
|
||||||
include ::aodh::params
|
include ::aodh::params
|
||||||
include ::apache
|
include ::apache
|
||||||
include ::apache::mod::wsgi
|
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.
|
@ -21,6 +21,7 @@ describe 'aodh::api' do
|
|||||||
|
|
||||||
shared_examples_for '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::params') }
|
||||||
it { is_expected.to contain_class('aodh::policy') }
|
it { is_expected.to contain_class('aodh::policy') }
|
||||||
|
|
||||||
@ -51,10 +52,11 @@ describe 'aodh::api' do
|
|||||||
:enable => params[:enabled],
|
:enable => params[:enabled],
|
||||||
:hasstatus => true,
|
:hasstatus => true,
|
||||||
:hasrestart => true,
|
:hasrestart => true,
|
||||||
:require => 'Class[Aodh::Db]',
|
|
||||||
:tag => 'aodh-service',
|
:tag => 'aodh-service',
|
||||||
)
|
)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ describe 'aodh::client' do
|
|||||||
|
|
||||||
shared_examples_for '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 { is_expected.to contain_class('aodh::params') }
|
||||||
|
|
||||||
it 'installs aodh client package' do
|
it 'installs aodh client package' do
|
||||||
|
@ -4,13 +4,19 @@ describe 'aodh::db::sync' do
|
|||||||
|
|
||||||
shared_examples_for 'aodh-dbsync' do
|
shared_examples_for 'aodh-dbsync' do
|
||||||
|
|
||||||
|
it { is_expected.to contain_class('aodh::deps') }
|
||||||
|
|
||||||
it 'runs aodh-db-sync' do
|
it 'runs aodh-db-sync' do
|
||||||
is_expected.to contain_exec('aodh-db-sync').with(
|
is_expected.to contain_exec('aodh-db-sync').with(
|
||||||
:command => 'aodh-dbsync --config-file /etc/aodh/aodh.conf',
|
:command => 'aodh-dbsync --config-file /etc/aodh/aodh.conf',
|
||||||
:path => '/usr/bin',
|
:path => '/usr/bin',
|
||||||
:refreshonly => 'true',
|
:refreshonly => 'true',
|
||||||
:user => 'aodh',
|
: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
|
end
|
||||||
|
|
||||||
|
@ -4,9 +4,13 @@ describe 'aodh' do
|
|||||||
|
|
||||||
shared_examples '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
|
context 'with default parameters' do
|
||||||
let :params do
|
let :params do
|
||||||
{ :purge_config => false }
|
{ :purge_config => false }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'contains the logging class' do
|
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
|
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_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('aodh::params') }
|
||||||
it { is_expected.to contain_class('apache') }
|
it { is_expected.to contain_class('apache') }
|
||||||
it { is_expected.to contain_class('apache::mod::wsgi') }
|
it { is_expected.to contain_class('apache::mod::wsgi') }
|
||||||
|
Loading…
Reference in New Issue
Block a user