Mistral external dependency management
Move all dependency tracking to an external class which simplifies the relationships and allows managing Mistral without necessarily using packages. Change-Id: If83638c6cdabc4256cd775d7a0187a5668e4d2c9
This commit is contained in:
parent
972b2d319d
commit
a617112364
@ -62,15 +62,10 @@ class mistral::api (
|
||||
$enable_proxy_headers_parsing = $::os_service_default,
|
||||
) inherits mistral::params {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
include ::mistral::policy
|
||||
|
||||
Mistral_config<||> ~> Service[$service_name]
|
||||
Class['mistral::policy'] ~> Service[$service_name]
|
||||
Package['mistral-api'] -> Class['mistral::policy']
|
||||
Package['mistral-api'] -> Service[$service_name]
|
||||
Package['mistral-api'] -> Service['mistral-api']
|
||||
|
||||
package { 'mistral-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::mistral::params::api_package_name,
|
||||
@ -102,7 +97,6 @@ class mistral::api (
|
||||
enable => false,
|
||||
tag => 'mistral-service',
|
||||
}
|
||||
Class['mistral::db'] -> Service[$service_name]
|
||||
Service <<| title == 'httpd' |>> { tag +> 'mistral-service' }
|
||||
|
||||
# we need to make sure mistral-api s stopped before trying to start apache
|
||||
|
@ -11,6 +11,7 @@ class mistral::client(
|
||||
$package_ensure = 'present'
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
|
||||
package { 'python-mistralclient':
|
||||
|
@ -24,6 +24,8 @@ class mistral::config (
|
||||
$mistral_config = {},
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
validate_hash($mistral_config)
|
||||
|
||||
create_resources('mistral_config', $mistral_config)
|
||||
|
@ -45,6 +45,8 @@ class mistral::cors (
|
||||
$allow_headers = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
oslo::cors { 'mistral_config':
|
||||
allowed_origin => $allowed_origin,
|
||||
allow_credentials => $allow_credentials,
|
||||
|
@ -49,6 +49,8 @@ class mistral::db (
|
||||
$database_db_max_retries = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use mistral::<myparam> if mistral::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::mistral::database_connection,$database_connection)
|
||||
|
@ -58,6 +58,8 @@ class mistral::db::mysql(
|
||||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'mistral':
|
||||
@ -70,6 +72,7 @@ class mistral::db::mysql(
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['mistral'] ~> Exec<| title == 'mistral-db-sync' |>
|
||||
|
||||
Anchor['mistral::db::begin']
|
||||
~> Class['mistral::db::mysql']
|
||||
~> Anchor['mistral::db::end']
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class mistral::db::postgresql(
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['mistral::db::postgresql'] -> Service<| title == 'mistral' |>
|
||||
include ::mistral::deps
|
||||
|
||||
::openstacklib::db::postgresql { 'mistral':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
@ -50,6 +50,7 @@ class mistral::db::postgresql(
|
||||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['mistral'] ~> Exec<| title == 'mistral-db-sync' |>
|
||||
|
||||
Anchor['mistral::db::begin']
|
||||
~> Class['mistral::db::postgresql']
|
||||
~> Anchor['mistral::db::end']
|
||||
}
|
||||
|
@ -3,13 +3,9 @@
|
||||
#
|
||||
class mistral::db::sync {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
|
||||
Package<| tag =='mistral-common' |> ~> Exec['mistral-db-sync']
|
||||
Exec['mistral-db-sync'] ~> Service<| tag == 'mistral-service' |>
|
||||
Mistral_config <||> -> Exec['mistral-db-sync']
|
||||
Mistral_config <| title == 'database/connection' |> ~> Exec['mistral-db-sync']
|
||||
|
||||
exec { 'mistral-db-sync':
|
||||
command => $::mistral::params::db_sync_command,
|
||||
path => '/usr/bin',
|
||||
@ -18,19 +14,25 @@ class mistral::db::sync {
|
||||
refreshonly => true,
|
||||
try_sleep => 5,
|
||||
tries => 10,
|
||||
}
|
||||
|
||||
Exec['mistral-db-sync'] -> Exec['mistral-db-populate']
|
||||
Package<| tag =='mistral-common' |> ~> Exec['mistral-db-populate']
|
||||
Exec['mistral-db-populate'] ~> Service<| tag == 'mistral-service' |>
|
||||
Mistral_config <||> -> Exec['mistral-db-populate']
|
||||
Mistral_config <| title == 'database/connection' |> ~> Exec['mistral-db-populate']
|
||||
subscribe => [
|
||||
Anchor['mistral::install::end'],
|
||||
Anchor['mistral::config::end'],
|
||||
Anchor['mistral::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['mistral::dbsync::end'],
|
||||
} ->
|
||||
exec { 'mistral-db-populate':
|
||||
command => $::mistral::params::db_populate_command,
|
||||
path => '/usr/bin',
|
||||
user => 'mistral',
|
||||
logoutput => on_failure,
|
||||
refreshonly => true,
|
||||
subscribe => [
|
||||
Anchor['mistral::install::end'],
|
||||
Anchor['mistral::config::end'],
|
||||
Anchor['mistral::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['mistral::dbsync::end'],
|
||||
}
|
||||
|
||||
}
|
||||
|
35
manifests/deps.pp
Normal file
35
manifests/deps.pp
Normal file
@ -0,0 +1,35 @@
|
||||
# == Class: mistral::deps
|
||||
#
|
||||
# mistral anchors and dependency management
|
||||
#
|
||||
class mistral::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 { 'mistral::install::begin': }
|
||||
-> Package<| tag == 'mistral-package'|>
|
||||
~> anchor { 'mistral::install::end': }
|
||||
-> anchor { 'mistral::config::begin': }
|
||||
-> Mistral_config<||>
|
||||
~> anchor { 'mistral::config::end': }
|
||||
-> anchor { 'mistral::db::begin': }
|
||||
-> anchor { 'mistral::db::end': }
|
||||
~> anchor { 'mistral::dbsync::begin': }
|
||||
-> anchor { 'mistral::dbsync::end': }
|
||||
~> anchor { 'mistral::service::begin': }
|
||||
~> Service<| tag == 'mistral-service' |>
|
||||
~> anchor { 'mistral::service::end': }
|
||||
|
||||
# policy config should occur in the config block
|
||||
Anchor['mistral::config::begin']
|
||||
-> Openstacklib::Policy::Base<||>
|
||||
~> Anchor['mistral::config::end']
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['mistral::install::end'] ~> Anchor['mistral::service::begin']
|
||||
Anchor['mistral::config::end'] ~> Anchor['mistral::service::begin']
|
||||
}
|
@ -59,6 +59,7 @@ class mistral::engine (
|
||||
$older_than = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
|
||||
package { 'mistral-engine':
|
||||
|
@ -49,6 +49,7 @@ class mistral::executor (
|
||||
$older_than = false,
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
|
||||
if $evaluation_interval {
|
||||
|
@ -242,8 +242,9 @@ class mistral(
|
||||
$rabbit_password = $::os_service_default,
|
||||
$rabbit_virtual_host = $::os_service_default,
|
||||
){
|
||||
include ::mistral::params
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
include ::mistral::db
|
||||
include ::mistral::logging
|
||||
|
||||
|
@ -74,6 +74,8 @@ class mistral::keystone::auth(
|
||||
$service_description = 'OpenStack Workflow Service',
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
keystone::resource::service_identity { 'mistral':
|
||||
|
@ -105,6 +105,8 @@ class mistral::logging(
|
||||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use mistral::<myparam> if mistral::logging::<myparam> isn't specified.
|
||||
$use_syslog_real = pick($::mistral::use_syslog,$use_syslog)
|
||||
|
@ -28,6 +28,8 @@ class mistral::policy (
|
||||
$policy_path = '/etc/mistral/policy.json',
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
|
@ -94,6 +94,7 @@ class mistral::wsgi::apache (
|
||||
$priority = '10',
|
||||
) {
|
||||
|
||||
include ::mistral::deps
|
||||
include ::mistral::params
|
||||
include ::apache
|
||||
include ::apache::mod::wsgi
|
||||
@ -101,6 +102,26 @@ class mistral::wsgi::apache (
|
||||
include ::apache::mod::ssl
|
||||
}
|
||||
|
||||
# The httpd package is untagged, but needs to have ordering enforced,
|
||||
# so handle it here rather than in the deps class.
|
||||
Anchor['mistral::install::begin']
|
||||
-> Package['httpd']
|
||||
-> Anchor['mistral::install::end']
|
||||
|
||||
# Configure apache during the config phase
|
||||
Anchor['mistral::config::begin']
|
||||
-> Apache::Vhost<||>
|
||||
~> Anchor['mistral::config::end']
|
||||
|
||||
# Start the service during the service phase
|
||||
Anchor['mistral::service::begin']
|
||||
-> Service['httpd']
|
||||
-> Anchor['mistral::service::end']
|
||||
|
||||
# Notify the service when config changes
|
||||
Anchor['mistral::config::end']
|
||||
~> Service['httpd']
|
||||
|
||||
::openstacklib::wsgi::apache { 'mistral_wsgi':
|
||||
bind_host => $bind_host,
|
||||
bind_port => $port,
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Dependencies are now managed in an external class.
|
||||
This allows installing Mistral via other methods besides
|
||||
packages.
|
17
spec/classes/mistral_deps_spec.rb
Normal file
17
spec/classes/mistral_deps_spec.rb
Normal file
@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'mistral::deps' do
|
||||
|
||||
it 'set up the anchors' do
|
||||
is_expected.to contain_anchor('mistral::install::begin')
|
||||
is_expected.to contain_anchor('mistral::install::end')
|
||||
is_expected.to contain_anchor('mistral::config::begin')
|
||||
is_expected.to contain_anchor('mistral::config::end')
|
||||
is_expected.to contain_anchor('mistral::db::begin')
|
||||
is_expected.to contain_anchor('mistral::db::end')
|
||||
is_expected.to contain_anchor('mistral::dbsync::begin')
|
||||
is_expected.to contain_anchor('mistral::dbsync::end')
|
||||
is_expected.to contain_anchor('mistral::service::begin')
|
||||
is_expected.to contain_anchor('mistral::service::end')
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user