summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-09-23 11:03:16 (GMT)
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-09-23 11:14:02 (GMT)
commit8470fbec1a26cd39e9621746e7456095327008f5 (patch)
tree4ff8fe407aa103ec609ffb5098ef993fb8934a63
parent3730023c6e0b83241d64fbef7fb4eb317e3edf70 (diff)
downloaddefinitions-baserock/pedroalvarez/improve-cloud-init-configuration.tar.gz
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.
-rwxr-xr-xcloud-init.configure28
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)
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