dhcp-all-interfaces: opt let NetworkManager doit.

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.

It will most likely do it just as good, or better than the
dhcp-all-interfaces.sh script.

Since dhcp-all-interfaces clean out all ifcfg files in
60-remove-cloud-image-interfaces it means NetworkManager will
by default attempt auto configuration for all interfaces.

This change add's and environment variable:
  DIB_DHCP_NETWORK_MANAGER_AUTO (default: false)

When DIB_DHCP_NETWORK_MANAGER_AUTO is set to `true` only the
NetworkManager config will be written. The dhcp-all-interfaces
service will not be installed. Hence dhcp-all-interfaces will
not write any config files, allowing NetworkManager to just do
it's thing.

Change-Id: Id6f8d6aaaf52a78175bb6c065ec88274c364834e
This commit is contained in:
Harald Jensås 2022-01-23 23:09:11 +01:00
parent 3df51c5279
commit e7c52139aa
3 changed files with 42 additions and 8 deletions

View File

@ -28,3 +28,14 @@ DIB_DHCP_TIMEOUT
will wait to get an address. Should be increased in networks such as will wait to get an address. Should be increased in networks such as
Infiniband. Infiniband.
:Example: DIB_DHCP_TIMEOUT=300 :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

View File

@ -9,14 +9,6 @@ set -o pipefail
SCRIPTDIR=$(dirname $0) SCRIPTDIR=$(dirname $0)
if [ -e "/etc/redhat-release" ]; then 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 # NOTE(TheJulia): While the internal client which every networkmanager user
# should have is internal, dhclient has better behavior which includes # should have is internal, dhclient has better behavior which includes
# shutting down the port between retries which is critical for recovery # 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 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_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 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 fi

View File

@ -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.