Allow to configure notifiers

Change-Id: I2fadae52aa59e3ee0fe74ddd3973a3e0863adca1
This commit is contained in:
Emilien Macchi 2018-01-04 10:43:46 -08:00
parent 2f61c54b8a
commit adc19e93a2
2 changed files with 31 additions and 0 deletions

View File

@ -13,20 +13,35 @@
# (optional) ensure state for package.
# Defaults to 'present'
#
# [*notifiers*]
# (optional) Names of enabled notifiers.
# Defaults to $::os_service_default.
#
class vitrage::notifier (
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$notifiers = $::os_service_default,
) {
include ::vitrage::deps
include ::vitrage::params
if !is_service_default($notifiers) {
$notifiers_orig = join(any2array($notifiers), ',')
} else {
$notifiers_orig = $notifiers
}
ensure_resource( 'package', [$::vitrage::params::notifier_package_name],
{ ensure => $package_ensure,
tag => ['openstack', 'vitrage-package'] }
)
vitrage_config {
'DEFAULT/notifiers': value => $notifiers_orig;
}
if $manage_service {
if $enabled {
$service_ensure = 'running'

View File

@ -19,6 +19,10 @@ describe 'vitrage::notifier' do
)
end
it 'configure notifier default params' do
is_expected.to contain_vitrage_config('DEFAULT/notifiers').with_value('<SERVICE DEFAULT>')
end
it 'configures vitrage-notifier service' do
is_expected.to contain_service('vitrage-notifier').with(
:ensure => 'running',
@ -67,6 +71,18 @@ describe 'vitrage::notifier' do
)
end
end
context 'when configuring notifiers' do
let :params do
{ :notifiers => ['mistral', 'nova'] }
end
it { is_expected.to compile }
it 'configure notifier params' do
is_expected.to contain_vitrage_config('DEFAULT/notifiers').with_value('mistral,nova')
end
end
end
on_supported_os({