This commit is contained in:
Bertrand Gouny 2015-06-15 16:04:40 +02:00
parent 9d3252cd55
commit ac8b946967
5 changed files with 42 additions and 3 deletions

View File

@ -4,6 +4,7 @@ MAINTAINER Bertrand Gouny <bertrand.gouny@osixia.net>
# This container need run options :
# --privileged=true
# --net=host
# -v /lib/modules:/lib/modules
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

View File

@ -1,10 +1,11 @@
KEEPALIVED_INTERFACE: eno1
KEEPALIVED_PASSWORD: d0cker
# for electing MASTER, highest priority wins.
# to be MASTER, make 50 more than other machines
KEEPALIVED_PRIORITY: 150
KEEPALIVED_UNICAST_PEER:
KEEPALIVED_UNICAST_PEERS:
- 172.17.8.101
- 172.17.8.102
- 172.17.8.103

View File

@ -1,5 +1,5 @@
vrrp_instance VI_1 {
interface eno1
interface {{ keepalived_interface }}
state MASTER
virtual_router_id 51
priority {{ keepalived_priority }}

View File

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash -ex
FIRST_START_DONE="/etc/docker-keepalived-first-start-done"
@ -13,6 +13,43 @@ if [ ! -e "$FIRST_START_DONE" ]; then
exit 1
else
ln -s /osixia/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
#
# bootstrap config
#
sed -i "s|{{ keepalived_interface }}|$KEEPALIVED_INTERFACE|g" /etc/keepalived/keepalived.conf
sed -i "s|{{ keepalived_priority }}|$KEEPALIVED_PRIORITY|g" /etc/keepalived/keepalived.conf
sed -i "s|{{ keepalived_password }}|$KEEPALIVED_PASSWORD|g" /etc/keepalived/keepalived.conf
# unicast peers
KEEPALIVED_UNICAST_PEERS=($KEEPALIVED_UNICAST_PEERS)
for peer in "${KEEPALIVED_UNICAST_PEERS[@]}"
do
# it's just a peer
# stored in a variable
if [ -n "${!peer}" ]; then
sed -i "s|{{ peer_ip }}|${!peer}\n {{ peer_ip }}|g" /etc/keepalived/keepalived.conf
# directly
else
sed -i "s|{{ peer_ip }}|${peer}\n {{ peer_ip }}|g" /etc/keepalived/keepalived.conf
fi
done
sed -i "/{{ peer_ip }}/d" /etc/keepalived/keepalived.conf
# virtual ips
KEEPALIVED_VIRTUAL_IPS=($KEEPALIVED_VIRTUAL_IPS)
for vip in "${KEEPALIVED_VIRTUAL_IPS[@]}"
do
# it's just a peer
# stored in a variable
if [ -n "${!vip}" ]; then
sed -i "s|{{ floating_ip }}|${!vip}\n {{ floating_ip }}|g" /etc/keepalived/keepalived.conf
# directly
else
sed -i "s|{{ floating_ip }}|${vip}\n {{ floating_ip }}|g" /etc/keepalived/keepalived.conf
fi
done
sed -i "/{{ floating_ip }}/d" /etc/keepalived/keepalived.conf
fi
fi

0
pop Normal file
View File