init
This commit is contained in:
parent
ac8b946967
commit
2df1fb5c42
|
@ -6,6 +6,8 @@ MAINTAINER Bertrand Gouny <bertrand.gouny@osixia.net>
|
|||
# --net=host
|
||||
# -v /lib/modules:/lib/modules
|
||||
|
||||
# sudo docker run --privileged=true --net=host -v /lib/modules:/lib/modules -d osixia/keepalived:0.1.0
|
||||
|
||||
# Use baseimage-docker's init system.
|
||||
CMD ["/sbin/my_init"]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
KEEPALIVED_INTERFACE: eno1
|
||||
KEEPALIVED_INTERFACE: wlan0
|
||||
KEEPALIVED_PASSWORD: d0cker
|
||||
|
||||
# for electing MASTER, highest priority wins.
|
||||
|
@ -6,10 +6,7 @@ KEEPALIVED_PASSWORD: d0cker
|
|||
KEEPALIVED_PRIORITY: 150
|
||||
|
||||
KEEPALIVED_UNICAST_PEERS:
|
||||
- 172.17.8.101
|
||||
- 172.17.8.102
|
||||
- 172.17.8.103
|
||||
- 192.168.1.9
|
||||
|
||||
KEEPALIVED_VIRTUAL_IPS:
|
||||
- 192.168.200.17/24 dev eth1
|
||||
- 192.168.200.18/24 dev eth2 label eth2:1
|
||||
- 192.168.1.230
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
vrrp_instance VI_1 {
|
||||
vrrp_instance vip-1 {
|
||||
interface {{ keepalived_interface }}
|
||||
|
||||
track_interface {
|
||||
{{ keepalived_interface }}
|
||||
}
|
||||
|
||||
state MASTER
|
||||
virtual_router_id 51
|
||||
priority {{ keepalived_priority }}
|
||||
nopreempt
|
||||
|
||||
unicast_peer {
|
||||
{{ peer_ip }}
|
||||
}
|
||||
unicast_peer {{ keepalived_unicast_peers }}
|
||||
|
||||
virtual_ipaddress {
|
||||
{{ floating_ip }}
|
||||
{{ keepalived_virtual_ips }}
|
||||
}
|
||||
|
||||
authentication {
|
||||
auth_type PASS
|
||||
auth_pass {{ keepalived_password }}
|
||||
}
|
||||
|
||||
debug
|
||||
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
|||
# 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
|
||||
sed -i "s|{{ keepalived_unicast_peers }}|${!peer}\n {{ keepalived_unicast_peers }}|g" /etc/keepalived/keepalived.conf
|
||||
# directly
|
||||
else
|
||||
sed -i "s|{{ peer_ip }}|${peer}\n {{ peer_ip }}|g" /etc/keepalived/keepalived.conf
|
||||
sed -i "s|{{ keepalived_unicast_peers }}|${peer}\n {{ keepalived_unicast_peers }}|g" /etc/keepalived/keepalived.conf
|
||||
fi
|
||||
done
|
||||
sed -i "/{{ peer_ip }}/d" /etc/keepalived/keepalived.conf
|
||||
sed -i "/{{ keepalived_unicast_peers }}/d" /etc/keepalived/keepalived.conf
|
||||
|
||||
# virtual ips
|
||||
KEEPALIVED_VIRTUAL_IPS=($KEEPALIVED_VIRTUAL_IPS)
|
||||
|
@ -43,13 +43,13 @@ if [ ! -e "$FIRST_START_DONE" ]; then
|
|||
# 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
|
||||
sed -i "s|{{ keepalived_virtual_ips }}|${!vip}\n {{ keepalived_virtual_ips }}|g" /etc/keepalived/keepalived.conf
|
||||
# directly
|
||||
else
|
||||
sed -i "s|{{ floating_ip }}|${vip}\n {{ floating_ip }}|g" /etc/keepalived/keepalived.conf
|
||||
sed -i "s|{{ keepalived_virtual_ips }}|${vip}\n {{ keepalived_virtual_ips }}|g" /etc/keepalived/keepalived.conf
|
||||
fi
|
||||
done
|
||||
sed -i "/{{ floating_ip }}/d" /etc/keepalived/keepalived.conf
|
||||
sed -i "/{{ keepalived_virtual_ips }}/d" /etc/keepalived/keepalived.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash -e
|
||||
exec /usr/sbin/keepalived -f /etc/keepalived/keepalived.conf --dont-fork --log-console
|
||||
exec /usr/sbin/keepalived -f /etc/keepalived/keepalived.conf --dont-fork --log-console -D -d
|
||||
|
|
Loading…
Reference in New Issue