Browse Source

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: I0d18ec6ffe6b54c85773a6dabb0ed7b6f59a12f4
changes/64/403964/5
ZhongShengping 6 years ago
parent
commit
fc4a0fd510
  1. 2
      manifests/agent/auth.pp
  2. 5
      manifests/agent/central.pp
  3. 15
      manifests/agent/notification.pp
  4. 5
      manifests/agent/polling.pp
  5. 10
      manifests/api.pp
  6. 1
      manifests/client.pp
  7. 14
      manifests/collector.pp
  8. 2
      manifests/config.pp
  9. 2
      manifests/db.pp
  10. 6
      manifests/db/mysql.pp
  11. 7
      manifests/db/postgresql.pp
  12. 13
      manifests/db/sync.pp
  13. 40
      manifests/deps.pp
  14. 2
      manifests/dispatcher/gnocchi.pp
  15. 3
      manifests/expirer.pp
  16. 5
      manifests/init.pp
  17. 2
      manifests/keystone/auth.pp
  18. 2
      manifests/keystone/authtoken.pp
  19. 2
      manifests/logging.pp
  20. 2
      manifests/policy.pp
  21. 1
      manifests/wsgi/apache.pp
  22. 10
      releasenotes/notes/external_install_mgmt_hook-676123a45de9237f.yaml
  23. 8
      spec/classes/ceilometer_agent_central_spec.rb
  24. 1
      spec/classes/ceilometer_agent_compute_spec.rb
  25. 3
      spec/classes/ceilometer_agent_notification_spec.rb
  26. 8
      spec/classes/ceilometer_agent_polling_spec.rb
  27. 4
      spec/classes/ceilometer_api_spec.rb
  28. 1
      spec/classes/ceilometer_client_spec.rb
  29. 6
      spec/classes/ceilometer_db_sync_spec.rb
  30. 1
      spec/classes/ceilometer_expirer_spec.rb
  31. 4
      spec/classes/ceilometer_init_spec.rb

2
manifests/agent/auth.pp

