The virt-builder templates that we ship just have core packages from each Linux distro. You can install more packages yourself using the
--install
option or by writing scripts.
Debian 7 doesn’t have cloud-init
in the base distro, but it is in wheezy-backports
so we have to write a short script that enables wheezy-backports and installs cloud-init from there:
#!/bin/sh set -e # Install wheezy backports. echo 'deb http://ftp.uk.debian.org/debian wheezy-backports main' \ >> /etc/apt/sources.list apt-get -y update # Install cloud-init. apt-get -y install cloud-init
Then we can run virt-builder, telling it to run the script during the build so that cloud-init will be available in the final image:
virt-builder debian-7 \ --edit '/etc/inittab: s,^#([1-9].*respawn.*/sbin/getty.*),$1,' \ --run install-cloud-init.sh
If you boot this guest, you will see cloud-init messages as it downloads the metadata and continues the customization.
(The complicated --edit
option there is necessary to enable virtual consoles, so you can actually see messages being printed during boot. It will work without that option, but you won’t be able to see any messages.)