Make haproxy vip colocation optional

New hiera parameter 'haproxy_colocate' will optionally
disable haproxy colocation with public and management VIPs.

This will allow plugins to use cluster_haproxy task, which
currently forces colocation to these VIPs. Previously it failed
but did not cause fatal errors in deployment.

Change-Id: Ie984d4ab3e6ca7aa033d533f79f125917a404017
Partial-Bug: #1556052
This commit is contained in:
Matthew Mosesohn 2016-03-11 17:25:14 +03:00
parent 77a59478b7
commit b3e20d5c1f
4 changed files with 47 additions and 24 deletions

View File

@ -28,6 +28,10 @@
# (optional) Flag to indicate if this is the primary controller
# Defaults to false
#
# [*colocate_haproxy*]
# (optional) Flag to enable pacemaker to bind haproxy to controller VIPs
# Defaults to false
#
# [*debug*]
# (optional)
# Defaults to false
@ -49,6 +53,7 @@ class cluster::haproxy (
$primary_controller = false,
$debug = false,
$other_networks = false,
$colocate_haproxy = false,
$stats_ipaddresses = ['127.0.0.1'],
$spread_checks = '3',
) {
@ -142,8 +147,9 @@ class cluster::haproxy (
# Pacemaker
class { 'cluster::haproxy_ocf':
debug => $debug,
other_networks => $other_networks,
debug => $debug,
other_networks => $other_networks,
colocate_haproxy => $colocate_haproxy,
}
}

View File

@ -3,8 +3,9 @@
# Configure OCF service for HAProxy managed by corosync/pacemaker
#
class cluster::haproxy_ocf (
$debug = false,
$other_networks = false,
$debug = false,
$other_networks = false,
$colocate_haproxy = true,
) inherits cluster::haproxy {
$primitive_type = 'ns_haproxy'
$complex_type = 'clone'
@ -43,28 +44,26 @@ class cluster::haproxy_ocf (
prefix => false,
}
pcmk_colocation { 'vip_public-with-haproxy':
ensure => 'present',
score => 'INFINITY',
first => "clone_${service_name}",
second => "vip__public",
}
if $colocate_haproxy {
pcmk_colocation { 'vip_public-with-haproxy':
ensure => 'present',
score => 'INFINITY',
first => "clone_${service_name}",
second => "vip__public",
}
Service[$service_name] -> Pcmk_colocation['vip_public-with-haproxy']
pcmk_colocation { 'vip_management-with-haproxy':
ensure => 'present',
score => 'INFINITY',
first => "clone_${service_name}",
second => 'vip__management',
pcmk_colocation { 'vip_management-with-haproxy':
ensure => 'present',
score => 'INFINITY',
first => "clone_${service_name}",
second => 'vip__management',
}
Service[$service_name] -> Pcmk_colocation['vip_management-with-haproxy']
}
Pcmk_resource[$service_name] ->
Service[$service_name] ->
Pcmk_colocation['vip_public-with-haproxy']
Pcmk_resource[$service_name] ->
Service[$service_name] ->
Pcmk_colocation['vip_management-with-haproxy']
Service[$service_name]
}

View File

@ -7,6 +7,8 @@ $service_endpoint = hiera('service_endpoint', '')
$primary_controller = hiera('primary_controller')
$haproxy_hash = hiera_hash('haproxy', {})
$external_lb = hiera('external_lb', false)
#FIXME(mattymo): Move colocations to a separate task
$colocate_haproxy = hiera('colocate_haproxy', true)
if !$external_lb {
#FIXME(mattymo): Replace with only VIPs for roles assigned to this node
@ -18,6 +20,7 @@ if !$external_lb {
primary_controller => $primary_controller,
debug => pick($haproxy_hash['debug'], hiera('debug', false)),
other_networks => direct_networks($network_scheme['endpoints']),
stats_ipaddresses => $stats_ipaddresses
stats_ipaddresses => $stats_ipaddresses,
colocate_haproxy => $colocate_haproxy,
}
}

View File

@ -18,7 +18,7 @@ describe manifest do
unless Noop.hiera('external_lb', false)
it "should delcare cluster::haproxy with correct other_networks" do
it "should declare cluster::haproxy with correct other_networks" do
expect(subject).to contain_class('cluster::haproxy').with(
'other_networks' => Noop.puppet_function('direct_networks', endpoints),
)
@ -27,6 +27,21 @@ describe manifest do
it "should setup rsyslog configuration for haproxy" do
expect(subject).to contain_file('/etc/rsyslog.d/haproxy.conf')
end
if Noop.hiera('colocate_haproxy', true)
it "should contain management vip colocation with haproxy" do
expect(subject).to contain_pcmk_colocation('vip_management-with-haproxy').with(
'first' => 'clone_p_haproxy',
'second' => 'vip__management',
)
end
it "should contain public vip colocation with haproxy" do
expect(subject).to contain_pcmk_colocation('vip_public-with-haproxy').with(
'first' => 'clone_p_haproxy',
'second' => 'vip__public',
)
end
end
end
end
test_ubuntu_and_centos manifest