Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow active network interface to be overriden #2489

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,41 @@ env_and_envsubst '$EKSD_NAME' \
# directory containing the kickstart config
if [ "$IMAGE_FORMAT" = "ova" ] && \
( [ "$IMAGE_OS" = "redhat" ] || ( [ "$IMAGE_OS" = "ubuntu" ] && [ "$IMAGE_OS_VERSION" != "2004" ] ) ); then
echo "Finding correct interface for packer temporary http server"
ACTIVE_INTERFACE=""
if [ "$(uname -s)" = "Linux" ]; then
INTERFACES=($(ls /sys/class/net))
for interface in "${INTERFACES[@]}"; do
if [ "$interface" = "eth0" ] || [ "$interface" = "en0" ] || [ "$interface" = "eno1" ]; then
ACTIVE_INTERFACE=$interface
echo "Found interface: $interface"
break
fi
done
HTTP_SERVER_IP=$(ip a l $ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
elif [ "$(uname -s)" = "Darwin" ]; then
ACTIVE_INTERFACE="en0"
HTTP_SERVER_IP=$(ifconfig $ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
fi

if [ -z $ACTIVE_INTERFACE ]; then
echo "ACTIVE_INTERFACE cannot be an empty string. Please check your network configuration
and set an appropriate value for ACTIVE_INTERFACE"
exit 1
# Get Packer HTTP server IP from env var if set
PACKER_HTTP_SERVER_IP=${PACKER_HTTP_SERVER_IP:-}
if [ -z $PACKER_HTTP_SERVER_IP ]; then
# Get active network interface from env var if set
PACKER_ACTIVE_INTERFACE="${PACKER_ACTIVE_INTERFACE:-}"
if [ -z $PACKER_ACTIVE_INTERFACE ]; then
echo "Finding interface for Packer temporary HTTP server"
if [ "$(uname -s)" = "Linux" ]; then
INTERFACES=($(ls /sys/class/net))
for interface in "${INTERFACES[@]}"; do
if [ "$interface" = "eth0" ] || [ "$interface" = "en0" ] || [ "$interface" = "eno1" ]; then
PACKER_ACTIVE_INTERFACE=$interface
echo "Found interface: $interface"
break
fi
done
elif [ "$(uname -s)" = "Darwin" ]; then
PACKER_ACTIVE_INTERFACE="en0"
fi
fi

if [ -z $PACKER_ACTIVE_INTERFACE ]; then
echo "PACKER_ACTIVE_INTERFACE cannot be automatically determined. Please export PACKER_ACTIVE_INTERFACE=<Current Host's primary network interface>"
exit 1
fi

if [ "$(uname -s)" = "Linux" ]; then
PACKER_HTTP_SERVER_IP=$(ip a l $PACKER_ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
elif
[ "$(uname -s)" = "Darwin" ]; then
PACKER_HTTP_SERVER_IP=$(ifconfig $PACKER_ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
fi
fi

PACKER_HTTP_SERVER_IP=${PACKER_HTTP_SERVER_IP:-$HTTP_SERVER_IP}
if [ -z $PACKER_HTTP_SERVER_IP ]; then
echo "PACKER_HTTP_SERVER_IP cannot be automatically determined. Please export PACKER_HTTP_SERVER_IP=<Current Host's IP>"
exit 1
Expand Down