1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
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 ]
EOF
# Newer cloud-init versions complain by default when they should
# use the Ec2 datasource on a non-AWS cloud. If the Ec2
# datasource is desired, we need to tell cloud-init that we really
# want this. Otherwise there will be ugly warnings or worse.
#
if [[ $DIB_CLOUD_INIT_DATASOURCES =~ Ec2 ]]; then
cat > /etc/cloud/cloud.cfg.d/92-ec2-datasource.cfg <<EOF
#cloud-config
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
|