Add DIB_APT_MINIMAL_CREATE_INTERFACES toggle

Add a DIB_APT_MINIMAL_CREATE_INTERFACES boolean to the debootstrap
element which functions identically to
DIB_YUM_MINIMAL_CREATE_INTERFACES in the yum-minimal element.

This can be used to disable the creation of the
/etc/network/interfaces.d/eth[01] dhcp configuration files, which
are not needed on systems where cloud-init or other means are used
to configure networking.

The flag is enabled by default to keep creating the dhcp interface
files, maintaining backwards compatibility.

Change-Id: I1fdaca8350a5ceefd9e437af4fd000ce6a3ee7f3
This commit is contained in:
Logan V 2019-02-27 17:42:33 -06:00 committed by Ian Wienand
parent 703549412d
commit 8756cbea1b
2 changed files with 23 additions and 9 deletions

View File

@ -63,6 +63,14 @@ For further information about ``DIB_DEBIAN_DEBOOTSTRAP_SCRIPT`` ,
``DIB_DEBIAN_USE_DEBOOTSTRAP_CACHE`` and ``DIB_DEBOOTSTRAP_EXTRA_ARGS``
please consult "README.rst" of the debootstrap element.
----------
Networking
----------
By default ``/etc/network/interfaces.d/eth[0|1]`` files will be
created and enabled with DHCP networking. If you do not wish this to
be done, set ``DIB_APT_MINIMAL_CREATE_INTERFACES`` to ``0``.
-------------------
Note on ARM systems
-------------------

View File

@ -24,15 +24,21 @@ set -o pipefail
# It would be eversogreat if we didn't need to do crap like this
echo $DISTRO_NAME > /etc/hostname
# cloud images expect eth0 and eth1 to use dhcp.
mkdir -p /etc/network/interfaces.d
if ! grep -E -q '^source(|-directory) /etc/network/interfaces.d/\*' /etc/network/interfaces; then
echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces
echo 'Network configuration set to source /etc/network/interfaces.d/*'
fi
for interface in eth0 eth1; do
cat << EOF | tee /etc/network/interfaces.d/$interface
# 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 systemd-networkd that will
# handle the interfaces dynamically.
if [[ "${DIB_APT_MINIMAL_CREATE_INTERFACES:-1}" -eq "1" ]]; then
mkdir -p /etc/network/interfaces.d
if ! grep -E -q '^source(|-directory) /etc/network/interfaces.d/\*' /etc/network/interfaces; then
echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces
echo 'Network configuration set to source /etc/network/interfaces.d/*'
fi
for interface in eth0 eth1; do
cat << EOF | tee /etc/network/interfaces.d/$interface
auto $interface
iface $interface inet dhcp
EOF
done
done
fi