Update AODH for using puppet-oslo

This commit switches using of oslo options to a puppet-oslo module:
* oslo messaging notifications;
* oslo messaging rabbitmq;
* oslo log;
* oslo db;

Change-Id: I6a989915df2529febaf980ddedc11f699d49147e
This commit is contained in:
Denis Egorenko 2016-03-29 15:28:08 +03:00
parent 4cc0e6498f
commit 4b22b9b289
6 changed files with 81 additions and 216 deletions

View File

@ -43,8 +43,6 @@ class aodh::db (
$database_max_overflow = 20,
) {
include ::aodh::params
$database_connection_real = pick($::aodh::database_connection, $database_connection)
$database_idle_timeout_real = pick($::aodh::database_idle_timeout, $database_idle_timeout)
$database_min_pool_size_real = pick($::aodh::database_min_pool_size, $database_min_pool_size)
@ -53,52 +51,13 @@ class aodh::db (
$database_retry_interval_real = pick($::aodh::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::aodh::database_max_overflow, $database_max_overflow)
validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql|mongodb):\/\/(\S+:\S+@\S+\/\S+)?')
if $database_connection_real {
case $database_connection_real {
/^mysql(\+pymysql)?:\/\//: {
require 'mysql::bindings'
require 'mysql::bindings::python'
if $database_connection_real =~ /^mysql\+pymysql/ {
$backend_package = $::aodh::params::pymysql_package_name
} else {
$backend_package = false
}
}
/^postgresql:\/\//: {
$backend_package = false
require 'postgresql::lib::python'
}
/^mongodb:\/\//: {
$backend_package = $::aodh::params::pymongo_package_name
}
/^sqlite:\/\//: {
$backend_package = $::aodh::params::sqlite_package_name
}
default: {
fail('Unsupported backend configured')
}
}
if $backend_package and !defined(Package[$backend_package]) {
package {'aodh-backend-package':
ensure => present,
name => $backend_package,
tag => 'openstack',
}
}
aodh_config {
'database/connection': value => $database_connection_real, secret => true;
'database/idle_timeout': value => $database_idle_timeout_real;
'database/min_pool_size': value => $database_min_pool_size_real;
'database/max_retries': value => $database_max_retries_real;
'database/retry_interval': value => $database_retry_interval_real;
'database/max_pool_size': value => $database_max_pool_size_real;
'database/max_overflow': value => $database_max_overflow_real;
}
oslo::db { 'aodh_config':
connection => $database_connection_real,
idle_timeout => $database_idle_timeout_real,
min_pool_size => $database_min_pool_size_real,
max_pool_size => $database_max_pool_size_real,
max_retries => $database_max_retries_real,
retry_interval => $database_retry_interval_real,
max_overflow => $database_max_overflow_real,
}
}

View File

