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 = {},
|
$zaqar_config = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
validate_hash($zaqar_config)
|
validate_hash($zaqar_config)
|
||||||
|
|
||||||
create_resources('zaqar_config', $zaqar_config)
|
create_resources('zaqar_config', $zaqar_config)
|
||||||
|
@ -53,6 +53,8 @@ class zaqar::db::mysql(
|
|||||||
$allowed_hosts = undef
|
$allowed_hosts = undef
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
validate_string($password)
|
validate_string($password)
|
||||||
|
|
||||||
::openstacklib::db::mysql { 'zaqar':
|
::openstacklib::db::mysql { 'zaqar':
|
||||||
@ -65,5 +67,8 @@ class zaqar::db::mysql(
|
|||||||
allowed_hosts => $allowed_hosts,
|
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',
|
$privileges = 'ALL',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Class['zaqar::db::postgresql'] -> Service<| title == 'zaqar' |>
|
include ::zaqar::deps
|
||||||
|
|
||||||
::openstacklib::db::postgresql { 'zaqar':
|
::openstacklib::db::postgresql { 'zaqar':
|
||||||
password_hash => postgresql_password($user, $password),
|
password_hash => postgresql_password($user, $password),
|
||||||
@ -50,6 +50,8 @@ class zaqar::db::postgresql(
|
|||||||
privileges => $privileges,
|
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 to execute "zaqar-manage db_sync
|
||||||
#
|
#
|
||||||
class zaqar::db::sync {
|
class zaqar::db::sync {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
exec { 'zaqar-manage db_sync':
|
exec { 'zaqar-manage db_sync':
|
||||||
path => '/usr/bin',
|
path => '/usr/bin',
|
||||||
user => 'zaqar',
|
user => 'zaqar',
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
try_sleep => 5,
|
try_sleep => 5,
|
||||||
tries => 10,
|
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,
|
$purge_config = false,
|
||||||
) inherits zaqar::params {
|
) inherits zaqar::params {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
resources { 'zaqar_config':
|
resources { 'zaqar_config':
|
||||||
purge => $purge_config,
|
purge => $purge_config,
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ class zaqar::keystone::auth(
|
|||||||
$service_description = 'Openstack messaging Service',
|
$service_description = 'Openstack messaging Service',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
validate_string($password)
|
validate_string($password)
|
||||||
|
|
||||||
keystone::resource::service_identity { 'zaqar':
|
keystone::resource::service_identity { 'zaqar':
|
||||||
|
@ -74,6 +74,8 @@ class zaqar::keystone::auth_websocket(
|
|||||||
$service_description = 'Openstack messaging websocket Service',
|
$service_description = 'Openstack messaging websocket Service',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
validate_string($password)
|
validate_string($password)
|
||||||
|
|
||||||
keystone::resource::service_identity { 'zaqar-websocket':
|
keystone::resource::service_identity { 'zaqar-websocket':
|
||||||
|
@ -223,6 +223,8 @@ class zaqar::keystone::authtoken(
|
|||||||
$token_cache_time = $::os_service_default,
|
$token_cache_time = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
if is_service_default($password) {
|
if is_service_default($password) {
|
||||||
fail('Please set password for Zaqar service user')
|
fail('Please set password for Zaqar service user')
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ class zaqar::logging(
|
|||||||
$log_date_format = $::os_service_default,
|
$log_date_format = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
oslo::log { 'zaqar_config':
|
oslo::log { 'zaqar_config':
|
||||||
logging_context_format_string => $logging_context_format_string,
|
logging_context_format_string => $logging_context_format_string,
|
||||||
logging_default_format_string => $logging_default_format_string,
|
logging_default_format_string => $logging_default_format_string,
|
||||||
|
@ -71,6 +71,8 @@ class zaqar::management::mongodb(
|
|||||||
$reconnect_sleep = $::os_service_default,
|
$reconnect_sleep = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
zaqar_config {
|
zaqar_config {
|
||||||
'drivers/management_store': value => 'mongodb';
|
'drivers/management_store': value => 'mongodb';
|
||||||
'drivers:management_store:mongodb/uri': value => $uri, secret => true;
|
'drivers:management_store:mongodb/uri': value => $uri, secret => true;
|
||||||
|
@ -78,6 +78,8 @@ class zaqar::messaging::mongodb(
|
|||||||
$partitions = $::os_service_default,
|
$partitions = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
zaqar_config {
|
zaqar_config {
|
||||||
'drivers/message_store': value => 'mongodb';
|
'drivers/message_store': value => 'mongodb';
|
||||||
'drivers:message_store:mongodb/uri': value => $uri, secret => true;
|
'drivers:message_store:mongodb/uri': value => $uri, secret => true;
|
||||||
|
@ -28,6 +28,8 @@ class zaqar::policy (
|
|||||||
$policy_path = '/etc/zaqar/policy.json',
|
$policy_path = '/etc/zaqar/policy.json',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
validate_hash($policies)
|
validate_hash($policies)
|
||||||
|
|
||||||
Openstacklib::Policy::Base {
|
Openstacklib::Policy::Base {
|
||||||
|
@ -16,6 +16,7 @@ class zaqar::server(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
include ::zaqar
|
include ::zaqar
|
||||||
|
include ::zaqar::deps
|
||||||
include ::zaqar::params
|
include ::zaqar::params
|
||||||
|
|
||||||
if $manage_service {
|
if $manage_service {
|
||||||
@ -30,8 +31,8 @@ class zaqar::server(
|
|||||||
service { $::zaqar::params::service_name:
|
service { $::zaqar::params::service_name:
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
|
tag => 'zaqar-service'
|
||||||
}
|
}
|
||||||
Zaqar_config<||> ~> Service[$::zaqar::params::service_name]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,10 @@ define zaqar::server_instance(
|
|||||||
$enabled = true,
|
$enabled = true,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar
|
||||||
|
include ::zaqar::deps
|
||||||
|
include ::zaqar::params
|
||||||
|
|
||||||
if $enabled {
|
if $enabled {
|
||||||
$service_ensure = 'running'
|
$service_ensure = 'running'
|
||||||
} else {
|
} else {
|
||||||
@ -27,17 +31,13 @@ define zaqar::server_instance(
|
|||||||
content => template('zaqar/zaqar.conf.erb'),
|
content => template('zaqar/zaqar.conf.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
include ::zaqar
|
|
||||||
include ::zaqar::params
|
|
||||||
|
|
||||||
service { "${::zaqar::params::service_name}@${name}":
|
service { "${::zaqar::params::service_name}@${name}":
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
|
tag => 'zaqar-service'
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['zaqar-common'] ~> Service["${::zaqar::params::service_name}@${name}"]
|
|
||||||
Package['zaqar-common'] ~> File["/etc/zaqar/${name}.conf"]
|
Package['zaqar-common'] ~> File["/etc/zaqar/${name}.conf"]
|
||||||
File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"]
|
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,
|
$external_port = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
zaqar_config {
|
zaqar_config {
|
||||||
'drivers:transport:websocket/bind': value => $bind;
|
'drivers:transport:websocket/bind': value => $bind;
|
||||||
'drivers:transport:websocket/port': value => $port;
|
'drivers:transport:websocket/port': value => $port;
|
||||||
|
@ -13,6 +13,8 @@ class zaqar::transport::wsgi(
|
|||||||
$port = $::os_service_default,
|
$port = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::zaqar::deps
|
||||||
|
|
||||||
zaqar_config {
|
zaqar_config {
|
||||||
'drivers:transport:wsgi/bind': value => $bind;
|
'drivers:transport:wsgi/bind': value => $bind;
|
||||||
'drivers:transport:wsgi/port': value => $port;
|
'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']
|
:tag => ['openstack', 'zaqar-package']
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
it { is_expected.to contain_class('zaqar::deps') }
|
||||||
it { is_expected.to contain_class('zaqar::params') }
|
it { is_expected.to contain_class('zaqar::params') }
|
||||||
|
|
||||||
it 'should contain default config' do
|
it 'should contain default config' do
|
||||||
|
Loading…
Reference in New Issue
Block a user