Skip to content
Snippets Groups Projects
Commit 541ef971 authored by ale's avatar ale
Browse files

use smarter logic to find etcd servers

parent e9af87df
Branches
No related tags found
No related merge requests found
......@@ -10,6 +10,20 @@ if [ -z "${DOMAIN}" ]; then
exit 1
fi
resolveall() {
local name="$1"
local port="$2"
getent hosts ${name} | awk "{print \$1 \":${port}\"}"
}
commaseplist() {
local out=
for arg in "$@" ; do
out="${out}${out:+,}${arg}"
done
echo "${out}"
}
set_public_ip() {
# Try to guess the public IP of this host if unset, resolving the
# fully-qualified host name.
......@@ -24,5 +38,6 @@ set_public_ip() {
set_etcd_params() {
local default_etcd_server="etcd.${DOMAIN}"
ETCD_SERVER="${ETCD_SERVER:-${default_etcd_server}}"
ETCD_OPTIONS="${ETCD_OPTIONS} --etcd-servers=localhost:4001,${ETCD_SERVER}"
local server_ips=$(commaseplist localhost:4001 $(resolveall ${ETCD_SERVER} 4001))
ETCD_OPTIONS="${ETCD_OPTIONS} --etcd-servers=${server_ips}"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment