diskimage-builder/elements/baremetal/install.d/02-stable-interface-names
Dan Prince 6f8f6b049b baremetal element: Enable stable interface names
By default most cloud images have disabled the
udev rules which give us stable network interface names. While
this is a reasonable default for something like EC2 (the target
for these images) this is very bad behavour on bare metal
and can cause a "musical NICs" situation to occur where
on reboot the NIC names get swapped.

In this commit we re-enable stable interface naming by
removing the dev nulled rules softlink and installing
the biosdevname package. Once this is done interface
names should again show up as em1, em2 instead of
the old eth0, eth1.

We also remove some the common, statically configured
eth0 config files on some distributions. Equivalent
files (if needed) may be auto-generated by using
the dhcp-all-interfaces element.

Change-Id: Idd67977342719e2f295e2fa2c0ed6cfa8602171a
2014-03-12 16:48:48 -04:00

26 lines
750 B
Bash
Executable File

#!/bin/bash
# remove softlink to /dev/null which disables these rules
NET_NAME_SLOT_FILE="/etc/udev/rules.d/80-net-name-slot.rules"
if [ -h $NET_NAME_SLOT_FILE ]; then
rm $NET_NAME_SLOT_FILE
fi
install-packages biosdevname
# Fedora/RHEL cloud images may hard code the eth0 interface
# so it boots w/ DHCP. We remove this file here so it
# doesn't interfere w/ stable interface naming
IFCFG_NETSCRIPT="/etc/sysconfig/network-interfaces/ifcfg-eth0"
if [ -f $IFCFG_NETSCRIPT ]; then
rm $IFCFG_NETSCRIPT
fi
# Ubuntu may hard code the eth0 interface for DHCP
# We remove this file here so it doesn't interfere w/
# stable interface naming
ENI_ETH0_CFG="/etc/network/interfaces.d/eth0.cfg"
if [ -f $ENI_ETH0_CFG ]; then
rm $ENI_ETH0_CFG
fi