From 6f8f6b049b2ac264ea7d4586f37d7bad74536ce7 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Fri, 7 Feb 2014 16:18:28 -0500 Subject: [PATCH] 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 --- elements/baremetal/README.md | 9 +++++-- .../install.d/02-stable-interface-names | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 elements/baremetal/install.d/02-stable-interface-names diff --git a/elements/baremetal/README.md b/elements/baremetal/README.md index c94fd3754..b5652fbdb 100644 --- a/elements/baremetal/README.md +++ b/elements/baremetal/README.md @@ -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. diff --git a/elements/baremetal/install.d/02-stable-interface-names b/elements/baremetal/install.d/02-stable-interface-names new file mode 100755 index 000000000..32fb19b12 --- /dev/null +++ b/elements/baremetal/install.d/02-stable-interface-names @@ -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