From 8470fbec1a26cd39e9621746e7456095327008f5 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Tue, 23 Sep 2014 11:03:16 +0000 Subject: Improve cloud-init.configure extension to detect cloud-init 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. --- cloud-init.configure | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cloud-init.configure b/cloud-init.configure index 0dd53654..ca0d2365 100755 --- a/cloud-init.configure +++ b/cloud-init.configure @@ -40,11 +40,23 @@ True|yes) esac -ln -sf /lib/systemd/system/cloud-config.service \ - "$ROOT/etc/systemd/system/multi-user.target.wants/cloud-config.service" -ln -sf /lib/systemd/system/cloud-init-local.service \ - "$ROOT/etc/systemd/system/multi-user.target.wants/cloud-init-local.service" -ln -sf /lib/systemd/system/cloud-init.service \ - "$ROOT/etc/systemd/system/multi-user.target.wants/cloud-init.service" -ln -sf /lib/systemd/system/cloud-final.service \ - "$ROOT/etc/systemd/system/multi-user.target.wants/cloud-final.service" +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/multi-user.target.wants. +# If the services to link are not present, fail. + +services_folder="lib/systemd/system" +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/multi-user.target.wants/$service_name" + fi +done -- cgit v1.2.1