ConfigDrive: Disable cloud-init auto dhcp by default

If your using configuration drive, cloud init tries to DHCP by
default anyway, which delays the boot sequence as it seeks out a
network attached metadata source.

So instead, disable the automatic activation so the configuration
drive data source is acutally leverage. Additionally add further
notes to provide guidance to users of DIB.

Change-Id: Ie7c522f23deb3f08ee4ec002e0e2020f382359aa
This commit is contained in:
Julia Kreger 2023-11-01 09:34:56 -07:00
parent bc48388e81
commit e544379010
3 changed files with 31 additions and 1 deletions

View File

@ -25,3 +25,10 @@ DIB_CLOUD_INIT_DATASOURCES
:Example: ``DIB_CLOUD_INIT_DATASOURCES="Ec2, ConfigDrive, OpenStack"`` will
enable the Ec2, ConfigDrive and OpenStack data sources.
.. warning::
Use of the ConfigDrive data source is only considered, by default,
for initial network configuration per cloud-init documentation.
It is recommended that you utilize ``OpenStack`` in addition to
``ConfigDrive`` to collect all available metadata and configuration.
As a result of configuration drive use, cloud-init's automatic
metadata discovery network activation is disabled.

View File

@ -8,12 +8,19 @@ set -o pipefail
DIB_CLOUD_INIT_DATASOURCES=${DIB_CLOUD_INIT_DATASOURCES:-""}
# NOTE(TheJulia): If your looking at slightly more exotic configuration, the
# following links may be wortwhile to review. Specifically: ConfigDrive is just
# initial datasource configuration, and fallback network configuration basically
# always happens. Plus, cloud-init by default ignores other data in the
# configuration drive unless "openstack" is referenced. :\
# https://cloudinit.readthedocs.io/en/latest/reference/datasources/configdrive.html
# https://cloudinit.readthedocs.io/en/latest/reference/datasources/openstack.html#openstack-ironic-bare-metal
if [ -z "$DIB_CLOUD_INIT_DATASOURCES" ] ; then
echo "DIB_CLOUD_INIT_DATASOURCES must be set to a comma-separated list "
echo "of cloud-init data sources you wish to use, ie 'Ec2, NoCloud, ConfigDrive'"
exit 1
fi
if [ -d /etc/cloud/cloud.cfg.d ]; then
cat > /etc/cloud/cloud.cfg.d/91-dib-cloud-init-datasources.cfg <<EOF
datasource_list: [ $DIB_CLOUD_INIT_DATASOURCES, None ]
@ -29,6 +36,15 @@ EOF
datasource:
Ec2:
strict_id: false
EOF
fi
# If we are drawing configuration from configuration drive, we *very*
# likely have network configuration there, so by default try that
# instead of trying to do DHCP out of the gate.
# https://cloudinit.readthedocs.io/en/latest/reference/network-config.html#disabling-network-activation
if [[ $DIB_CLOUD_INIT_DATASOURCES =~ ConfigDrive ]]; then
cat > /etc/cloud/cloud.cfg.d/93-dib-cloud-init-disable-datasource-network-activation.cfg <<EOF
disable_network_activation: true
EOF
fi
fi

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes an issue where if an operator set a cloud-init data source to
``ConfigDrive``, the host might not properly configure as automatic
metadata collection still attempts to operate. We now disable that
by default, when ``ConfigDrive`` is passed as an argument.