2014-05-26 21:35:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-09-04 04:56:29 +00:00
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2014-05-26 21:35:57 +00:00
|
|
|
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
|
|
|
|
|
2015-05-11 16:48:42 +00:00
|
|
|
if [ -d /etc/cloud/cloud.cfg.d ]; then
|
2017-05-25 22:25:26 +00:00
|
|
|
cat > /etc/cloud/cloud.cfg.d/91-dib-cloud-init-datasources.cfg <<EOF
|
2014-05-26 21:35:57 +00:00
|
|
|
datasource_list: [ $DIB_CLOUD_INIT_DATASOURCES, None ]
|
2017-04-15 17:01:42 +00:00
|
|
|
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
|
2014-05-26 21:35:57 +00:00
|
|
|
EOF
|
2015-05-11 16:48:42 +00:00
|
|
|
fi
|
2014-06-11 23:03:47 +00:00
|
|
|
fi
|