Uncloud / Recloud
Ubuntu cloud images helper and EC2/Openstack AMI publisher
Canonical provides a build of ubuntu setup for OpenStack Amazon EC2. These VMs are configured to run on EC2, consumes the EC2 init parameters and more.
More info: Canonical's cloud portal.
To run those ubuntu builds on a local hypervisor, some changes are necessary. The uncloud script runs through those changes.
Import an ubuntu VM archive into EC2 and publish it as an EBS based AMI. A lot of this work is derived from Eric Hammond's blog post Creating Public AMIs Securely for EC2, and his shell script alestic-git-build-ami
Important note: this script assumes that the VM archive can be run by the EC2/Openstack hypervisor. Potential pitfalls that this script does not resolve:
- the hypervisor does not understand the partition
- the kernel will panic (hint: use the 'virtual' build of the kernel)
- the runtime parameters passwed to the VM (ssh keys) are not taken into account by the VM (hint: apt-get install cloud-init)
This script is used at the moment with the a VM created from 'uncloud'. That type of VM is originally made to run on EC2/Openstack. It works fine when re-imported into it.
Another project similar to this is here: https://github.com/kickstarter/build-ubuntu-ami
git clone http://github.com/hmalphettes/ubuntu-uncloud-recloud cd ubuntu-uncloud-recloud ./uncloud.sh
- Download the latest 12.04 cloud image
- Clone it in the raw format
- Grow its partition from 2G to 15G
- Mount it locally
- Setup the ubuntu user with the ubuntu password via grub
- Disable the cloud-init service
- Clone the disk in vmdk format
Ready to be run in your favorite hypervisor.
- OS Linux; tested on ubuntu
- e2progs: e2fsck, resize2fs, fdisk
- qemu-img, qemu-nbd
- VBoxManage: vmdk conversion (optional)
Define the EC2 keys as environment variables:
AWS_USERID="" AWS_ACCESSKEY="" AWS_SECRETKEY=""
Define the URL of the Ubuntu VM archive to download as the environment varable
Place the pk-.pem and cert-.pem files in ~/.ec2 Check the script and run it:
git clone http://github.com/hmalphettes/ubuntu-uncloud-recloud cd ubuntu-uncloud-recloud ./recloud.sh
- Downoad the VM archive (if necessary)
- Unzip it (if necessary
- Locate the VM file (if necessary)
- Clone the VM file into a raw VM file if the VM file is a vmdk (necessary for qemu-nbd).
- Mount the VM file on the file system with qemu-nbd
- Run the script lib/recloud-mounted-img.sh to reverse uncloud.
- reset the grub config to a ubuntu cloud image
- reset the ubuntu user's password
- harden the /etc/sshd_config to only accept public keys for authentication
- delete the chef-connection parameters if present
- delete the /home/ubuntu/.ssh/ keys and known_hosts
- wait for the user to manually tweak other things
- Create a new EBS volume, attach it and mount it to the current instance.
- Copy into the VM's content into the EBS volume.
- Unmount everything
- Create a snapshot of the EBS volument and publish it as an AMI.
1- init job to lazy configure the sshd's keyx; just like cloud-init does but we are disabling it) 2- map 127.0.1.1 to the hostname (not a blocker)