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: If4f585264f5f5a15549855d97b532866d91f5215
This commit is contained in:
parent
a85d3bc12c
commit
c54428f524
@ -24,6 +24,8 @@ class zaqar::config (
|
||||
$zaqar_config = {},
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
validate_hash($zaqar_config)
|
||||
|
||||
create_resources('zaqar_config', $zaqar_config)
|
||||
|
@ -53,6 +53,8 @@ class zaqar::db::mysql(
|
||||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'zaqar':
|
||||
@ -65,5 +67,8 @@ class zaqar::db::mysql(
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['zaqar'] ~> Exec<| title == 'zaqar-manage db_sync' |>
|
||||
Anchor['zaqar::db::begin']
|
||||
~> Class['zaqar::db::mysql']
|
||||
~> Anchor['zaqar::db::end']
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class zaqar::db::postgresql(
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['zaqar::db::postgresql'] -> Service<| title == 'zaqar' |>
|
||||
include ::zaqar::deps
|
||||
|
||||
::openstacklib::db::postgresql { 'zaqar':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
@ -50,6 +50,8 @@ class zaqar::db::postgresql(
|
||||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['zaqar'] ~> Exec<| title == 'zaqar-manage db_sync' |>
|
||||
Anchor['zaqar::db::begin']
|
||||
~> Class['zaqar::db::postgresql']
|
||||
~> Anchor['zaqar::db::end']
|
||||
|
||||
}
|
||||
|
@ -2,14 +2,21 @@
|
||||
# Class to execute "zaqar-manage db_sync
|
||||
#
|
||||
class zaqar::db::sync {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
exec { 'zaqar-manage db_sync':
|
||||
path => '/usr/bin',
|
||||
user => 'zaqar',
|
||||
refreshonly => true,
|
||||
try_sleep => 5,
|
||||
tries => 10,
|
||||
subscribe => [Package['zaqar'], Zaqar_config['database/connection']],
|
||||
subscribe => [
|
||||
Anchor['zaqar::install::end'],
|
||||
Anchor['zaqar::config::end'],
|
||||
Anchor['zaqar::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['zaqar::dbsync::end'],
|
||||
}
|
||||
|
||||
Exec['zaqar-manage db_sync'] ~> Service<| title == 'zaqar' |>
|
||||
}
|
||||
|
35
manifests/deps.pp
Normal file
35
manifests/deps.pp
Normal file
@ -0,0 +1,35 @@
|
||||
# == Class: zaqar::deps
|
||||
#
|
||||
# Zaqar anchors and dependency management
|
||||
#
|
||||
class zaqar::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 { 'zaqar::install::begin': }
|
||||
-> Package<| tag == 'zaqar-package'|>
|
||||
~> anchor { 'zaqar::install::end': }
|
||||
-> anchor { 'zaqar::config::begin': }
|
||||
-> Zaqar_config<||>
|
||||
~> anchor { 'zaqar::config::end': }
|
||||
-> anchor { 'zaqar::db::begin': }
|
||||
-> anchor { 'zaqar::db::end': }
|
||||
~> anchor { 'zaqar::dbsync::begin': }
|
||||
-> anchor { 'zaqar::dbsync::end': }
|
||||
~> anchor { 'zaqar::service::begin': }
|
||||
~> Service<| tag == 'zaqar-service' |>
|
||||
~> anchor { 'zaqar::service::end': }
|
||||
|
||||
# policy config should occur in the config block also.
|
||||
Anchor['zaqar::config::begin']
|
||||
-> Openstacklib::Policy::Base<||>
|
||||
~> Anchor['zaqar::config::end']
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['zaqar::install::end'] ~> Anchor['zaqar::service::begin']
|
||||
Anchor['zaqar::config::end'] ~> Anchor['zaqar::service::begin']
|
||||
}
|
@ -78,6 +78,8 @@ class zaqar(
|
||||
$purge_config = false,
|
||||
) inherits zaqar::params {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
resources { 'zaqar_config':
|
||||
purge => $purge_config,
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ class zaqar::keystone::auth(
|
||||
$service_description = 'Openstack messaging Service',
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
keystone::resource::service_identity { 'zaqar':
|
||||
|
@ -74,6 +74,8 @@ class zaqar::keystone::auth_websocket(
|
||||
$service_description = 'Openstack messaging websocket Service',
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
keystone::resource::service_identity { 'zaqar-websocket':
|
||||
|
@ -223,6 +223,8 @@ class zaqar::keystone::authtoken(
|
||||
$token_cache_time = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
if is_service_default($password) {
|
||||
fail('Please set password for Zaqar service user')
|
||||
}
|
||||
|
@ -82,6 +82,8 @@ class zaqar::logging(
|
||||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
oslo::log { 'zaqar_config':
|
||||
logging_context_format_string => $logging_context_format_string,
|
||||
logging_default_format_string => $logging_default_format_string,
|
||||
|
@ -71,6 +71,8 @@ class zaqar::management::mongodb(
|
||||
$reconnect_sleep = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
zaqar_config {
|
||||
'drivers/management_store': value => 'mongodb';
|
||||
'drivers:management_store:mongodb/uri': value => $uri, secret => true;
|
||||
|
@ -78,6 +78,8 @@ class zaqar::messaging::mongodb(
|
||||
$partitions = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
zaqar_config {
|
||||
'drivers/message_store': value => 'mongodb';
|
||||
'drivers:message_store:mongodb/uri': value => $uri, secret => true;
|
||||
|
@ -28,6 +28,8 @@ class zaqar::policy (
|
||||
$policy_path = '/etc/zaqar/policy.json',
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
|
@ -16,6 +16,7 @@ class zaqar::server(
|
||||
) {
|
||||
|
||||
include ::zaqar
|
||||
include ::zaqar::deps
|
||||
include ::zaqar::params
|
||||
|
||||
if $manage_service {
|
||||
@ -30,8 +31,8 @@ class zaqar::server(
|
||||
service { $::zaqar::params::service_name:
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
tag => 'zaqar-service'
|
||||
}
|
||||
Zaqar_config<||> ~> Service[$::zaqar::params::service_name]
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,10 @@ define zaqar::server_instance(
|
||||
$enabled = true,
|
||||
) {
|
||||
|
||||
include ::zaqar
|
||||
include ::zaqar::deps
|
||||
include ::zaqar::params
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
@ -27,17 +31,13 @@ define zaqar::server_instance(
|
||||
content => template('zaqar/zaqar.conf.erb'),
|
||||
}
|
||||
|
||||
include ::zaqar
|
||||
include ::zaqar::params
|
||||
|
||||
service { "${::zaqar::params::service_name}@${name}":
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
tag => 'zaqar-service'
|
||||
}
|
||||
|
||||
Package['zaqar-common'] ~> Service["${::zaqar::params::service_name}@${name}"]
|
||||
Package['zaqar-common'] ~> File["/etc/zaqar/${name}.conf"]
|
||||
File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"]
|
||||
Zaqar_config<||> ~> Service["${::zaqar::params::service_name}@${name}"]
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ class zaqar::transport::websocket(
|
||||
$external_port = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
zaqar_config {
|
||||
'drivers:transport:websocket/bind': value => $bind;
|
||||
'drivers:transport:websocket/port': value => $port;
|
||||
|
@ -13,6 +13,8 @@ class zaqar::transport::wsgi(
|
||||
$port = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::zaqar::deps
|
||||
|
||||
zaqar_config {
|
||||
'drivers:transport:wsgi/bind': value => $bind;
|
||||
'drivers:transport:wsgi/port': value => $port;
|
||||
|
@ -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.
|
@ -27,6 +27,7 @@ describe 'zaqar' do
|
||||
:tag => ['openstack', 'zaqar-package']
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_class('zaqar::deps') }
|
||||
it { is_expected.to contain_class('zaqar::params') }
|
||||
|
||||
it 'should contain default config' do
|
||||
|
Loading…
Reference in New Issue
Block a user