diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-09-23 11:03:16 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-10-07 11:52:44 +0100 |
commit | 48d79f276ca3b37e90a991e2e951d06d4e35c72b (patch) | |
tree | ad0aa0ddf1b357b4e9f2296869ad283068349aff /cloud-init.configure | |
parent | a8d42b546acbb827f0cba1243d2602f06125a10b (diff) | |
download | definitions-48d79f276ca3b37e90a991e2e951d06d4e35c72b.tar.gz |
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.
Diffstat (limited to 'cloud-init.configure')
-rwxr-xr-x | cloud-init.configure | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/cloud-init.configure b/cloud-init.configure index 0dd53654..aa83e0e2 100755 --- a/cloud-init.configure +++ b/cloud-init.configure @@ -40,11 +40,24 @@ 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." >&2 + echo "Failed to configure cloud-init." + exit 1 + else + echo Enabling systemd service "$service_name" >"$MORPH_LOG_FD" + ln -sf "/$services_folder/$service_name" \ + "$ROOT/etc/systemd/system/multi-user.target.wants/$service_name" + fi +done |