@ -69,21 +69,21 @@
#
# [*kombu_ssl_ca_certs*]
# (optional) SSL certification authority file (valid only if SSL enabled).
# Defaults to undef
# Defaults to $::os_service_default
#
# [*kombu_ssl_certfile*]
# (optional) SSL cert file (valid only if SSL enabled).
# Defaults to undef
# Defaults to $::os_service_default
#
# [*kombu_ssl_keyfile*]
# (optional) SSL key file (valid only if SSL enabled).
# Defaults to undef
# Defaults to $::os_service_default
#
# [*kombu_ssl_version*]
# (optional) SSL version to use (valid only if SSL enabled).
# Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be
# available on some distributions.
# Defaults to 'TLSv1'
# Defaults to $::os_service_default
#
# [*kombu_reconnect_delay*]
# (optional) How long to wait before reconnecting in response to an AMQP
@ -222,10 +222,10 @@ class aodh (
$rabbit_heartbeat_timeout_threshold = 0,
$rabbit_heartbeat_rate = 2,
$rabbit_ha_queues = undef,
$kombu_ssl_ca_certs = undef,
$kombu_ssl_certfile = undef,
$kombu_ssl_keyfile = undef,
$kombu_ssl_version = 'TLSv1',
$kombu_ssl_ca_certs = $::os_service_default,
$kombu_ssl_certfile = $::os_service_default,
$kombu_ssl_keyfile = $::os_service_default,
$kombu_ssl_version = $::os_service_default,
$kombu_reconnect_delay = '1.0',
$amqp_durable_queues = false,
$verbose = undef,
@ -259,19 +259,6 @@ class aodh (
include ::aodh::db
include ::aodh::logging
if $kombu_ssl_ca_certs and !$rabbit_use_ssl {
fail('The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true')
}
if $kombu_ssl_certfile and !$rabbit_use_ssl {
fail('The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true')
}
if $kombu_ssl_keyfile and !$rabbit_use_ssl {
fail('The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true')
}
if ($kombu_ssl_certfile and !$kombu_ssl_keyfile) or ($kombu_ssl_keyfile and !$kombu_ssl_certfile) {
fail('The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together')
}
package { 'aodh':
ensure => $ensure_package,
name => $::aodh::params::common_package_name,
@ -279,69 +266,26 @@ class aodh (
}
if $rpc_backend == 'rabbit' {
# I may want to support exporting and collecting these
oslo::messaging::rabbit { 'aodh_config':
rabbit_userid => $rabbit_userid,
rabbit_password => $rabbit_password,
rabbit_virtual_host => $rabbit_virtual_host,
rabbit_host => $rabbit_host,
rabbit_port => $rabbit_port,
rabbit_hosts => $rabbit_hosts,
rabbit_ha_queues => $rabbit_ha_queues,
heartbeat_timeout_threshold => $rabbit_heartbeat_timeout_threshold,
heartbeat_rate => $rabbit_heartbeat_rate,
rabbit_use_ssl => $rabbit_use_ssl,
kombu_reconnect_delay => $kombu_reconnect_delay,
kombu_ssl_version => $kombu_ssl_version,
kombu_ssl_keyfile => $kombu_ssl_keyfile,
kombu_ssl_certfile => $kombu_ssl_certfile,
kombu_ssl_ca_certs => $kombu_ssl_ca_certs,
}
aodh_config {
'oslo_messaging_rabbit/rabbit_password': value => $rabbit_password, secret => true;
'oslo_messaging_rabbit/rabbit_userid': value => $rabbit_userid;
'oslo_messaging_rabbit/rabbit_virtual_host': value => $rabbit_virtual_host;
'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl;
'oslo_messaging_rabbit/heartbeat_timeout_threshold': value => $rabbit_heartbeat_timeout_threshold;
'oslo_messaging_rabbit/heartbeat_rate': value => $rabbit_heartbeat_rate;
'oslo_messaging_rabbit/kombu_reconnect_delay': value => $kombu_reconnect_delay;
'DEFAULT/amqp_durable_queues': value => $amqp_durable_queues;
}
if $rabbit_use_ssl {
if $kombu_ssl_ca_certs {
aodh_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs; }
} else {
aodh_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent; }
}
if $kombu_ssl_certfile or $kombu_ssl_keyfile {
aodh_config {
'oslo_messaging_rabbit/kombu_ssl_certfile': value => $kombu_ssl_certfile;
'oslo_messaging_rabbit/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
}
} else {
aodh_config {
'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent;
'oslo_messaging_rabbit/kombu_ssl_keyfile': ensure => absent;
}
}
if $kombu_ssl_version {
aodh_config { 'oslo_messaging_rabbit/kombu_ssl_version': value => $kombu_ssl_version; }
} else {
aodh_config { 'oslo_messaging_rabbit/kombu_ssl_version': ensure => absent; }
}
} else {
aodh_config {
'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent;
'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent;
'oslo_messaging_rabbit/kombu_ssl_keyfile': ensure => absent;
'oslo_messaging_rabbit/kombu_ssl_version': ensure => absent;
}
}
if $rabbit_hosts {
aodh_config { 'oslo_messaging_rabbit/rabbit_hosts': value => join($rabbit_hosts, ',') }
} else {
aodh_config { 'oslo_messaging_rabbit/rabbit_host': value => $rabbit_host }
aodh_config { 'oslo_messaging_rabbit/rabbit_port': value => $rabbit_port }
aodh_config { 'oslo_messaging_rabbit/rabbit_hosts': value => "${rabbit_host}:${rabbit_port}" }
}
if $rabbit_ha_queues == undef {
if $rabbit_hosts {
aodh_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => true }
} else {
aodh_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => false }
}
} else {
aodh_config { 'oslo_messaging_rabbit/rabbit_ha_queues': value => $rabbit_ha_queues }
'DEFAULT/amqp_durable_queues': value => $amqp_durable_queues;
}
}
@ -349,18 +293,13 @@ class aodh (
warning('Qpid driver was removed from Oslo.messaging in Mitaka release')
}
if $notification_driver {
aodh_config {
'DEFAULT/notification_driver': value => join(any2array($notification_driver), ',');
}
} else {
aodh_config { 'DEFAULT/notification_driver': ensure => absent; }
oslo::messaging::notifications { 'aodh_config':
driver => $notification_driver,
topics => $notification_topics,
}
aodh_config {
'DEFAULT/rpc_backend': value => $rpc_backend;
'DEFAULT/notification_topics': value => $notification_topics;
'DEFAULT/gnocchi_url': value => $gnocchi_url;
'database/alarm_history_time_to_live': value => $alarm_history_time_to_live;
}
}

