From 491f7bd30727c18fbf043d94b2293607e59633e9 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Tue, 14 Jan 2014 15:07:10 -0500 Subject: [PATCH] loadbalancer: Enable priority selection One can now define the priority of the vrrp router close #25 --- manifests/loadbalancer.pp | 3 ++- spec/classes/cloud_loadbalancer_spec.rb | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/manifests/loadbalancer.pp b/manifests/loadbalancer.pp index 6d35d31b..44356377 100644 --- a/manifests/loadbalancer.pp +++ b/manifests/loadbalancer.pp @@ -34,6 +34,7 @@ class cloud::loadbalancer( $spice = true, $haproxy_auth = $os_params::haproxy_auth, $keepalived_state = 'BACKUP', + $keepalived_priority = 50, $keepalived_interface = $os_params::keepalived_interface, $keepalived_ipvs = [ $os_params::openstack_vip, $os_params::mysql_vip ], $keepalived_localhost_ip = $os_params::keepalived_localhost_ip, @@ -71,7 +72,7 @@ class cloud::loadbalancer( virtual_ips => split(join(flatten([$keepalived_ipvs, ['']]), " dev ${keepalived_interface},"), ','), state => $keepalived_state, track_script => ['haproxy'], - priority => 50, + priority => $keepalived_priority, notify_master => '"/etc/init.d/haproxy start"', notify_backup => '"/etc/init.d/haproxy stop"', } diff --git a/spec/classes/cloud_loadbalancer_spec.rb b/spec/classes/cloud_loadbalancer_spec.rb index 73a7de84..6f1f4cb3 100644 --- a/spec/classes/cloud_loadbalancer_spec.rb +++ b/spec/classes/cloud_loadbalancer_spec.rb @@ -40,6 +40,7 @@ describe 'cloud::loadbalancer' do :spice => true, :haproxy_auth => 'root:secrete', :keepalived_state => 'MASTER', + :keepalived_priority => 50, :keepalived_interface => 'eth0', :keepalived_ipvs => ['10.0.0.1', '10.0.0.2'], :keepalived_localhost_ip => '127.0.0.1', @@ -75,6 +76,7 @@ describe 'cloud::loadbalancer' do it 'configure vrrp_instance with MASTER state' do should contain_keepalived__instance('1').with({ 'state' => 'MASTER', + 'priority' => 50, 'notify_master' => '"/etc/init.d/haproxy start"', 'notify_backup' => '"/etc/init.d/haproxy stop"', }) @@ -102,6 +104,7 @@ describe 'cloud::loadbalancer' do :spice => true, :haproxy_auth => 'root:secrete', :keepalived_state => 'BACKUP', + :keepalived_priority => 49, :keepalived_interface => 'eth0', :keepalived_ipvs => ['10.0.0.1', '10.0.0.2'], :keepalived_localhost_ip => '127.0.0.1', @@ -120,7 +123,7 @@ describe 'cloud::loadbalancer' do :ks_cinder_public_port => '8776', :ks_neutron_public_port => '9696', :ks_heat_public_port => '8004', - :ks_heat_cfn_public_port => '8000', + :ks_heat_cfn_public_port => '8000', :ks_heat_cloudwatch_public_port => '8003' } end @@ -136,6 +139,7 @@ describe 'cloud::loadbalancer' do it 'configure vrrp_instance with BACKUP state' do should contain_keepalived__instance('1').with({ + 'priority' => '49', 'notify_master' => '"/etc/init.d/haproxy start"', 'notify_backup' => '"/etc/init.d/haproxy stop"', })