From 3276c9fe474f6882e2672cf2da03333b0a4b651b Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 10 Mar 2021 22:23:38 +0100 Subject: [PATCH] Always choose the default IPv4 address for init'ing Closes https://git.autonomic.zone/coop-cloud/abra/issues/91. --- CHANGELOG.md | 1 + abra | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22addd0..6425e7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Allow cloning of app repos with different main branches using `-b, --branch=` ([#80](https://git.autonomic.zone/coop-cloud/abra/issues/80)) - Protect against lengthy app names which gives Docker trouble later on ([#83](https://git.autonomic.zone/coop-cloud/abra/issues/83)) - Support removal of secrets and volumes when `rm`'ing apps ([#44](https://git.autonomic.zone/coop-cloud/abra/issues/44)) +- Always choose the default IPv4 address with `abra server init` ([#91](https://git.autonomic.zone/coop-cloud/abra/issues/91)) # abra 0.5.0 (2021-03-01) diff --git a/abra b/abra index 258f645..7c2b0db 100755 --- a/abra +++ b/abra @@ -1509,7 +1509,10 @@ sub_server_list() { help_server_init (){ echo "abra [options] server init -Set up a server for Docker swarm joy. +Set up a server for Docker swarm joy. This initialisation explicitly chooses +for the \"single host swarm\" mode which uses the default IPv4 address as the +advertising address. This can be re-configured later for more advanced use +cases. POWERED BY docker swarm init @@ -1521,7 +1524,12 @@ sub_server_init() { load_context - docker swarm init || true + # Note(decentral1se): it sucks to use Google DNS but seems like a reliable method + # for determining the default IPv4 address especially nowadays + # when there are often multiple internal addresses assigned to eth0 + default_ipv4="$(ip route get 8.8.8.8 | head -1 | awk '{print $7}')" + + docker swarm init --advertise-addr "$default_ipv4" || true docker network create --driver=overlay proxy --scope swarm || true }