Add new cloud-init-datasources element

This moves cloud-init data source configuration to a general purpose
cloud-init-datasources element that can be used to explicitly configure
the list of cloud-init sources that will be queried on first boot.

cloud-init-nocloud now depends on this new element to configure the
datasource_list while continuing to prep the image for a nocloud first boot.

Change-Id: Ibcc3b86d6ca567a23f89b7a1a36bc713e444ef68
Closes-bug: #1316475
This commit is contained in:
Adam Gandelman 2014-05-26 14:35:57 -07:00
parent d69c0fce86
commit f645287ec4
5 changed files with 39 additions and 9 deletions

View File

@ -0,0 +1,21 @@
Configures cloud-init to only use an explicit list of data sources.
Cloud-init contains a growing collection of data source modules and most
are enabled by default. This causes cloud-init to query each data source
on first boot. This can cause delays or even boot problems depending on your
environment.
You must define `DIB_CLOUD_INIT_DATASOURCES` as a comma-separated list of valid
data sources to limit the data sources that will be queried for metadata on
first boot.
For instance, to enable only the Ec2 datasource:
export `DIB_CLOUD_INIT_DATASOURCES`="Ec2"
Or to enable multiple:
export `DIB_CLOUD_INIT_DATASOURCES`="Ec2, ConfigDrive, OpenStack"
Including this element without setting `DIB_CLOUD_INIT_DATASOURCES` will cause
image builds to fail.

View File

@ -0,0 +1,16 @@
#!/bin/bash
set -eu
set -o pipefail
DIB_CLOUD_INIT_DATASOURCES=${DIB_CLOUD_INIT_DATASOURCES:-""}
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
cat > /etc/cloud/cloud.cfg.d/91-dib-cloud-init-datasources.cfg <<EOF
datasource_list: [ $DIB_CLOUD_INIT_DATASOURCES, None ]
EOF

View File

@ -0,0 +1 @@
cloud-init-datasources

View File

@ -0,0 +1 @@
export DIB_CLOUD_INIT_DATASOURCES="NoCloud"

View File

@ -1,9 +0,0 @@
#!/bin/bash
set -eu
set -o pipefail
cat > /etc/cloud/cloud.cfg.d/91-local-metadata-only.cfg <<EOF
# No cloud metadata available, use only what is in the image.
datasource_list: [ NoCloud, None ]
EOF