diff --git a/elements/centos-minimal/README.rst b/elements/centos-minimal/README.rst index eea475ff..759a1e50 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 7309b384..39449b15 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 511ac338..ebe6be3c 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 64df7ed7..0072ab1b 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