Setup IP address env vars before running installation of specific components 01/14901/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 30 Jan 2025 14:54:08 +0000 (15:54 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 30 Jan 2025 14:54:08 +0000 (15:54 +0100)
Change-Id: I5e03fbe660a68845726188c0abba9ecf78a28908
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/full_install_osm.sh

index f6f30e0..2875228 100755 (executable)
@@ -473,6 +473,16 @@ function deploy_osm() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
+function setup_external_ip() {
+    echo "Determining IP address of the interface with the default route"
+    [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}')
+    [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}')
+    [ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
+    OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'`
+    [ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
+    OSM_K8S_EXTERNAL_IP=${OSM_K8S_EXTERNAL_IP:-${OSM_DEFAULT_IP}}
+}
+
 function install_osm() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
 
@@ -497,13 +507,8 @@ function install_osm() {
 
     [ -n "$DOCKER_REGISTRY_URL" ] && parse_docker_registry_url
 
-    echo "Determining IP address of the interface with the default route"
-    [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}')
-    [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}')
-    [ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
-    OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'`
-    [ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
-    OSM_K8S_EXTERNAL_IP=${OSM_K8S_EXTERNAL_IP:-${OSM_DEFAULT_IP}}
+    echo "Setting up external IP address"
+    setup_external_ip
 
     # configure apt proxy
     [ -n "$APT_PROXY_URL" ] && configure_apt_proxy $APT_PROXY_URL
@@ -1021,6 +1026,7 @@ else
     # Community_installer
     # Special cases go first
     if [ -n "$INSTALL_ONLY" ]; then
+        setup_external_ip
         [ -n "$INSTALL_ONLY_DOCKER_CE" ] && install_docker_ce
         [ -n "$INSTALL_ONLY_K8S_CLUSTER" ] && install_k8s_cluster
         [ -n "$INSTALL_K8S_MONITOR" ] && install_k8s_monitoring