Deploying cloud images on Promox using proxmox-deploy

One of the main features that Proxmox VE is missing right now, is support for deploying cloud images and configuring them using cloud-init. After having experienced how Amazon AWS and OpenStack handle the deployment of VM’s, having to install all VM’s manually is something I don’t like doing anymore. Luckily, there is a method to achieve the same results on Proxmox (or any other virtualization for that matter). I have created a tool for deploying a cloud image on Proxmox, and the ability to customize it using cloud-init.

So what’s a cloud image?

Cloud image is a term that I have taken from Ubuntu, and it describes a specially prepared VM image. The image contains a minimal installation of the OS (usually a Linux variant). OpenSSH is also installed for logging into the VM after deployment. Finally, cloud-init has been setup to run on first boot. By using cloud-init, one can customize the VM on first boot. cloud-init can perform quite a few tasks, the most common of which are adding your personal SSH key to the VM, configuring the network and setting the hostname. cloud-init can also handoff to Chef or Puppet, to perform more fine-grained configuration.

How does cloud-init work?

cloud-init is documented, albeit quite poorly. In a nutshell, cloud-init will look in certain pre-determined places for configuration to use. On Amazon AWS, there is a special metadata service running on 169.254.169.254. On OpenStack, there is a special block device available called the config-drive. Apart from these specially made metadata services, there is also a more generic solution: the NoCloud datasource.

NoCloud is a specially crafted vfat or iso9660 filesystem, which contains two files: user-data and meta-data. Using these two files, one can run all cloud-init tasks that one could run on Amazon AWS or OpenStack. All it requires is a bit of effort and two files in Yaml format.

The exact way this works is very sparsely documented. I could however glean some insights for another earlier tool called proxmox-init, and see how the files should be formatted. It seems that the meta-data file described the VM itself (its name and identifier) as well as configuring the network. The user-data file is used for all other customizations, like expanding the root disk and configuring SSH client keys. A lot of trial and error went into making this work properly, first with cloud-init itself and then finding out the quirks in the various Linux distributions.

Using proxmox-deploy

I have modelled proxmox-deploy to be an interactive CLI tool. After answering questions about the VM to deploy, the tool will interface with Proxmox and perform all the steps needed to deploy the cloud image and setup the NoCloud configuration. All that’s left after running proxmox-deploy is starting the VM in Proxmox.

In a nutshell, the steps proxmox-deploy executes are as follows:

  1. Asking the user questions about the VM.
  2. Creating a basic VM on Proxmox without disks.
  3. Generating the cloud-init NoCloud disk, uploading it and attaching it to the VM.
  4. Uploading the selected cloud image, optionally decompressing and converting it and attaching it to the VM.

The questions are interactive, where possible the tool tries to provide a sane default. For instance, it tries to get your SSH public keys from your SSH agent, and will set these by default. I will not provide examples of a complete proxmox-deploy session, because the format is still very much in development. However to give you an idea, it may look something like this:

$ proxmox-deploy --proxmox-host node1.example.com --cloud-images-dir /path/to/cloud/images/
proxmox-deploy version 0.1 (build 1aa342a) starting...
...
Proxmox Node to create VM on (Enter ? for a list of options): ?
Please enter one of: node1
Proxmox Node to create VM on (Enter ? for a list of options): node1
...
Amount of CPUs: 1
Emulate which CPU family (Enter ? for a list of options) [host]: 
Amount of Memory (MB): 256
Size of disk (GB): 4

For information on how to setup proxmox-deploy, see the README on Github. Stable releases will be pushed to PyPi.

Future development

I intend to create multiple frontends for providing answers. An ncurses based interface comes to mind, because a lot of questions have lists of possible options and a small popup with a selection box could be very useful. I would also like to provide the option to generate an answer file, to be able to automate proxmox-deploy. For now, the tool provides all the basic functionality I need for my own Proxmox VE setup.

Let me know if you like proxmox-deploy and end up using it for your Proxmox setup.