Allow configuring the new notifier settings

This change adds four new parameters for the new notifier added in the
Mistral Rocky release.

Change-Id: I005a49d21842661e944f45d44f08bf6bcec0a2a5
This commit is contained in:
Dougal Matthews 2018-03-02 15:48:46 +00:00
parent efd8cd4b59
commit 59cf993b60
3 changed files with 92 additions and 0 deletions

46
manifests/notifier.pp Normal file
View File

@ -0,0 +1,46 @@
# == Class: mistral::notifier
#
# Configure the mistral notifier
#
# === Parameters
#
# [*type*]
# Type of notifier. Use local to run the notifier within the
# engine server. Use remote if the notifier is launched as
# a separate server to process events.
# (string value)
# Defaults to $::os_service_default.
# [*host*]
# Name of the notifier node. This can be an opaque
# identifier. It is not necessarily a hostname,
# FQDN, or IP address.
# (string value)
# Defaults to $::os_service_default.
# [*topic*]
# The message topic that the notifier server listens on.
# (string value)
# Defaults to $::os_service_default.
# [*notify_publishers*]
# List of publishers to publish notification.
# Note: This maps to the mistral config option `notify` but this is reserved
# in Puppet.
# (list of dicts)
# Defaults to $::os_service_default.
class mistral::notifier(
$type = $::os_service_default,
$host = $::os_service_default,
$topic = $::os_service_default,
$notify_publishers = $::os_service_default,
) {
include ::mistral::deps
include ::mistral::params
mistral_config {
'notifier/type': value => $type;
'notifier/host': value => $host;
'notifier/topic': value => $topic;
'notifier/notify': value => $notify_publishers;
}
}

View File

@ -0,0 +1,3 @@
---
features:
- Add new parameters that allow configuring notifier settings.

View File

@ -0,0 +1,43 @@
require 'spec_helper'
describe 'mistral::notifier' do
shared_examples_for 'mistral notifier' do
it 'configure notifier default params' do
is_expected.to contain_mistral_config('notifier/type').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/host').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/topic').with_value('<SERVICE DEFAULT>')
is_expected.to contain_mistral_config('notifier/notify').with_value('<SERVICE DEFAULT>')
end
context 'with specific parameters' do
let :params do
{ :type => "remote",
:host => "localhost",
:topic => "mistral-event-stream",
:notify_publishers => "[{'type': 'noop'}]",
}
end
it 'configure notifier params' do
is_expected.to contain_mistral_config('notifier/type').with_value('remote')
is_expected.to contain_mistral_config('notifier/host').with_value('localhost')
is_expected.to contain_mistral_config('notifier/topic').with_value('mistral-event-stream')
is_expected.to contain_mistral_config('notifier/notify').with_value("[{'type': 'noop'}]")
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'mistral notifier'
end
end
end