diff --git a/diskimage_builder/elements/dhcp-all-interfaces/README.rst b/diskimage_builder/elements/dhcp-all-interfaces/README.rst index 4c6c7353d..a11a4cb38 100644 --- a/diskimage_builder/elements/dhcp-all-interfaces/README.rst +++ b/diskimage_builder/elements/dhcp-all-interfaces/README.rst @@ -28,3 +28,14 @@ DIB_DHCP_TIMEOUT will wait to get an address. Should be increased in networks such as Infiniband. :Example: DIB_DHCP_TIMEOUT=300 + +DIB_DHCP_NETWORK_MANAGER_AUTO + :Required: No + :Default: false + :Description: When NetworkManager is detected, and this is set to true the + dhcp-all-interfaces service will not be installed. Only the NetworkManager + configuration will be added. NetworkManager is quite capable to do automatic + interface configuration. NetworkManager will by default try to + auto-configure any interface with no configuration, it will use DHCP for + IPv4 and Router Advertisements to decide how to initialize IPv6. + :Example: DIB_DHCP_NETWORK_MANAGER_AUTO=true diff --git a/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces b/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces index 9b7223117..2b6e4ce6a 100755 --- a/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces +++ b/diskimage_builder/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces @@ -9,14 +9,6 @@ set -o pipefail SCRIPTDIR=$(dirname $0) if [ -e "/etc/redhat-release" ]; then - # TODO(hjensas): Once ndisc6 package is available in EPEL8 drop this, - # and add the package back in pkg-map. - # See: https://bugzilla.redhat.com/show_bug.cgi?id=1779134 - if type dnf &>/dev/null; then - dnf -v -y install ndisc6 || true - else - yum -v -y install ndisc6 || true - fi # NOTE(TheJulia): While the internal client which every networkmanager user # should have is internal, dhclient has better behavior which includes # shutting down the port between retries which is critical for recovery @@ -31,6 +23,22 @@ if [ -x "/etc/NetworkManager" ]; then install -D -g root -o root -m 0644 ${SCRIPTDIR}/NetworkManager-conf.d-00-main.conf /etc/NetworkManager/conf.d/00-main.conf sed -i "s/DIB_DHCP_CLIENT/${DIB_DHCP_CLIENT:-internal}/g" /etc/NetworkManager/conf.d/00-main.conf sed -i "s/DIB_DHCP_TIMEOUT/${DIB_DHCP_TIMEOUT:-30}/g" /etc/NetworkManager/conf.d/00-main.conf + if [ "${DIB_DHCP_NETWORK_MANAGER_AUTO:-false}" == true ]; then + # Use NetworkManager for auto configuration, it will behave just as + # good as dhcp-all-interfaces.sh in most cases. + exit 0 + fi +fi + +if [ -e "/etc/redhat-release" ]; then + # TODO(hjensas): Once ndisc6 package is available in EPEL8 drop this, + # and add the package back in pkg-map. + # See: https://bugzilla.redhat.com/show_bug.cgi?id=1779134 + if type dnf &>/dev/null; then + dnf -v -y install ndisc6 || true + else + yum -v -y install ndisc6 || true + fi fi diff --git a/releasenotes/notes/dhcp-all-interfaces-add-opt-to-let-NetworkManager-handle-it-f7c7f2d033b7f92d.yaml b/releasenotes/notes/dhcp-all-interfaces-add-opt-to-let-NetworkManager-handle-it-f7c7f2d033b7f92d.yaml new file mode 100644 index 000000000..de2039855 --- /dev/null +++ b/releasenotes/notes/dhcp-all-interfaces-add-opt-to-let-NetworkManager-handle-it-f7c7f2d033b7f92d.yaml @@ -0,0 +1,15 @@ +--- +features: + - | + It is now possible to configure the dhcp-all-interfaces element not to + install the dhcp-all-interfaces service on systems with NetworkManager. + + NetworkManager is quite capable to do automatic interface configuration. + NetworkManager will by default try to auto-configure any interface with + no configuration, it will use DHCP for IPv4 and Router Advertisements to + decide how to initialize IPv6. + + The new environment variable ``DIB_DHCP_NETWORK_MANAGER_AUTO`` (defauls to: + ``false``) has been added, when set to ``true`` only the configuration for + NetworkManager is written. +