Fix idempotence of logging task

The logging task removes all files from /etc/rsyslog.d, while
cluster-haproxy (executed later in the deployment graph) wants to put
its rsyslog configuration there. This commit moves HAProxy rsyslog
configuration to cluster::haproxy::rsyslog class, and defines it in both
logging task and cluster:haproxy class.

Change-Id: I2b450ef8d8de4fc9d41ada458af26ab91b9c871e
Closes-Bug: 1524687
This commit is contained in:
Bartłomiej Piotrowski 2015-12-15 12:06:30 +01:00
parent 14576a3dbb
commit 29d65b95b1
6 changed files with 60 additions and 18 deletions

View File

@ -121,6 +121,10 @@ class cluster::haproxy (
package_name => $haproxy::params::package_name,
}
class { 'cluster::haproxy::rsyslog':
log_file => $haproxy_log_file,
}
Package['haproxy'] ->
Class['haproxy::base']
@ -133,23 +137,7 @@ class cluster::haproxy (
Sysctl::Value['net.ipv4.ip_nonlocal_bind'] ~>
Service['haproxy']
# Rsyslog
file { '/etc/rsyslog.d/haproxy.conf':
ensure => present,
content => template("${module_name}/haproxy.conf.erb"),
notify => Service[$::rsyslog::params::service_name],
}
if !defined(Service[$::rsyslog::params::service_name]) {
service { $::rsyslog::params::service_name:
ensure => 'running',
enable => true,
}
}
# Paceamker
# Pacemaker
class { 'cluster::haproxy_ocf':
debug => $debug,
other_networks => $other_networks,

View File

@ -0,0 +1,27 @@
# == Class: cluster::haproxy::rsyslog
#
# Configure rsyslog for corosync/pacemaker managed HAProxy
#
# === Parameters
#
# [*log_file*]
# Log file location for haproxy. Defaults to '/var/log/haproxy.log'
#
class cluster::haproxy::rsyslog (
$log_file = '/var/log/haproxy.log',
) {
include ::rsyslog::params
file { '/etc/rsyslog.d/haproxy.conf':
ensure => present,
content => template("${module_name}/haproxy.conf.erb"),
notify => Service[$::rsyslog::params::service_name],
}
if !defined(Service[$::rsyslog::params::service_name]) {
service { $::rsyslog::params::service_name:
ensure => 'running',
enable => true,
}
}
}

View File

@ -0,0 +1,21 @@
require 'spec_helper'
describe 'cluster::haproxy::rsyslog' do
let(:default_params) { {
:log_file => '/var/log/haproxy.log'
} }
shared_examples_for 'haproxy rsyslog configuration' do
let :params do
default_params
end
context 'with default parameters' do
it 'should configure rsyslog for haproxy' do
should contain_file('/etc/rsyslog.d/haproxy.conf')
end
end
end
end

View File

@ -3,5 +3,5 @@
$AddUnixListenSocket /var/lib/haproxy/dev/log
# Send HAProxy messages to a dedicated logfile
if $programname startswith 'haproxy' then <%= @haproxy_log_file %>
if $programname startswith 'haproxy' then <%= @log_file %>
&~

View File

@ -64,4 +64,6 @@ if $use_syslog {
debug => $debug,
ironic_collector => $ironic_collector,
}
class { '::cluster::haproxy::rsyslog': }
}

View File

@ -28,6 +28,10 @@ describe manifest do
)
}
end
it {
should contain_class('cluster::haproxy::rsyslog')
}
end
test_ubuntu_and_centos manifest
end