From 1f499360fcb14fb1012e1d378a8a4e76ab171c50 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 14 Dec 2015 15:26:11 +1100 Subject: [PATCH] yum-minimal: do not configure eth0 & eth1 for DHCP automatically Add an environment variable to control the creation of eth0/1 interface enablement scripts. With a tool such as glean, the presence of these scripts will indicate the interface is configured and configuration-drive settings will not be applied. This means in a non-dhcp situation like on Rackspace, network is broken. On Fedora, where later systemd provides "predictable network interface names" [1] eth0 & eth1 ironically aren't predictable so this just confuses things. You really need cloud-init or glean or something to bring up your interfaces in a sane fashion. This maintains the status-quo on centos-minimal, but disables creation for fedora-minimal. [1] http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ Change-Id: I3f1ffeb6de3b1f952292a144efab9554f7f99a5f --- elements/centos-minimal/README.rst | 7 +++++++ .../environment.d/10-centos-distro-name.bash | 4 ++++ elements/yum-minimal/README.rst | 4 ++++ elements/yum-minimal/install.d/10-base-networking | 13 ++++++++++--- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/elements/centos-minimal/README.rst b/elements/centos-minimal/README.rst index eea475ff7..759a1e501 100644 --- a/elements/centos-minimal/README.rst +++ b/elements/centos-minimal/README.rst @@ -12,3 +12,10 @@ flag to disk-image-create when using this element. The `DIB_OFFLINE` or more specific `DIB_YUMCHROOT_USE_CACHE` variables can be set to prefer the use of a pre-cached root filesystem tarball. + +By default, `DIB_YUM_MINIMAL_CREATE_INTERFACES` is set to enable the +creation of `/etc/sysconfig/network-scripts/ifcfg-eth[0|1]` scripts to +enable DHCP on the `eth0` & `eth1` interfaces. If you do not have +these interfaces, or if you are using something else to setup the +network such as cloud-init, glean or network-manager, you would want +to set this to `0`. diff --git a/elements/centos-minimal/environment.d/10-centos-distro-name.bash b/elements/centos-minimal/environment.d/10-centos-distro-name.bash index 7309b3840..39449b156 100644 --- a/elements/centos-minimal/environment.d/10-centos-distro-name.bash +++ b/elements/centos-minimal/environment.d/10-centos-distro-name.bash @@ -1,2 +1,6 @@ export DISTRO_NAME=centos export DIB_RELEASE=${DIB_RELEASE:-7} + +# by default, enable DHCP configuration of eth0 & eth1 in network +# scripts. See yum-minimal for full details +export DIB_YUM_MINIMAL_CREATE_INTERFACES=${DIB_YUM_MINIMAL_CREATE_INTERFACES:-1} diff --git a/elements/yum-minimal/README.rst b/elements/yum-minimal/README.rst index 511ac3380..ebe6be3cf 100644 --- a/elements/yum-minimal/README.rst +++ b/elements/yum-minimal/README.rst @@ -12,3 +12,7 @@ Ubuntu and Debian. Nothing additional is needed on Fedora or CentOS. The `DIB_OFFLINE` or more specific `DIB_YUMCHROOT_USE_CACHE` variables can be set to prefer the use of a pre-cached root filesystem tarball. + +If you wish to have DHCP networking setup for eth0 & eth1 via +/etc/sysconfig/network-config scripts/ifcfg-eth[0|1], set the +environment variable `DIB_YUM_MINIMAL_CREATE_INTERFACES` to `1`. diff --git a/elements/yum-minimal/install.d/10-base-networking b/elements/yum-minimal/install.d/10-base-networking index 64df7ed7c..0072ab1ba 100755 --- a/elements/yum-minimal/install.d/10-base-networking +++ b/elements/yum-minimal/install.d/10-base-networking @@ -28,10 +28,17 @@ NETWORKING_IPV6=yes NOZEROCONF=yes EOF -for interface in eth0 eth1; do - cat << EOF | tee /etc/sysconfig/network-scripts/ifcfg-$interface > /dev/null +# If you want eth0 and eth1 created as DHCP based interfaces, enable +# this. You don't want this if systemd is going to call the +# interfaces on the real system something else, or if you're using a +# network-manager like cloud-init, glean or network-manager that will +# handle the interfaces dynamically. +if [[ "${DIB_YUM_MINIMAL_CREATE_INTERFACES:-0}" -eq "1" ]]; then + for interface in eth0 eth1; do + cat << EOF | tee /etc/sysconfig/network-scripts/ifcfg-$interface > /dev/null DEVICE=$interface BOOTPROTO=dhcp ONBOOT=on EOF -done + done +fi