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: Idc43b06eab3f7103392da699e2a77bb55ce7344d
This commit is contained in:
parent
fda9e7d52c
commit
654cd9c862
|
@ -68,15 +68,9 @@ class gnocchi::api (
|
|||
$enable_proxy_headers_parsing = $::os_service_default,
|
||||
) inherits gnocchi::params {
|
||||
|
||||
include ::gnocchi::deps
|
||||
include ::gnocchi::policy
|
||||
|
||||
Gnocchi_config<||> ~> Service[$service_name]
|
||||
Gnocchi_api_paste_ini<||> ~> Service[$service_name]
|
||||
Class['gnocchi::policy'] ~> Service[$service_name]
|
||||
|
||||
Package['gnocchi-api'] -> Service[$service_name]
|
||||
Package['gnocchi-api'] -> Service['gnocchi-api']
|
||||
Package['gnocchi-api'] -> Class['gnocchi::policy']
|
||||
package { 'gnocchi-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::gnocchi::params::api_package_name,
|
||||
|
@ -102,7 +96,6 @@ class gnocchi::api (
|
|||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
require => Class['gnocchi::db'],
|
||||
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||
}
|
||||
} elsif $service_name == 'httpd' {
|
||||
|
@ -113,7 +106,6 @@ class gnocchi::api (
|
|||
enable => false,
|
||||
tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||
}
|
||||
Class['gnocchi::db'] -> Service[$service_name]
|
||||
Service <<| title == 'httpd' |>> { tag +> 'gnocchi-db-sync-service' }
|
||||
|
||||
# we need to make sure gnocchi-api/eventlet is stopped before trying to start apache
|
||||
|
|
|
@ -9,6 +9,7 @@ class gnocchi::client (
|
|||
$ensure = 'present'
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
include ::gnocchi::params
|
||||
|
||||
package { 'python-gnocchiclient':
|
||||
|
|
|
@ -28,6 +28,8 @@ class gnocchi::config (
|
|||
$gnocchi_api_paste_ini = {},
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
validate_hash($gnocchi_config)
|
||||
validate_hash($gnocchi_api_paste_ini)
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ class gnocchi::db (
|
|||
$ensure_package = 'present',
|
||||
) inherits gnocchi::params {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use gnocchi::<myparam> if gnocchi::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::gnocchi::database_connection, $database_connection)
|
||||
|
|
|
@ -53,6 +53,8 @@ class gnocchi::db::mysql(
|
|||
$allowed_hosts = undef
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
validate_string($password)
|
||||
|
||||
::openstacklib::db::mysql { 'gnocchi':
|
||||
|
@ -65,5 +67,8 @@ class gnocchi::db::mysql(
|
|||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Mysql['gnocchi'] ~> Exec<| title == 'gnocchi-db-sync' |>
|
||||
Anchor['gnocchi::db::begin']
|
||||
~> Class['gnocchi::db::mysql']
|
||||
~> Anchor['gnocchi::db::end']
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class gnocchi::db::postgresql(
|
|||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
Class['gnocchi::db::postgresql'] -> Service<| title == 'gnocchi' |>
|
||||
include ::gnocchi::deps
|
||||
|
||||
::openstacklib::db::postgresql { 'gnocchi':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
|
@ -42,5 +42,8 @@ class gnocchi::db::postgresql(
|
|||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['gnocchi'] ~> Exec<| title == 'gnocchi-db-sync' |>
|
||||
Anchor['gnocchi::db::begin']
|
||||
~> Class['gnocchi::db::postgresql']
|
||||
~> Anchor['gnocchi::db::end']
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ class gnocchi::db::sync (
|
|||
$user = 'gnocchi',
|
||||
$extra_opts = undef,
|
||||
){
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
exec { 'gnocchi-db-sync':
|
||||
command => "gnocchi-upgrade --config-file /etc/gnocchi/gnocchi.conf ${extra_opts}",
|
||||
path => '/usr/bin',
|
||||
|
@ -22,10 +25,12 @@ class gnocchi::db::sync (
|
|||
try_sleep => 5,
|
||||
tries => 10,
|
||||
logoutput => on_failure,
|
||||
subscribe => [
|
||||
Anchor['gnocchi::install::end'],
|
||||
Anchor['gnocchi::config::end'],
|
||||
Anchor['gnocchi::dbsync::begin']
|
||||
],
|
||||
notify => Anchor['gnocchi::dbsync::end'],
|
||||
}
|
||||
|
||||
Package<| tag == 'gnocchi-package' |> ~> Exec['gnocchi-db-sync']
|
||||
Exec['gnocchi-db-sync'] ~> Service<| tag == 'gnocchi-db-sync-service' |>
|
||||
Gnocchi_config<||> ~> Exec['gnocchi-db-sync']
|
||||
Gnocchi_config<| title == 'indexer/url' |> ~> Exec['gnocchi-db-sync']
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# == Class: gnocchi::deps
|
||||
#
|
||||
# Gnocchi anchors and dependency management
|
||||
#
|
||||
class gnocchi::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 { 'gnocchi::install::begin': }
|
||||
-> Package<| tag == 'gnocchi-package'|>
|
||||
~> anchor { 'gnocchi::install::end': }
|
||||
-> anchor { 'gnocchi::config::begin': }
|
||||
-> Gnocchi_config<||>
|
||||
~> anchor { 'gnocchi::config::end': }
|
||||
-> anchor { 'gnocchi::db::begin': }
|
||||
-> anchor { 'gnocchi::db::end': }
|
||||
~> anchor { 'gnocchi::dbsync::begin': }
|
||||
-> anchor { 'gnocchi::dbsync::end': }
|
||||
~> anchor { 'gnocchi::service::begin': }
|
||||
~> Service<| tag == 'gnocchi-service' |>
|
||||
~> anchor { 'gnocchi::service::end': }
|
||||
|
||||
# policy config should occur in the config block also.
|
||||
Anchor['gnocchi::config::begin']
|
||||
-> Openstacklib::Policy::Base<||>
|
||||
~> Anchor['gnocchi::config::end']
|
||||
|
||||
# Installation or config changes will always restart services.
|
||||
Anchor['gnocchi::install::end'] ~> Anchor['gnocchi::service::begin']
|
||||
Anchor['gnocchi::config::end'] ~> Anchor['gnocchi::service::begin']
|
||||
}
|
|
@ -50,6 +50,7 @@ class gnocchi (
|
|||
$purge_config = false,
|
||||
) inherits gnocchi::params {
|
||||
|
||||
include ::gnocchi::deps
|
||||
include ::gnocchi::db
|
||||
include ::gnocchi::logging
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ class gnocchi::keystone::auth (
|
|||
$service_description = 'OpenStack Metric Service',
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
keystone::resource::service_identity { 'gnocchi':
|
||||
configure_user => $configure_user,
|
||||
configure_user_role => $configure_user_role,
|
||||
|
|
|
@ -223,6 +223,8 @@ class gnocchi::keystone::authtoken(
|
|||
$token_cache_time = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
if is_service_default($password) {
|
||||
fail('Please set password for Gnocchi service user')
|
||||
}
|
||||
|
|
|
@ -105,6 +105,8 @@ class gnocchi::logging(
|
|||
$log_date_format = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
# note(spredzy): in order to keep backward compatibility we rely on the pick function
|
||||
# to use gnocchi::<myparam> first then gnocchi::logging::<myparam>.
|
||||
$use_syslog_real = pick($::gnocchi::use_syslog,$use_syslog)
|
||||
|
|
|
@ -25,8 +25,7 @@ class gnocchi::metricd (
|
|||
$package_ensure = 'present',
|
||||
) inherits gnocchi::params {
|
||||
|
||||
Gnocchi_config<||> ~> Service['gnocchi-metricd']
|
||||
Package['gnocchi-metricd'] -> Service['gnocchi-metricd']
|
||||
include ::gnocchi::deps
|
||||
|
||||
gnocchi_config {
|
||||
'metricd/workers': value => $workers;
|
||||
|
|
|
@ -28,6 +28,8 @@ class gnocchi::policy (
|
|||
$policy_path = '/etc/gnocchi/policy.json',
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
validate_hash($policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
|
|
|
@ -41,8 +41,7 @@ class gnocchi::statsd (
|
|||
$package_ensure = 'present',
|
||||
) inherits gnocchi::params {
|
||||
|
||||
Gnocchi_config<||> ~> Service['gnocchi-statsd']
|
||||
Package['gnocchi-statsd'] -> Service['gnocchi-statsd']
|
||||
include ::gnocchi::deps
|
||||
|
||||
package { 'gnocchi-statsd':
|
||||
ensure => $package_ensure,
|
||||
|
|
|
@ -30,6 +30,8 @@ class gnocchi::storage(
|
|||
$coordination_url = $::os_service_default,
|
||||
) inherits gnocchi::params {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
package { 'gnocchi-carbonara':
|
||||
ensure => $package_ensure,
|
||||
name => $::gnocchi::params::carbonara_package_name,
|
||||
|
|
|
@ -63,6 +63,8 @@ class gnocchi::storage::ceph(
|
|||
$manage_rados = false,
|
||||
) inherits gnocchi::params {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
if (is_service_default($ceph_keyring) and is_service_default($ceph_secret)) or (! $ceph_keyring and ! $ceph_secret) {
|
||||
fail('You need to specify either gnocchi::storage::ceph::ceph_keyring or gnocchi::storage::ceph::ceph_secret.')
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ class gnocchi::storage::file(
|
|||
$file_basepath = '/var/lib/gnocchi',
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
gnocchi_config {
|
||||
'storage/driver': value => 'file';
|
||||
'storage/file_basepath': value => $file_basepath;
|
||||
|
|
|
@ -54,6 +54,8 @@ class gnocchi::storage::influxdb(
|
|||
$influxdb_block_until_data_ingested = false,
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
gnocchi_config {
|
||||
'storage/driver': value => 'influxdb';
|
||||
'storage/influxdb_host': value => $influxdb_host;
|
||||
|
|
|
@ -49,6 +49,8 @@ class gnocchi::storage::swift(
|
|||
$swift_tenant_name = undef,
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
|
||||
gnocchi_config {
|
||||
'storage/driver': value => 'swift';
|
||||
'storage/swift_user': value => $swift_user;
|
||||
|
|
|
@ -94,6 +94,7 @@ class gnocchi::wsgi::apache (
|
|||
$priority = '10',
|
||||
) {
|
||||
|
||||
include ::gnocchi::deps
|
||||
include ::gnocchi::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.
|
|
@ -22,6 +22,7 @@ describe 'gnocchi::api' do
|
|||
|
||||
shared_examples_for 'gnocchi-api' do
|
||||
|
||||
it { is_expected.to contain_class('gnocchi::deps') }
|
||||
it { is_expected.to contain_class('gnocchi::params') }
|
||||
it { is_expected.to contain_class('gnocchi::policy') }
|
||||
|
||||
|
@ -54,10 +55,11 @@ describe 'gnocchi::api' do
|
|||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:require => 'Class[Gnocchi::Db]',
|
||||
:tag => ['gnocchi-service', 'gnocchi-db-sync-service'],
|
||||
)
|
||||
end
|
||||
it { is_expected.to contain_service('gnocchi-api').that_subscribes_to('Anchor[gnocchi::service::begin]')}
|
||||
it { is_expected.to contain_service('gnocchi-api').that_notifies('Anchor[gnocchi::service::end]')}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'gnocchi::client' do
|
|||
|
||||
shared_examples_for 'gnocchi client' do
|
||||
|
||||
it { is_expected.to contain_class('gnocchi::deps') }
|
||||
it { is_expected.to contain_class('gnocchi::params') }
|
||||
|
||||
it 'installs gnocchi client package' do
|
||||
|
|
|
@ -12,7 +12,11 @@ describe 'gnocchi::db::sync' do
|
|||
:refreshonly => 'true',
|
||||
:try_sleep => 5,
|
||||
:tries => 10,
|
||||
:logoutput => 'on_failure'
|
||||
:logoutput => 'on_failure',
|
||||
:subscribe => ['Anchor[gnocchi::install::end]',
|
||||
'Anchor[gnocchi::config::end]',
|
||||
'Anchor[gnocchi::dbsync::begin]'],
|
||||
:notify => 'Anchor[gnocchi::dbsync::end]',
|
||||
)
|
||||
end
|
||||
describe "overriding extra_opts" do
|
||||
|
@ -28,7 +32,11 @@ describe 'gnocchi::db::sync' do
|
|||
:refreshonly => 'true',
|
||||
:try_sleep => 5,
|
||||
:tries => 10,
|
||||
:logoutput => 'on_failure'
|
||||
:logoutput => 'on_failure',
|
||||
:subscribe => ['Anchor[gnocchi::install::end]',
|
||||
'Anchor[gnocchi::config::end]',
|
||||
'Anchor[gnocchi::dbsync::begin]'],
|
||||
:notify => 'Anchor[gnocchi::dbsync::end]',
|
||||
)
|
||||
}
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ describe 'gnocchi' do
|
|||
end
|
||||
|
||||
it 'contains the logging class' do
|
||||
is_expected.to contain_class('gnocchi::deps')
|
||||
is_expected.to contain_class('gnocchi::logging')
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ describe 'gnocchi::metricd' do
|
|||
|
||||
shared_examples_for 'gnocchi-metricd' do
|
||||
|
||||
it { is_expected.to contain_class('gnocchi::deps') }
|
||||
it { is_expected.to contain_class('gnocchi::params') }
|
||||
|
||||
it 'installs gnocchi-metricd package' do
|
||||
|
|
|
@ -15,6 +15,7 @@ describe 'gnocchi::statsd' do
|
|||
|
||||
shared_examples_for 'gnocchi-statsd' do
|
||||
|
||||
it { is_expected.to contain_class('gnocchi::deps') }
|
||||
it { is_expected.to contain_class('gnocchi::params') }
|
||||
|
||||
it 'installs gnocchi-statsd package' do
|
||||
|
|
|
@ -8,6 +8,7 @@ describe 'gnocchi::storage' do
|
|||
|
||||
shared_examples_for 'gnocchi-storage' do
|
||||
|
||||
it { is_expected.to contain_class('gnocchi::deps') }
|
||||
it { is_expected.to contain_class('gnocchi::params') }
|
||||
|
||||
it 'installs gnocchi-carbonara package' do
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'gnocchi::wsgi::apache' do
|
|||
|
||||
shared_examples_for 'apache serving gnocchi with mod_wsgi' do
|
||||
it { is_expected.to contain_service('httpd').with_name(platform_params[:httpd_service_name]) }
|
||||
it { is_expected.to contain_class('gnocchi::deps') }
|
||||
it { is_expected.to contain_class('gnocchi::params') }
|
||||
it { is_expected.to contain_class('apache') }
|
||||
it { is_expected.to contain_class('apache::mod::wsgi') }
|
||||
|
|
Loading…
Reference in New Issue