From 314b11b6dd565295b546decee2c8c4ff3e07073f Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 25 Sep 2019 05:43:01 +0000 Subject: [PATCH] Fix networking for CentOS 8 By default network-scripts package isn't installed, so the directories for these files don't exist either. Skip by default for Centos 8. Change-Id: I194ec3735e17f27e586386541dc51f775b01e510 --- .../elements/centos-minimal/README.rst | 14 ++++++++------ .../environment.d/10-centos-distro-name.bash | 9 +++++++-- .../simple-init/post-install.d/80-simple-init | 6 +++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/diskimage_builder/elements/centos-minimal/README.rst b/diskimage_builder/elements/centos-minimal/README.rst index f9187772..394f8879 100644 --- a/diskimage_builder/elements/centos-minimal/README.rst +++ b/diskimage_builder/elements/centos-minimal/README.rst @@ -6,9 +6,11 @@ Create a minimal image based on CentOS Use of this element will require 'yum' and 'yum-utils' to be installed on Ubuntu and Debian. Nothing additional is needed on Fedora or CentOS. -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``. +For CentOS 7, 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``. For CentOS 8, this is set to ``0`` by default as the +system uses NetworkManager by default. diff --git a/diskimage_builder/elements/centos-minimal/environment.d/10-centos-distro-name.bash b/diskimage_builder/elements/centos-minimal/environment.d/10-centos-distro-name.bash index 39449b15..c9fef536 100644 --- a/diskimage_builder/elements/centos-minimal/environment.d/10-centos-distro-name.bash +++ b/diskimage_builder/elements/centos-minimal/environment.d/10-centos-distro-name.bash @@ -2,5 +2,10 @@ 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} +# scripts for centos 7. See yum-minimal for full details. CentOS 8 +# does not come with network-scripts by default so avoid this there. +if [[ ${DIB_RELEASE} -le 7 ]]; then + export DIB_YUM_MINIMAL_CREATE_INTERFACES=${DIB_YUM_MINIMAL_CREATE_INTERFACES:-1} +else + export DIB_YUM_MINIMAL_CREATE_INTERFACES=${DIB_YUM_MINIMAL_CREATE_INTERFACES:-0} +fi diff --git a/diskimage_builder/elements/simple-init/post-install.d/80-simple-init b/diskimage_builder/elements/simple-init/post-install.d/80-simple-init index 3acfba3e..4e219db3 100755 --- a/diskimage_builder/elements/simple-init/post-install.d/80-simple-init +++ b/diskimage_builder/elements/simple-init/post-install.d/80-simple-init @@ -16,7 +16,11 @@ case "$DIB_INIT_SYSTEM" in if [[ ${DIB_SIMPLE_INIT_NETWORKMANAGER} != 1 ]]; then # NOTE(pabelanger): Glean requires network.service for # these platforms when not using networkmanager - systemctl enable network.service + if [[ ${DIB_RELEASE} -lt 8 ]]; then + # Not available on Centos 8 + # NOTE(ianw) we should evaluate if Fedora needs this + systemctl enable network.service + fi fi elif [[ ${DISTRO_NAME} =~ (opensuse) ]]; then # on suse, this is named wicked.service, but it's the same