loadbalancer: Make it possible to define a master and a backup router
Until now, the router was hardcoded to be MASTER in the keepalived configuration. This commit allows us to be able to define MASTER and BACKUPS routers for HA failover. close #25
This commit is contained in:
parent
8c65ee7c02
commit
b4bafb06c0
@ -33,6 +33,7 @@ class cloud::loadbalancer(
|
||||
$horizon = true,
|
||||
$spice = true,
|
||||
$haproxy_auth = $os_params::haproxy_auth,
|
||||
$keepalived_state = 'BACKUP',
|
||||
$keepalived_interface = $os_params::keepalived_interface,
|
||||
$keepalived_ipvs = [ $os_params::openstack_vip, $os_params::mysql_vip ],
|
||||
$keepalived_localhost_ip = $os_params::keepalived_localhost_ip,
|
||||
@ -66,7 +67,7 @@ class cloud::loadbalancer(
|
||||
keepalived::instance { '1':
|
||||
interface => $keepalived_interface,
|
||||
virtual_ips => split(join(flatten([$keepalived_ipvs, ['']]), " dev ${keepalived_interface},"), ','),
|
||||
state => 'MASTER',
|
||||
state => $keepalived_state,
|
||||
track_script => ['haproxy'],
|
||||
priority => 50,
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ require 'spec_helper'
|
||||
|
||||
describe 'cloud::loadbalancer' do
|
||||
|
||||
shared_examples_for 'openstack loadbalancer' do
|
||||
shared_examples_for 'openstack master loadbalancer' do
|
||||
|
||||
let :params do
|
||||
{ :ceilometer_api => true,
|
||||
@ -39,6 +39,65 @@ describe 'cloud::loadbalancer' do
|
||||
:horizon => true,
|
||||
:spice => true,
|
||||
:haproxy_auth => 'root:secrete',
|
||||
:keepalived_state => 'MASTER',
|
||||
:keepalived_interface => 'eth0',
|
||||
:keepalived_ipvs => ['10.0.0.1', '10.0.0.2'],
|
||||
:keepalived_localhost_ip => '127.0.0.1',
|
||||
:horizon_port => '80',
|
||||
:spice_port => '6082',
|
||||
:openstack_vip => '10.0.0.3',
|
||||
:mysql_vip => '10.0.0.4',
|
||||
:ks_ceilometer_public_port => '8777',
|
||||
:ks_nova_public_port => '8774',
|
||||
:ks_ec2_public_port => '8773',
|
||||
:ks_metadata_public_port => '8777',
|
||||
:ks_glance_public_port => '9292',
|
||||
:ks_swift_public_port => '8080',
|
||||
:ks_keystone_public_port => '5000',
|
||||
:ks_keystone_admin_port => '35357',
|
||||
:ks_cinder_public_port => '8776',
|
||||
:ks_neutron_public_port => '9696',
|
||||
:ks_heat_public_port => '8004',
|
||||
:ks_heat_cfn_public_port => '8000',
|
||||
:ks_heat_cloudwatch_public_port => '8003' }
|
||||
end
|
||||
|
||||
it 'configure haproxy server' do
|
||||
should contain_class('haproxy')
|
||||
end
|
||||
|
||||
it 'configure keepalived server' do
|
||||
should contain_class('keepalived')
|
||||
end
|
||||
|
||||
it 'configure vrrp_instance with MASTER state' do
|
||||
should contain_keepalived__instance('1').with({
|
||||
'state' => 'MASTER',
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'openstack backup loadbalancer' do
|
||||
|
||||
let :params do
|
||||
{ :ceilometer_api => true,
|
||||
:cinder_api => true,
|
||||
:glance_api => true,
|
||||
:neutron_api => true,
|
||||
:heat_api => true,
|
||||
:heat_cfn_api => true,
|
||||
:heat_cloudwatch_api => true,
|
||||
:nova_api => true,
|
||||
:ec2_api => true,
|
||||
:metadata_api => true,
|
||||
:swift_api => true,
|
||||
:keystone_api_admin => true,
|
||||
:keystone_api => true,
|
||||
:horizon => true,
|
||||
:spice => true,
|
||||
:haproxy_auth => 'root:secrete',
|
||||
:keepalived_state => 'BACKUP',
|
||||
:keepalived_interface => 'eth0',
|
||||
:keepalived_ipvs => ['10.0.0.1', '10.0.0.2'],
|
||||
:keepalived_localhost_ip => '127.0.0.1',
|
||||
@ -69,6 +128,10 @@ describe 'cloud::loadbalancer' do
|
||||
should contain_class('keepalived')
|
||||
end
|
||||
|
||||
it 'configure vrrp_instance with BACKUP state' do
|
||||
should contain_keepalived__instance('1')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
@ -77,7 +140,8 @@ describe 'cloud::loadbalancer' do
|
||||
:concat_basedir => '/var/lib/puppet/concat' }
|
||||
end
|
||||
|
||||
it_configures 'openstack loadbalancer'
|
||||
it_configures 'openstack master loadbalancer'
|
||||
it_configures 'openstack backup loadbalancer'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
@ -86,7 +150,8 @@ describe 'cloud::loadbalancer' do
|
||||
:concat_basedir => '/var/lib/puppet/concat' }
|
||||
end
|
||||
|
||||
it_configures 'openstack loadbalancer'
|
||||
it_configures 'openstack master loadbalancer'
|
||||
it_configures 'openstack backup loadbalancer'
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user