View File

@ -120,29 +120,23 @@ class aodh::logging(
$verbose_real = pick($::aodh::verbose,$verbose)
$debug_real = pick($::aodh::debug,$debug)
if is_service_default($default_log_levels) {
$default_log_levels_real = $default_log_levels
} else {
$default_log_levels_real = join(sort(join_keys_to_values($default_log_levels, '=')), ',')
}
aodh_config {
'DEFAULT/debug' : value => $debug_real;
'DEFAULT/verbose' : value => $verbose_real;
'DEFAULT/use_stderr' : value => $use_stderr_real;
'DEFAULT/use_syslog' : value => $use_syslog_real;
'DEFAULT/log_dir' : value => $log_dir_real;
'DEFAULT/syslog_log_facility' : value => $log_facility_real;
'DEFAULT/logging_context_format_string' : value => $logging_context_format_string;
'DEFAULT/logging_default_format_string' : value => $logging_default_format_string;
'DEFAULT/logging_debug_format_suffix' : value => $logging_debug_format_suffix;
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
'DEFAULT/log_config_append' : value => $log_config_append;
'DEFAULT/default_log_levels' : value => $default_log_levels_real;
'DEFAULT/publish_errors' : value => $publish_errors;
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
'DEFAULT/instance_format' : value => $instance_format;
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
'DEFAULT/log_date_format' : value => $log_date_format;
oslo::log { 'aodh_config':
debug => $debug_real,
verbose => $verbose_real,
use_syslog => $use_syslog_real,
use_stderr => $use_stderr_real,
log_dir => $log_dir_real,
syslog_log_facility => $log_facility_real,
logging_context_format_string => $logging_context_format_string,
logging_default_format_string => $logging_default_format_string,
logging_debug_format_suffix => $logging_debug_format_suffix,
logging_exception_prefix => $logging_exception_prefix,
log_config_append => $log_config_append,
default_log_levels => $default_log_levels,
publish_errors => $publish_errors,
fatal_deprecations => $fatal_deprecations,
log_date_format => $log_date_format,
instance_format => $instance_format,
instance_uuid_format => $instance_uuid_format,
}
}

View File

@ -29,6 +29,7 @@
"dependencies": [
{ "name": "puppetlabs/inifile", "version_requirement": ">=1.0.0 <2.0.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.2.0 <5.0.0" },
{ "name": "openstack/openstacklib", "version_requirement": ">=8.0.0 <9.0.0" }
{ "name": "openstack/openstacklib", "version_requirement": ">=8.0.0 <9.0.0" },
{ "name": "openstack/oslo", "version_requirement": "<9.0.0" }
]
}

View File

