Browse Source

Merge "Enable configuration of omamqp1 plugin"

changes/40/772340/4
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
e3ebbb1143
2 changed files with 116 additions and 40 deletions
  1. +68
    -39
      manifests/profile/base/logging/rsyslog.pp
  2. +48
    -1
      spec/classes/tripleo_profile_base_logging_rsyslog_spec.rb

+ 68
- 39
manifests/profile/base/logging/rsyslog.pp View File

@ -45,6 +45,11 @@
# (Optional) String. Contains content of the private key corresponding to
# the cert elasticsearch_tls_client_cert.
# Defaults to undef
#
# [*amqp1*]
# (Optional) Hash. Configuration for output plugin omamqp1.
# Defaults to undef
#
class tripleo::profile::base::logging::rsyslog (
$step = Integer(hiera('step')),
$service_names = hiera('service_names', []),
@ -52,65 +57,89 @@ class tripleo::profile::base::logging::rsyslog (
$elasticsearch_tls_ca_cert = undef,
$elasticsearch_tls_client_cert = undef,
$elasticsearch_tls_client_key = undef,
$amqp1 = undef,
) {
if $step >= 2 {
# NOTE: puppet-rsyslog does not have params manifest, so we don't have any
# other choice than using hiera currently.
$rsyslog_confdir = hiera('rsyslog::confdir', '/etc/rsyslog.d')
if $elasticsearch_tls_ca_cert {
$cacert_path = "${rsyslog_confdir}/es-ca-cert.crt"
$cacert_conf = {'tls.cacert' => $cacert_path}
if $elasticsearch != undef {
if $elasticsearch_tls_ca_cert {
$cacert_path = "${rsyslog_confdir}/es-ca-cert.crt"
$cacert_conf = {'tls.cacert' => $cacert_path}
file { 'elasticsearch_ca_cert':
ensure => 'present',
path => $cacert_path,
content => $elasticsearch_tls_ca_cert
file { 'elasticsearch_ca_cert':
ensure => 'present',
path => $cacert_path,
content => $elasticsearch_tls_ca_cert
}
$esconf1 = merge($elasticsearch, $cacert_conf)
} else {
$esconf1 = $elasticsearch
}
$esconf1 = merge($elasticsearch, $cacert_conf)
} else {
$esconf1 = $elasticsearch
}
if $elasticsearch_tls_client_cert {
$clientcert_path = "${rsyslog_confdir}/es-client-cert.pem"
$clientcert_conf = {'tls.mycert' => $clientcert_path}
if $elasticsearch_tls_client_cert {
$clientcert_path = "${rsyslog_confdir}/es-client-cert.pem"
$clientcert_conf = {'tls.mycert' => $clientcert_path}
file { 'elasticsearch_client_cert':
ensure => 'present',
path => $clientcert_path,
content => $elasticsearch_tls_client_cert
file { 'elasticsearch_client_cert':
ensure => 'present',
path => $clientcert_path,
content => $elasticsearch_tls_client_cert
}
$esconf2 = merge($esconf1, $clientcert_conf)
} else {
$esconf2 = $esconf1
}
$esconf2 = merge($esconf1, $clientcert_conf)
} else {
$esconf2 = $esconf1
}
if $elasticsearch_tls_client_key {
$clientkey_path = "${rsyslog_confdir}/es-client-key.pem"
$clientkey_conf = {'tls.myprivkey' => $clientkey_path}
if $elasticsearch_tls_client_key {
$clientkey_path = "${rsyslog_confdir}/es-client-key.pem"
$clientkey_conf = {'tls.myprivkey' => $clientkey_path}
file { 'elasticsearch_client_key':
ensure => 'present',
path => $clientkey_path,
content => $elasticsearch_tls_client_key
file { 'elasticsearch_client_key':
ensure => 'present',
path => $clientkey_path,
content => $elasticsearch_tls_client_key
}
$esconf = merge($esconf2, $clientkey_conf)
} else {
$esconf = $esconf2
}
$modules_es = {
'imfile' => {},
'omelasticsearch' => {},
}
$actions_es = {
'elasticsearch' => {
'type' => 'omelasticsearch',
'config' => $esconf,
}
}
$esconf = merge($esconf2, $clientkey_conf)
} else {
$esconf = $esconf2
$modules_es = {}
$actions_es = {}
}
$modules = {
'imfile' => {},
'omelasticsearch' => {},
}
$actions = {
'elasticsearch' => {
'type' => 'omelasticsearch',
'config' => $esconf,
if $amqp1 != undef {
$modules_qdr = {
'imfile' => {},
'omamqp1' => {},
}
$actions_qdr = {
'amqp1' => {
'type' => 'omamqp1',
'config' => $amqp1,
}
}
} else {
$modules_qdr = {}
$actions_qdr = {}
}
$modules = $modules_es + $modules_qdr
$actions = $actions_es + $actions_qdr
class { 'rsyslog::server':
modules => $modules,
actions => $actions


+ 48
- 1
spec/classes/tripleo_profile_base_logging_rsyslog_spec.rb View File

@ -41,6 +41,16 @@ action(type="omelasticsearch"
tls.myprivkey="/etc/rsyslog.d/es-client-key.pem"
)
EOS
amqp1_conf = <<-EOS
# amqp1
action(type="omamqp1"
name="amqp1"
host="localhost:5666"
target="rsyslog/logs"
username="bm"
password="whubbaLubba"
)
EOS
describe 'tripleo::profile::base::logging::rsyslog' do
shared_examples_for 'tripleo::profile::base::logging::rsyslog' do
@ -48,9 +58,10 @@ describe 'tripleo::profile::base::logging::rsyslog' do
facts.merge!({ :step => params[:step] })
end
context 'on step 2' do
context 'on step 2 with elasticsearch output' do
let(:params) do
{ :step => 2,
:elasticsearch => {},
:elasticsearch_tls_ca_cert => 'cacert',
:elasticsearch_tls_client_cert => 'clientcert',
:elasticsearch_tls_client_key => 'clientkey',
@ -92,6 +103,42 @@ describe 'tripleo::profile::base::logging::rsyslog' do
})
end
end
context 'on step 2 with amqp1 output' do
let(:params) do
{ :step => 2,
:amqp1 => {
"host" => "localhost:5666",
"target" => "rsyslog/logs",
"username" => "bm",
"password" => "whubbaLubba",
},
}
end
it 'should generate a rsyslog config file for horizon from hieradata and AMQP1 output connection' do
should contain_concat__fragment('rsyslog::component::module::imfile').with({
:target => '/etc/rsyslog.d/50_openstack_logs.conf',
:content => "module(load=\"imfile\")\n",
})
should contain_concat__fragment('rsyslog::component::module::omamqp1').with({
:target => '/etc/rsyslog.d/50_openstack_logs.conf',
:content => "module(load=\"omamqp1\")\n",
})
should contain_concat__fragment('rsyslog::component::input::horizon_openstack.horizon.access').with({
:target => '/etc/rsyslog.d/50_openstack_logs.conf',
:content => horizon_access_log_conf,
})
should contain_concat__fragment('rsyslog::component::input::horizon_openstack.horizon.test').with({
:target => '/etc/rsyslog.d/50_openstack_logs.conf',
:content => horizon_test_log_conf,
})
should contain_concat__fragment('rsyslog::component::action::amqp1').with({
:target => '/etc/rsyslog.d/50_openstack_logs.conf',
:content => amqp1_conf,
})
end
end
end
on_supported_os.each do |os, facts|


Loading…
Cancel
Save