From 02340e2480b2e2e1ed7163f41c9b1ba895b303cd Mon Sep 17 00:00:00 2001 From: Robert C Jennings Date: Thu, 25 May 2017 20:35:27 -0500 Subject: [PATCH] ubuntu-cpc: nocloud data source for non-cloud cloud images (armhf+raspi2) --- debian/changelog | 9 ++++++ .../ubuntu-cpc/hooks/999-cpc-fixes.chroot | 32 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/debian/changelog b/debian/changelog index f3df49d1..b434fe39 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +livecd-rootfs (2.209.13) trusty; urgency=medium + + [Adam Conrad] + * live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot: Add fake_cloud_init + function to create a nocloud data source for cloud images that aren't + meant to be used on real clouds and use it by default on armhf+raspi2 + + -- Robert C Jennings Tue, 23 May 2017 22:35:47 -0500 + livecd-rootfs (2.209.12) trusty; urgency=medium [ Steve Langasek ] diff --git a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot index 34964ca7..b8c8f9d0 100644 --- a/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks/999-cpc-fixes.chroot @@ -50,6 +50,33 @@ EOF sed -i "s/CONDEV/${condev}/g" "$idir/${condev}.conf" } +fake_cloud_init() { + # If the cloud does not provide a meta-data service this should be run + # This will setup a nocloud datasource. + + seed_d="${rootd}/var/lib/cloud/seed/nocloud-net" + mkdir -p "${seed_d}" + + # fake instance-id + cat << EOF > "${seed_d}/meta-data" +instance_id: cloud-image +EOF + + # fake user-data to create the default user/password + cat << EOF > "${seed_d}/user-data" +#cloud-config +password: ubuntu +chpasswd: ubuntu +ssh_pwauth: True +EOF + + # tell cloud-init not to look for meta-data sources + cat << EOF > ${rootd}/etc/cloud/cloud.cfg.d/99-fake_cloud.cfg +# configure cloud-init for NoCloud +datasource_list: [ NoCloud, None ] +EOF +} + ## -------------- # remove 127.0.1.1 entry (LP: #440757) _xchroot "${rootd}" sh -c 'sed -i "/^127.0.1.1/d" /etc/hosts' @@ -132,6 +159,11 @@ case $arch in armhf|arm64) echo "Configuring ARM Serial Port" add_serial_console ttyAMA0 + # Dirty hack because SUBARCH doesn't exist when running chroot hooks, + # and we don't want raspi2 images to depend on a cloud data source: + if _xchroot "${rootd}" dpkg -l linux-image-raspi2 2>/dev/null | grep -q '^.i'; then + fake_cloud_init + fi echo "Image architecture is ARM. Existing vmbuilder-fixups"