keepalived: Fix ordering of config sections
authorBen Kelly <ben@benjii.net>
Tue, 4 Oct 2016 15:41:47 +0000 (18:41 +0300)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Sat, 31 Dec 2016 10:37:14 +0000 (12:37 +0200)
keepalived seems to be rather particular about which config parameters
come before others.

When defining a virtual IP address, keepalived will check to see if the
vrrp instance is associated with a valid interface. Previously, the
interface parameter was declared after the virtual IP address which
caused an error when keepalived tried to run this check. Keepalived
tries to fall back to checking if 'eth0' exists.

The fix is to re-order the config stanzas so that the interface
parameter comes before the virtual IP address definitions.

Signed-off-by: Ben Kelly <ben@benjii.net>
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
net/keepalived/files/keepalived.init

index da5b69c4a52fa3b4526b9a14d8b85b4a19ad3fa1..125c0872179a6d60708a486e667f94aeb7b6f098 100644 (file)
@@ -248,6 +248,24 @@ vrrp_instance() {
 
        config_section_open "vrrp_instance" "$name"
 
+       config_get auth_type $1 auth_type
+       config_get auth_pass $1 auth_pass
+       [ -n "$auth_type" -a -n "$auth_pass" ] && {
+               printf "${INDENT_1}authentication {\n" >> $KEEPALIVED_CONF
+               printf "${INDENT_2}auth_type $auth_type\n" >> $KEEPALIVED_CONF
+               printf "${INDENT_2}auth_pass $auth_pass\n" >> $KEEPALIVED_CONF
+               printf "$INDENT_1}\n" >> $KEEPALIVED_CONF
+       }
+
+       print_elems_indent $1 $INDENT_1 use_vmac state interface \
+               mcast_src_ip unicast_src_ip virtual_router_id version priority \
+               advert_int preempt_delay debug notify_backup \
+               notify_master notify_fault notify_stop notify \
+               lvs_sync_daemon_interface garp_master_delay garp_master_refresh \
+               garp_master_repeat garp_master_refresh_repeat \
+               no_val_vmac_xmit_base no_val_native_ipv6 no_val_accept \
+               no_val_dont_track_primary no_val_smtp_alert no_val_nopreempt
+
        # Handle virtual_ipaddress & virtual_ipaddress_excluded lists
        for opt in virtual_ipaddress virtual_ipaddress_excluded; do
                config_get $opt $1 $opt
@@ -291,24 +309,6 @@ vrrp_instance() {
        done
        unset optval
 
-       config_get auth_type $1 auth_type
-       config_get auth_pass $1 auth_pass
-       [ -n "$auth_type" -a -n "$auth_pass" ] && {
-               printf "${INDENT_1}authentication {\n" >> $KEEPALIVED_CONF
-               printf "${INDENT_2}auth_type $auth_type\n" >> $KEEPALIVED_CONF
-               printf "${INDENT_2}auth_pass $auth_pass\n" >> $KEEPALIVED_CONF
-               printf "$INDENT_1}\n" >> $KEEPALIVED_CONF
-       }
-
-       print_elems_indent $1 $INDENT_1 use_vmac state interface \
-               mcast_src_ip unicast_src_ip virtual_router_id version priority \
-               advert_int preempt_delay debug notify_backup \
-               notify_master notify_fault notify_stop notify \
-               lvs_sync_daemon_interface garp_master_delay garp_master_refresh \
-               garp_master_repeat garp_master_refresh_repeat \
-               no_val_vmac_xmit_base no_val_native_ipv6 no_val_accept \
-               no_val_dont_track_primary no_val_smtp_alert no_val_nopreempt
-
        config_section_close
 }