diff options
authorPedro Alvarez <>2014-09-23 11:03:16 (GMT)
committerPedro Alvarez <>2014-09-23 11:14:02 (GMT)
commit8470fbec1a26cd39e9621746e7456095327008f5 (patch)
parent3730023c6e0b83241d64fbef7fb4eb317e3edf70 (diff)
Improve cloud-init.configure extension to detect cloud-initbaserock/pedroalvarez/improve-cloud-init-configuration
Some users think that adding the cloud-init configuration extension to a system is enough to install and enable cloud-init. This is not true, to add and enable cloud-init in a system the system has to have cloud-init installed (cloud-init chunk) and cloud-init services have to be enabled (with cloud-init configuration extension) This patch is to alert the user that cloud-init can't be enabled in a system without cloud-init installed, and making the deployment fail.
1 files changed, 20 insertions, 8 deletions
diff --git a/cloud-init.configure b/cloud-init.configure
index 0dd5365..ca0d236 100755
--- a/cloud-init.configure
+++ b/cloud-init.configure
@@ -40,11 +40,23 @@ True|yes)
-ln -sf /lib/systemd/system/cloud-config.service \
- "$ROOT/etc/systemd/system/"
-ln -sf /lib/systemd/system/cloud-init-local.service \
- "$ROOT/etc/systemd/system/"
-ln -sf /lib/systemd/system/cloud-init.service \
- "$ROOT/etc/systemd/system/"
-ln -sf /lib/systemd/system/cloud-final.service \
- "$ROOT/etc/systemd/system/"
+cloud_init_services="cloud-config.service \
+ cloud-init-local.service \
+ cloud-init.service \
+ cloud-final.service"
+# Iterate over the cloud-init services and enable them creating a link
+# into /etc/systemd/system/
+# If the services to link are not present, fail.
+for service_name in $cloud_init_services; do
+ if [ ! -f "$ROOT/$services_folder/$service_name" ]; then
+ echo "ERROR: Service $service_name is missing."
+ echo "Failed to configure cloud-init."
+ exit 1
+ else
+ ln -sf "/$services_folder/$service_name" \
+ "$ROOT/etc/systemd/system/$service_name"
+ fi