init
This commit is contained in:
parent
9d3252cd55
commit
ac8b946967
|
@ -4,6 +4,7 @@ MAINTAINER Bertrand Gouny <bertrand.gouny@osixia.net>
|
||||||
# This container need run options :
|
# This container need run options :
|
||||||
# --privileged=true
|
# --privileged=true
|
||||||
# --net=host
|
# --net=host
|
||||||
|
# -v /lib/modules:/lib/modules
|
||||||
|
|
||||||
# Use baseimage-docker's init system.
|
# Use baseimage-docker's init system.
|
||||||
CMD ["/sbin/my_init"]
|
CMD ["/sbin/my_init"]
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
KEEPALIVED_INTERFACE: eno1
|
||||||
KEEPALIVED_PASSWORD: d0cker
|
KEEPALIVED_PASSWORD: d0cker
|
||||||
|
|
||||||
# for electing MASTER, highest priority wins.
|
# for electing MASTER, highest priority wins.
|
||||||
# to be MASTER, make 50 more than other machines
|
# to be MASTER, make 50 more than other machines
|
||||||
KEEPALIVED_PRIORITY: 150
|
KEEPALIVED_PRIORITY: 150
|
||||||
|
|
||||||
KEEPALIVED_UNICAST_PEER:
|
KEEPALIVED_UNICAST_PEERS:
|
||||||
- 172.17.8.101
|
- 172.17.8.101
|
||||||
- 172.17.8.102
|
- 172.17.8.102
|
||||||
- 172.17.8.103
|
- 172.17.8.103
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
vrrp_instance VI_1 {
|
vrrp_instance VI_1 {
|
||||||
interface eno1
|
interface {{ keepalived_interface }}
|
||||||
state MASTER
|
state MASTER
|
||||||
virtual_router_id 51
|
virtual_router_id 51
|
||||||
priority {{ keepalived_priority }}
|
priority {{ keepalived_priority }}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -ex
|
||||||
|
|
||||||
FIRST_START_DONE="/etc/docker-keepalived-first-start-done"
|
FIRST_START_DONE="/etc/docker-keepalived-first-start-done"
|
||||||
|
|
||||||
|
@ -13,6 +13,43 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
ln -s /osixia/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue