author Paul Tonelli <>
Fri, 08 Mar 2013 15:16:08 +0100
changeset 51 555bcf9abc33
parent 46 c0fd55eb7989
child 58 987740c53034
permissions -rw-r--r--
corrected bug in resize


Automatically create variations of virtual machines depending
on configuration files availables in repository :


top.sls : top file for the ami_creator
ami_creator.sls : state file to have a correct ami-builder environment
ami_creator_pre.sls : state file applied before the creation of variation
ami_creator_post.sls : state file applied after the creation of variation for cleanup
variation.sls : variation file (should be modified depending on requirements) : top file for the chroot

Present state

The first step is to launch an instance of "ami-creation" on openstack. However the machine is not completely automatic. for now as the user data is not passed. Use at least 20Gb of disk

if there is no file, the state.highstate has not been run:

  salt-call state.highstate
  salt-call state.highstate

(doing it twice is necessary to load new states)

to put in what you want on your ami image (if you already defined it in the hg repo, it is not useful). Then run:

  salt-call state.sls ami_creator_pre

which mounts a debian image and creates all the necessary files inside. Then
update the chroot:

  salt-call vm_create.update_image /mnt/variation

and run your state file (if necessary, modify /etc/salt/srv/variation.sls
which will be executed inside):

  salt-call vm_create.variate_image /mnt/variation

which runs your variation inside the chroot. Finally run

  salt-call state.sls ami_creator_post

which will extract your image kernel and ramdisk and unmount and resize as necessary

Additionnal Documentation


The salt module from glance does not work in debian as ``glanceclient`` package is only available in experimental and I did not manage to connect to openstack essex with it.


The salt module is working as intended.

Optimal behavior of this project

3 levels of scripting:

Virtual Instance Launcher

(hooked to modifications of HG repository)

Ami Creator

An image available on openstack / ec2.

At boot, the user must supply a repository address in user data as
``variation_address`` this information is used by salt at boot to download the
correct revision of files.  it then execute salt-call
vm_create.create_variation which will create a complete ami file and upload it
to glance EC2

Chroot Image

this script should only be a salt state file, and must be run using
salt-highstate before packaging of the ami.