diff --git a/elements/keepalived/README.md b/elements/keepalived/README.md new file mode 100644 index 000000000..6bdd65d18 --- /dev/null +++ b/elements/keepalived/README.md @@ -0,0 +1,14 @@ +Element to install keepalived + +Configuration +------------- + +keepalived: + keepalive_interface: eth0 + - interface used for VRRP traffic +virtual_ips: + - you can define one or more virtual IPs including IPv6: +- ip: 192.0.2.254/24 + interface: eth0 +- ip: fe80::5cc1:afff:fe58:143b/64 + interface: br-ctlplane diff --git a/elements/keepalived/install.d/76-keepalived b/elements/keepalived/install.d/76-keepalived new file mode 100755 index 000000000..59156efde --- /dev/null +++ b/elements/keepalived/install.d/76-keepalived @@ -0,0 +1,9 @@ +#!/bin/bash + +set -eux + +install-packages keepalived + +if [ "$DIB_INIT_SYSTEM" == "systemd" ] ; then + systemctl enable keepalived.service +fi diff --git a/elements/keepalived/os-config-applier/etc/keepalived/keepalived.conf b/elements/keepalived/os-config-applier/etc/keepalived/keepalived.conf new file mode 100644 index 000000000..bb5a6da8c --- /dev/null +++ b/elements/keepalived/os-config-applier/etc/keepalived/keepalived.conf @@ -0,0 +1,20 @@ +vrrp_script chk_haproxy { + script "killall -0 haproxy" + interval 2 + weight 2 +} + +vrrp_instance VI_1 { + interface {{keepalived.keepalive_interface}} + state MASTER + virtual_router_id 51 + priority {{keepalived.priority}} # 101 on master, 100 on backup + virtual_ipaddress { + {{#virtual_ips}} + {{ip}} dev {{interface}} + {{/virtual_ips}} + } + track_script { + chk_haproxy + } +} diff --git a/elements/keepalived/os-refresh-config/post-configure.d/15-keepalived b/elements/keepalived/os-refresh-config/post-configure.d/15-keepalived new file mode 100755 index 000000000..e188eac3d --- /dev/null +++ b/elements/keepalived/os-refresh-config/post-configure.d/15-keepalived @@ -0,0 +1,4 @@ +#!/bin/bash +set -eux + +service keepalived restart