loadbalancer: Adapt number of process of Haproxy

Currently we only use one process for Haproxy. This patch allow to adapt
the number of process of Haproxy to the number of processor.

Change-Id: Id5a211b72c397bb6cef0f81f7759702f65f9e828
This commit is contained in:
Dimitri Savineau 2015-02-13 17:19:29 -05:00
parent 353d1bf857
commit 809473b7b0
2 changed files with 45 additions and 1 deletions

View File

@ -241,6 +241,10 @@
# (optional) The HTTP sytle basic credentials (using login:password form)
# Defaults to 'admin:changeme'
#
# [*haproxy_options*]
# (optional) The haproxy global options
# Defaults to {}
#
# [*keepalived_state*]
# (optional) TODO
# Defaults to 'BACKUP'
@ -543,6 +547,7 @@ class cloud::loadbalancer(
$sensu_api = true,
$redis = true,
$haproxy_auth = 'admin:changeme',
$haproxy_options = {},
$keepalived_state = 'BACKUP',
$keepalived_priority = '50',
$keepalived_vrrp_interface = false,
@ -642,10 +647,24 @@ class cloud::loadbalancer(
fail('galera_ip should be part of keepalived_public_ipvs or keepalived_internal_ipvs.')
}
# TODO : Use global_options in puppetlabs-haproxy as merge in params.pp
$haproxy_default_options = {
'log' => "${::ipaddress} local0",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => '4000',
'user' => 'haproxy',
'group' => 'haproxy',
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats',
'nbproc' => $::processorcount
}
$haproxy_global_options = merge($haproxy_default_options,$haproxy_options)
# Ensure Keepalived is started before HAproxy to avoid binding errors.
class { 'keepalived': } ->
class { 'haproxy':
service_manage => true
service_manage => true,
global_options => $haproxy_global_options
}
keepalived::vrrp_script { 'haproxy':

View File

@ -110,6 +110,31 @@ describe 'cloud::loadbalancer' do
is_expected.not_to contain_keepalived__instance('2')
end
context 'with 4 processors' do
before :each do
facts.merge!(
:processorcount => '4',
:ipaddress => '10.10.0.1'
)
end
it 'configure haproxy server' do
is_expected.to contain_class('haproxy').with(
:service_manage => true,
:global_options => {
'log' => '10.10.0.1 local0',
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => '4000',
'user' => 'haproxy',
'group' => 'haproxy',
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats',
'nbproc' => '4'
}
)
end
end # configure haproxy server
context 'configure an internal VIP with the same VIP as public network' do
before do
params.merge!(:keepalived_internal_ipvs => ['10.0.0.1', '10.0.0.2'])