@ -6,7 +6,6 @@ describe 'aodh::db' do
context 'with default parameters' do
it { is_expected.to contain_class('aodh::params') }
it { is_expected.to contain_aodh_config('database/connection').with_value('sqlite:////var/lib/aodh/aodh.sqlite') }
it { is_expected.to contain_aodh_config('database/idle_timeout').with_value('3600') }
it { is_expected.to contain_aodh_config('database/min_pool_size').with_value('1') }
@ -25,7 +24,6 @@ describe 'aodh::db' do
}
end
it { is_expected.to contain_class('aodh::params') }
it { is_expected.to contain_aodh_config('database/connection').with_value('mysql+pymysql://aodh:aodh@localhost/aodh').with_secret(true) }
it { is_expected.to contain_aodh_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_aodh_config('database/min_pool_size').with_value('2') }
@ -59,7 +57,7 @@ describe 'aodh::db' do
end
it 'installs python-mongodb package' do
is_expected.to contain_package('aodh-backend-package').with(
is_expected.to contain_package('db_backend_package').with(
:ensure => 'present',
:name => 'python-pymongo',
:tag => 'openstack'
@ -94,7 +92,7 @@ describe 'aodh::db' do
end
it 'install the proper backend package' do
is_expected.to contain_package('aodh-backend-package').with(
is_expected.to contain_package('db_backend_package').with(
:ensure => 'present',
:name => 'python-pysqlite2',
:tag => 'openstack'
@ -108,7 +106,7 @@ describe 'aodh::db' do
end
it 'install the proper backend package' do
is_expected.to contain_package('aodh-backend-package').with(
is_expected.to contain_package('db_backend_package').with(
:ensure => 'present',
:name => 'python-pymysql',
:tag => 'openstack'
@ -123,7 +121,7 @@ describe 'aodh::db' do
{ :database_connection => 'mysql+pymysql://aodh:aodh@localhost/aodh', }
end
it { is_expected.not_to contain_package('aodh-backend-package') }
it { is_expected.not_to contain_package('db_backend_package') }
end
end

View File

@ -26,7 +26,7 @@ describe 'aodh' do
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value('/')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2')
is_expected.to contain_aodh_config('DEFAULT/notification_driver').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_notifications/driver').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('database/alarm_history_time_to_live').with_value('<SERVICE DEFAULT>')
end
end
@ -63,15 +63,15 @@ describe 'aodh' do
end
it 'configures various things' do
is_expected.to contain_aodh_config('DEFAULT/notification_driver').with_value('ceilometer.compute.aodh_notifier')
is_expected.to contain_aodh_config('DEFAULT/notification_topics').with_value('openstack')
is_expected.to contain_aodh_config('oslo_messaging_notifications/driver').with_value('ceilometer.compute.aodh_notifier')
is_expected.to contain_aodh_config('oslo_messaging_notifications/topics').with_value('openstack')
is_expected.to contain_aodh_config('DEFAULT/gnocchi_url').with_value('http://127.0.0.1:8041')
end
context 'with multiple notification_driver' do
before { params.merge!( :notification_driver => ['ceilometer.compute.aodh_notifier', 'aodh.openstack.common.notifier.rpc_notifier']) }
it { is_expected.to contain_aodh_config('DEFAULT/notification_driver').with_value(
it { is_expected.to contain_aodh_config('oslo_messaging_notifications/driver').with_value(
'ceilometer.compute.aodh_notifier,aodh.openstack.common.notifier.rpc_notifier'
) }
end
@ -84,17 +84,13 @@ describe 'aodh' do
end
it 'configures rabbit' do
is_expected.to_not contain_aodh_config('oslo_messaging_rabbit/rabbit_host')
is_expected.to_not contain_aodh_config('oslo_messaging_rabbit/rabbit_port')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673,rabbit2:5674')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('1.0')
is_expected.to contain_aodh_config('DEFAULT/amqp_durable_queues').with_value(false)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent')
end
end
@ -104,10 +100,10 @@ describe 'aodh' do
end
it 'configures rabbit' do
is_expected.to_not contain_aodh_config('oslo_messaging_rabbit/rabbit_host')
is_expected.to_not contain_aodh_config('oslo_messaging_rabbit/rabbit_port')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_reconnect_delay').with_value('1.0')
is_expected.to contain_aodh_config('DEFAULT/amqp_durable_queues').with_value(false)
@ -152,23 +148,19 @@ describe 'aodh' do
end
it 'configures rabbit' do
is_expected.to_not contain_aodh_config('oslo_messaging_rabbit/rabbit_host')
is_expected.to_not contain_aodh_config('oslo_messaging_rabbit/rabbit_port')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_port').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_hosts').with_value('rabbit:5673')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value(true)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false)
is_expected.to contain_aodh_config('DEFAULT/amqp_durable_queues').with_value(true)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent')
end
end
context 'with rabbit ssl enabled with kombu' do
let :params do
{ :rabbit_hosts => ['rabbit:5673'],
:rabbit_use_ssl => 'true',
:rabbit_use_ssl => true,
:kombu_ssl_ca_certs => '/etc/ca.cert',
:kombu_ssl_certfile => '/etc/certfile',
:kombu_ssl_keyfile => '/etc/key',
@ -187,33 +179,15 @@ describe 'aodh' do
context 'with rabbit ssl enabled without kombu' do
let :params do
{ :rabbit_hosts => ['rabbit:5673'],
:rabbit_use_ssl => 'true', }
:rabbit_use_ssl => true, }
end
it 'configures rabbit' do
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(true)
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1')
end
end
context 'with rabbit ssl disabled' do
let :params do
{
:rabbit_password => 'pass',
:rabbit_use_ssl => false,
:kombu_ssl_version => 'TLSv1',
}
end
it 'configures rabbit' do
is_expected.to contain_aodh_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('false')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('<SERVICE DEFAULT>')
is_expected.to contain_aodh_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('<SERVICE DEFAULT>')
end
end
end