From f645287ec45ef49eaee9a04f5d18e2a9c7d928db Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Mon, 26 May 2014 14:35:57 -0700 Subject: [PATCH] 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 --- elements/cloud-init-datasources/README.md | 21 +++++++++++++++++++ .../install.d/05-set-cloud-init-sources | 16 ++++++++++++++ elements/cloud-init-nocloud/element-deps | 1 + .../environment.d/10-cloud-init-nocloud.bash | 1 + .../install.d/05-set-cloud-init-sources | 9 -------- 5 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 elements/cloud-init-datasources/README.md create mode 100755 elements/cloud-init-datasources/install.d/05-set-cloud-init-sources create mode 100644 elements/cloud-init-nocloud/element-deps create mode 100644 elements/cloud-init-nocloud/environment.d/10-cloud-init-nocloud.bash delete mode 100755 elements/cloud-init-nocloud/install.d/05-set-cloud-init-sources diff --git a/elements/cloud-init-datasources/README.md b/elements/cloud-init-datasources/README.md new file mode 100644 index 00000000..61a8d9dc --- /dev/null +++ b/elements/cloud-init-datasources/README.md @@ -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. diff --git a/elements/cloud-init-datasources/install.d/05-set-cloud-init-sources b/elements/cloud-init-datasources/install.d/05-set-cloud-init-sources new file mode 100755 index 00000000..4f88ad95 --- /dev/null +++ b/elements/cloud-init-datasources/install.d/05-set-cloud-init-sources @@ -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 < /etc/cloud/cloud.cfg.d/91-local-metadata-only.cfg <