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
This commit is contained in:
Dan Prince 2014-02-07 16:18:28 -05:00
parent 66cf95c321
commit 6f8f6b049b
2 changed files with 32 additions and 2 deletions

View File

@ -1,4 +1,9 @@
This is the baremetal (IE: real hardware) element.
Currently, this element will extract out the kernel and initial ramdisk of
the built image.
Does the following:
* Enables stable network interface naming (em1, em2, etc) by
installing the biosdevname and removes any symlinks which may
disable udev rules, etc.
* extracts the kernel and initial ramdisk of the built image.

View File

@ -0,0 +1,25 @@
#!/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