@ -63,6 +63,8 @@ class ceilometer::agent::auth (
$auth_type = 'password',
) {
include ::ceilometer::deps
if ! $auth_cacert {
ceilometer_config { 'service_credentials/ca_file': ensure => absent }
} else {

5
manifests/agent/central.pp

@ -28,11 +28,9 @@ class ceilometer::agent::central (
$coordination_url = undef,
) {
include ::ceilometer::deps
include ::ceilometer::params
Ceilometer_config<||> ~> Service['ceilometer-agent-central']
Package['ceilometer-agent-central'] -> Service['ceilometer-agent-central']
package { 'ceilometer-agent-central':
ensure => $package_ensure,
name => $::ceilometer::params::agent_central_package_name,
@ -47,7 +45,6 @@ class ceilometer::agent::central (
}
}
Package['ceilometer-common'] -> Service['ceilometer-agent-central']
service { 'ceilometer-agent-central':
ensure => $service_ensure,
name => $::ceilometer::params::agent_central_service_name,

15
manifests/agent/notification.pp

@ -80,17 +80,13 @@ class ceilometer::agent::notification (
$event_pipeline_publishers = ['notifier://'],
) {
include ::ceilometer::deps
include ::ceilometer::params
Ceilometer_config<||> ~> Service['ceilometer-agent-notification']
Package[$::ceilometer::params::agent_notification_package_name] ->
Service['ceilometer-agent-notification']
ensure_resource('package', [$::ceilometer::params::agent_notification_package_name],
{
ensure => $package_ensure,
tag => 'openstack'
tag => ['openstack', 'ceilometer-package']
}
)
@ -102,7 +98,6 @@ class ceilometer::agent::notification (
}
}
Package['ceilometer-common'] -> Service['ceilometer-agent-notification']
service { 'ceilometer-agent-notification':
ensure => $service_ensure,
name => $::ceilometer::params::agent_notification_service_name,
@ -119,11 +114,9 @@ class ceilometer::agent::notification (
ensure => present,
path => $::ceilometer::params::event_pipeline,
content => template('ceilometer/event_pipeline.yaml.erb'),
selinux_ignore_defaults => true
selinux_ignore_defaults => true,
tag => 'event-pipeline',
}
Package<| tag == 'ceilometer-package' |> -> File['event_pipeline']
File['event_pipeline'] ~> Service['ceilometer-agent-notification']
}
ceilometer_config {

5
manifests/agent/polling.pp

@ -42,6 +42,7 @@ class ceilometer::agent::polling (
$coordination_url = undef,
) inherits ceilometer {
include ::ceilometer::deps
include ::ceilometer::params
if $central_namespace {
@ -93,10 +94,6 @@ class ceilometer::agent::polling (
}
}
Ceilometer_config<||> ~> Service['ceilometer-polling']
Package['ceilometer-polling'] -> Service['ceilometer-polling']
Package['ceilometer-common'] -> Service['ceilometer-polling']
service { 'ceilometer-polling':
ensure => $service_ensure,
name => $::ceilometer::params::agent_polling_service_name,

10
manifests/api.pp

@ -58,6 +58,7 @@ class ceilometer::api (
$enable_proxy_headers_parsing = $::os_service_default,
) inherits ceilometer::params {
include ::ceilometer::deps
include ::ceilometer::params
include ::ceilometer::policy
@ -65,11 +66,6 @@ class ceilometer::api (
include ::ceilometer::keystone::authtoken
}
Ceilometer_config<||> ~> Service[$service_name]
Class['ceilometer::policy'] ~> Service[$service_name]
Package['ceilometer-api'] -> Service[$service_name]
Package['ceilometer-api'] -> Class['ceilometer::policy']
package { 'ceilometer-api':
ensure => $package_ensure,
name => $::ceilometer::params::api_package_name,
@ -84,8 +80,6 @@ class ceilometer::api (
}
}
Package['ceilometer-common'] -> Service[$service_name]
if $service_name == $::ceilometer::params::api_service_name {
service { 'ceilometer-api':
ensure => $service_ensure,
@ -93,7 +87,6 @@ class ceilometer::api (
enable => $enabled,
hasstatus => true,
hasrestart => true,
require => Class['ceilometer::db'],
tag => 'ceilometer-service',
}
} elsif $service_name == 'httpd' {
@ -104,7 +97,6 @@ class ceilometer::api (
enable => false,
tag => 'ceilometer-service',
}
Class['ceilometer::db'] -> Service[$service_name]
# we need to make sure ceilometer-api/eventlet is stopped before trying to start apache
Service['ceilometer-api'] -> Service[$service_name]

1
manifests/client.pp

@ -12,6 +12,7 @@ class ceilometer::client (
$ensure = 'present'
) {
include ::ceilometer::deps
include ::ceilometer::params
package { 'python-ceilometerclient':

14
manifests/collector.pp

@ -50,10 +50,9 @@ class ceilometer::collector (
$event_dispatcher = 'database',
) {
include ::ceilometer::deps
include ::ceilometer::params
Ceilometer_config<||> ~> Service['ceilometer-collector']
# We accept udp_address to be set to empty instead of the usual undef to stay
# close to the "strange" upstream interface.
if (is_ip_address($udp_address) != true and $udp_address != '' ){
@ -64,13 +63,15 @@ class ceilometer::collector (
'collector/udp_address': value => $udp_address;
'collector/udp_port': value => $udp_port;
'collector/workers': value => $collector_workers;
'DEFAULT/meter_dispatchers': value => join(any2array($meter_dispatcher), ',');
'DEFAULT/event_dispatchers': value => join(any2array($event_dispatcher), ',');
'DEFAULT/meter_dispatchers': value => join(any2array($meter_dispatcher), ',');
'DEFAULT/event_dispatchers': value => join(any2array($event_dispatcher), ',');
}
Package[$::ceilometer::params::collector_package_name] -> Service['ceilometer-collector']
ensure_resource( 'package', [$::ceilometer::params::collector_package_name],
{ ensure => $package_ensure }
{
ensure => $package_ensure,
tag => ['openstack', 'ceilometer-package']
}
)
if $manage_service {
@ -81,7 +82,6 @@ class ceilometer::collector (
}
}
Package['ceilometer-common'] -> Service['ceilometer-collector']
service { 'ceilometer-collector':
ensure => $service_ensure,
name => $::ceilometer::params::collector_service_name,

2
manifests/config.pp

@ -30,6 +30,8 @@ class ceilometer::config (
$ceilometer_api_paste_ini = {},
) {
include ::ceilometer::deps
validate_hash($ceilometer_config)
validate_hash($ceilometer_api_paste_ini)

2
manifests/db.pp

@ -56,7 +56,7 @@ class ceilometer::db (
$sync_db = true,
) {
Package<| title == 'ceilometer-common' |> -> Class['ceilometer::db']
include ::ceilometer::deps
oslo::db { 'ceilometer_config':
db_max_retries => $database_db_max_retries,

6
manifests/db/mysql.pp

@ -42,6 +42,8 @@ class ceilometer::db::mysql(
$collate = 'utf8_general_ci',
) {
include ::ceilometer::deps
validate_string($password)
::openstacklib::db::mysql { 'ceilometer':
@ -54,5 +56,7 @@ class ceilometer::db::mysql(
allowed_hosts => $allowed_hosts,
}
::Openstacklib::Db::Mysql['ceilometer'] ~> Exec<| title == 'ceilometer-dbsync' |>
Anchor['ceilometer::db::begin']
~> Class['ceilometer::db::mysql']
~> Anchor['ceilometer::db::end']
}

7
manifests/db/postgresql.pp

@ -32,6 +32,8 @@ class ceilometer::db::postgresql(
$privileges = 'ALL',
) {
include ::ceilometer::deps
::openstacklib::db::postgresql { 'ceilometer':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
@ -40,6 +42,7 @@ class ceilometer::db::postgresql(
privileges => $privileges,
}
::Openstacklib::Db::Postgresql['ceilometer'] ~> Exec<| title == 'ceilometer-dbsync' |>
Anchor['ceilometer::db::begin']
~> Class['ceilometer::db::postgresql']
~> Anchor['ceilometer::db::end']
}

13
manifests/db/sync.pp

@ -13,14 +13,9 @@ class ceilometer::db::sync(
$extra_params = undef,
) {
include ::ceilometer::deps
include ::ceilometer::params
Package<| tag == 'ceilometer-package' |> ~> Exec['ceilometer-dbsync']
Exec['ceilometer-dbsync'] ~> Service <| tag == 'ceilometer-service' |>
Ceilometer_config<||> -> Exec['ceilometer-dbsync']
Ceilometer_config<| title == 'database/connection' |> ~> Exec['ceilometer-dbsync']
exec { 'ceilometer-dbsync':
command => "${::ceilometer::params::dbsync_command} ${extra_params}",
path => '/usr/bin',
@ -29,6 +24,12 @@ class ceilometer::db::sync(
try_sleep => 5,
tries => 10,
logoutput => on_failure,
subscribe => [
Anchor['ceilometer::install::end'],
Anchor['ceilometer::config::end'],
Anchor['ceilometer::dbsync::begin']
],
notify => Anchor['ceilometer::dbsync::end'],
}
}

40
manifests/deps.pp

@ -0,0 +1,40 @@
# == Class: ceilometer::deps
#
# Ceilometer anchors and dependency management
#
class ceilometer::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 { 'ceilometer::install::begin': }
-> Package<| tag == 'ceilometer-package'|>
~> anchor { 'ceilometer::install::end': }
-> anchor { 'ceilometer::config::begin': }
-> Ceilometer_config<||>
~> anchor { 'ceilometer::config::end': }
-> anchor { 'ceilometer::db::begin': }
-> anchor { 'ceilometer::db::end': }
~> anchor { 'ceilometer::dbsync::begin': }
-> anchor { 'ceilometer::dbsync::end': }
~> anchor { 'ceilometer::service::begin': }
~> Service<| tag == 'ceilometer-service' |>
~> anchor { 'ceilometer::service::end': }
# policy config should occur in the config block also.
Anchor['ceilometer::config::begin']
-> Openstacklib::Policy::Base<||>
~> Anchor['ceilometer::config::end']
# Ensure files are modified in the config block
Anchor['ceilometer::config::begin']
-> File<| tag == 'event-pipeline' |>
~> Anchor['ceilometer::config::end']
# Installation or config changes will always restart services.
Anchor['ceilometer::install::end'] ~> Anchor['ceilometer::service::begin']
Anchor['ceilometer::config::end'] ~> Anchor['ceilometer::service::begin']
}

2
manifests/dispatcher/gnocchi.pp

@ -34,6 +34,8 @@ class ceilometer::dispatcher::gnocchi (
$resources_definition_file = $::os_service_default,
) {
include ::ceilometer::deps
ceilometer_config {
'dispatcher_gnocchi/filter_service_activity': value => $filter_service_activity;
'dispatcher_gnocchi/filter_project': value => $filter_project;

3
manifests/expirer.pp

@ -40,7 +40,6 @@
# [*weekday*]
# (optional) Defaults to '*'.
#
class ceilometer::expirer (
$enable_cron = true,
$minute = 1,
@ -52,7 +51,7 @@ class ceilometer::expirer (
include ::ceilometer::params
Package<| title == 'ceilometer-common' |> -> Class['ceilometer::expirer']
Anchor['ceilometer::install::end'] ~> Class['ceilometer::expirer']
if $enable_cron {
cron { 'ceilometer-expirer':

5
manifests/init.pp

@ -285,6 +285,7 @@ class ceilometer(
$rabbit_virtual_host = $::os_service_default,
) {
include ::ceilometer::deps
include ::ceilometer::logging
include ::ceilometer::params
@ -319,14 +320,14 @@ deprecated. Please use ceilometer::default_transport_url instead.")
group { 'ceilometer':
name => 'ceilometer',
require => Package['ceilometer-common'],
require => Anchor['ceilometer::install::end'],
}
user { 'ceilometer':
name => 'ceilometer',
gid => 'ceilometer',
system => true,
require => Package['ceilometer-common'],
require => Anchor['ceilometer::install::end'],
}
package { 'ceilometer-common':

2
manifests/keystone/auth.pp

@ -87,6 +87,8 @@ class ceilometer::keystone::auth (
$internal_url = 'http://127.0.0.1:8777',
) {
include ::ceilometer::deps
validate_string($password)
::keystone::resource::service_identity { 'ceilometer':

2
manifests/keystone/authtoken.pp

@ -223,6 +223,8 @@ class ceilometer::keystone::authtoken(
$token_cache_time = $::os_service_default,
) {
include ::ceilometer::deps
if is_service_default($password) {
fail('Please set password for ceilometer service user')
}

2
manifests/logging.pp

@ -104,6 +104,8 @@ class ceilometer::logging(
$log_date_format = $::os_service_default,
) {
include ::ceilometer::deps
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use ceilometer::<myparam> first then ceilometer::logging::<myparam>.
$use_syslog_real = pick($::ceilometer::use_syslog,$use_syslog)

2
manifests/policy.pp

@ -21,6 +21,8 @@ class ceilometer::policy (
$policy_path = '/etc/ceilometer/policy.json',
) {
include ::ceilometer::deps
validate_hash($policies)
Openstacklib::Policy::Base {

1
manifests/wsgi/apache.pp

@ -96,6 +96,7 @@ class ceilometer::wsgi::apache (
$priority = '10',
) {
include ::ceilometer::deps
include ::ceilometer::params
include ::apache
include ::apache::mod::wsgi

10
releasenotes/notes/external_install_mgmt_hook-676123a45de9237f.yaml

@ -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.

8
spec/classes/ceilometer_agent_central_spec.rb

@ -16,23 +16,17 @@ describe 'ceilometer::agent::central' do
shared_examples_for 'ceilometer-agent-central' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-agent-central package' do
is_expected.to contain_package('ceilometer-agent-central').with(
:ensure => 'latest',
:name => platform_params[:agent_package_name],
:before => ['Service[ceilometer-agent-central]'],
:tag => ['openstack', 'ceilometer-package'],
)
end
it 'ensures ceilometer-common is installed before the service' do
is_expected.to contain_package('ceilometer-common').with(
:before => /Service\[ceilometer-agent-central\]/
)
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
before do

1
spec/classes/ceilometer_agent_compute_spec.rb

@ -16,6 +16,7 @@ describe 'ceilometer::agent::compute' do
shared_examples_for 'ceilometer-agent-compute' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer-agent-compute package' do

3
spec/classes/ceilometer_agent_notification_spec.rb

@ -35,12 +35,13 @@ describe 'ceilometer::agent::notification' do
shared_examples_for 'ceilometer-agent-notification' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer agent notification package' do
is_expected.to contain_package(platform_params[:agent_notification_package_name]).with(
:ensure => 'present',
:tag => 'openstack'
:tag => ['openstack', 'ceilometer-package'],
)
end

8
spec/classes/ceilometer_agent_polling_spec.rb

@ -21,6 +21,7 @@ describe 'ceilometer::agent::polling' do
shared_examples_for 'ceilometer-polling' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
context 'when compute_namespace => true' do
@ -43,7 +44,6 @@ describe 'ceilometer::agent::polling' do
is_expected.to contain_package('ceilometer-polling').with(
:ensure => 'latest',
:name => platform_params[:agent_package_name],
:before => ['Service[ceilometer-polling]'],
:tag => ['openstack', 'ceilometer-package'],
)
end
@ -52,12 +52,6 @@ describe 'ceilometer::agent::polling' do
is_expected.to contain_ceilometer_config('DEFAULT/polling_namespaces').with_value('central,compute,ipmi')
end
it 'ensures ceilometer-common is installed before the service' do
is_expected.to contain_package('ceilometer-common').with(
:before => /Service\[ceilometer-polling\]/
)
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
before do

4
spec/classes/ceilometer_api_spec.rb

@ -21,6 +21,7 @@ describe 'ceilometer::api' do
shared_examples_for 'ceilometer-api' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
it { is_expected.to contain_class('ceilometer::policy') }
it { is_expected.to contain_class('ceilometer::keystone::authtoken') }
@ -53,10 +54,11 @@ describe 'ceilometer::api' do
:enable => params[:enabled],
:hasstatus => true,
:hasrestart => true,
:require => 'Class[Ceilometer::Db]',
:tag => 'ceilometer-service',
)
end
it { is_expected.to contain_service('ceilometer-api').that_subscribes_to('Anchor[ceilometer::service::begin]')}
it { is_expected.to contain_service('ceilometer-api').that_notifies('Anchor[ceilometer::service::end]')}
end
end

1
spec/classes/ceilometer_client_spec.rb

@ -4,6 +4,7 @@ describe 'ceilometer::client' do
shared_examples_for 'ceilometer client' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer client package' do

6
spec/classes/ceilometer_db_sync_spec.rb

@ -10,7 +10,11 @@ describe 'ceilometer::db::sync' do
:path => '/usr/bin',
:refreshonly => 'true',
:user => 'ceilometer',
:logoutput => 'on_failure'
:logoutput => 'on_failure',
:subscribe => ['Anchor[ceilometer::install::end]',
'Anchor[ceilometer::config::end]',
'Anchor[ceilometer::dbsync::begin]'],
:notify => 'Anchor[ceilometer::dbsync::end]',
)
end

1
spec/classes/ceilometer_expirer_spec.rb

@ -32,6 +32,7 @@ describe 'ceilometer::expirer' do
shared_examples_for 'ceilometer-expirer' do
it { is_expected.to contain_class('ceilometer::deps') }
it { is_expected.to contain_class('ceilometer::params') }
it 'installs ceilometer common package' do

4
spec/classes/ceilometer_init_spec.rb

@ -85,7 +85,7 @@ describe 'ceilometer' do
it 'configures ceilometer group' do
is_expected.to contain_group('ceilometer').with(
:name => 'ceilometer',
:require => 'Package[ceilometer-common]'
:require => 'Anchor[ceilometer::install::end]'
)
end
@ -94,7 +94,7 @@ describe 'ceilometer' do
:name => 'ceilometer',
:gid => 'ceilometer',
:system => true,
:require => 'Package[ceilometer-common]'
:require => 'Anchor[ceilometer::install::end]'
)
end

Loading…
Cancel
Save