aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-07-31 08:50:41 +0000
committerGerrit Code Review <review@openstack.org>2015-07-31 08:50:41 +0000
commit240bed12caf0f45a4e0982c50719ff06675013a7 (patch)
tree8738950c1ac1923e3dbaffcb5ddbabf5232c04d8 /docker
parent6b1f9714c703bb3a1c2411b264b26c3fc960901f (diff)
parentab9f652113243c38bef59b907e6729ea5d17f9e0 (diff)
downloadkolla-240bed12caf0f45a4e0982c50719ff06675013a7.tar.gz
kolla-240bed12caf0f45a4e0982c50719ff06675013a7.zip
Merge "Add keepalived to ansible"
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/centos/binary/keepalived/Dockerfile3
l---------docker/centos/binary/keepalived/config-external.sh1
l---------docker/centos/binary/keepalived/config-internal.sh1
-rwxr-xr-xdocker/common/keepalived/config-external.sh11
-rwxr-xr-xdocker/common/keepalived/config-internal.sh31
-rwxr-xr-xdocker/common/keepalived/start.sh34
6 files changed, 54 insertions, 27 deletions
diff --git a/docker/centos/binary/keepalived/Dockerfile b/docker/centos/binary/keepalived/Dockerfile
index f24954990..6aa0a4f10 100755
--- a/docker/centos/binary/keepalived/Dockerfile
+++ b/docker/centos/binary/keepalived/Dockerfile
@@ -8,6 +8,7 @@ RUN yum -y install \
&& yum clean all
COPY keepalived.conf /etc/keepalived/
-
COPY start.sh check_alive.sh /
+COPY config-internal.sh config-external.sh /opt/kolla/
+
CMD ["/start.sh"]
diff --git a/docker/centos/binary/keepalived/config-external.sh b/docker/centos/binary/keepalived/config-external.sh
new file mode 120000
index 000000000..08cebbe79
--- /dev/null
+++ b/docker/centos/binary/keepalived/config-external.sh
@@ -0,0 +1 @@
+../../../common/keepalived/config-external.sh \ No newline at end of file
diff --git a/docker/centos/binary/keepalived/config-internal.sh b/docker/centos/binary/keepalived/config-internal.sh
new file mode 120000
index 000000000..9e9437a00
--- /dev/null
+++ b/docker/centos/binary/keepalived/config-internal.sh
@@ -0,0 +1 @@
+../../../common/keepalived/config-internal.sh \ No newline at end of file
diff --git a/docker/common/keepalived/config-external.sh b/docker/common/keepalived/config-external.sh
new file mode 100755
index 000000000..cb69e1c8f
--- /dev/null
+++ b/docker/common/keepalived/config-external.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+SOURCE="/opt/kolla/keepalived/keepalived.conf"
+TARGET="/etc/keepalived/keepalived.conf"
+OWNER="root"
+
+if [[ -f "$SOURCE" ]]; then
+ rm $TARGET
+ cp $SOURCE $TARGET
+ chown ${OWNER}: $TARGET
+ chmod 0644 $TARGET
+fi
diff --git a/docker/common/keepalived/config-internal.sh b/docker/common/keepalived/config-internal.sh
new file mode 100755
index 000000000..3d182f635
--- /dev/null
+++ b/docker/common/keepalived/config-internal.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+. /opt/kolla/kolla-common.sh
+
+check_required_vars KEEPALIVED_HOST_PRIORITIES \
+ PUBLIC_INTERFACE \
+ PUBLIC_IP
+
+MY_HOSTNAME=`hostname`
+
+# here we unpack KEEPALIVED_HOST_PRIORITIES hostname:priority pairs and match
+# them with current hostname, if it's there
+for i in ${KEEPALIVED_HOST_PRIORITIES//,/ }; do
+ HOST_PRIORITY=(${i//:/ })
+ if [ "$MY_HOSTNAME" == "${HOST_PRIORITY[0]}" ]; then
+ KEEPALIVED_PRIORITY=${HOST_PRIORITY[1]}
+ fi
+done
+
+if [ -z "$KEEPALIVED_PRIORITY" ]; then
+ echo "ERROR: missing hostname in KEEPALIVED_HOST_PRIORITIES: $MY_HOSTNAME" >&2
+ exit 1
+fi
+
+sed -i '
+ s|@PUBLIC_INTERFACE@|'$PUBLIC_INTERFACE'|g
+ s|@PUBLIC_IP@|'$PUBLIC_IP'|g
+ s|@KEEPALIVED_PRIORITY@|'$KEEPALIVED_PRIORITY'|g
+' /etc/keepalived/keepalived.conf
+
+exec /usr/sbin/keepalived -nld -p /run/keepalived.pid
diff --git a/docker/common/keepalived/start.sh b/docker/common/keepalived/start.sh
index 3d182f635..64f47e295 100755
--- a/docker/common/keepalived/start.sh
+++ b/docker/common/keepalived/start.sh
@@ -1,31 +1,13 @@
#!/bin/bash
+set -o errexit
-. /opt/kolla/kolla-common.sh
+CMD="/usr/sbin/keepalived"
+ARGS="-nld -p /run/keepalived.pid"
-check_required_vars KEEPALIVED_HOST_PRIORITIES \
- PUBLIC_INTERFACE \
- PUBLIC_IP
+# Loading common functions.
+source /opt/kolla/kolla-common.sh
-MY_HOSTNAME=`hostname`
+# Config-internal script exec out of this function, it does not return here.
+set_configs
-# here we unpack KEEPALIVED_HOST_PRIORITIES hostname:priority pairs and match
-# them with current hostname, if it's there
-for i in ${KEEPALIVED_HOST_PRIORITIES//,/ }; do
- HOST_PRIORITY=(${i//:/ })
- if [ "$MY_HOSTNAME" == "${HOST_PRIORITY[0]}" ]; then
- KEEPALIVED_PRIORITY=${HOST_PRIORITY[1]}
- fi
-done
-
-if [ -z "$KEEPALIVED_PRIORITY" ]; then
- echo "ERROR: missing hostname in KEEPALIVED_HOST_PRIORITIES: $MY_HOSTNAME" >&2
- exit 1
-fi
-
-sed -i '
- s|@PUBLIC_INTERFACE@|'$PUBLIC_INTERFACE'|g
- s|@PUBLIC_IP@|'$PUBLIC_IP'|g
- s|@KEEPALIVED_PRIORITY@|'$KEEPALIVED_PRIORITY'|g
-' /etc/keepalived/keepalived.conf
-
-exec /usr/sbin/keepalived -nld -p /run/keepalived.pid
+exec $CMD $ARGS