Logilab logo

Previous topic

Main Files

Next topic

How to build an AMI

This Page

How it worksΒΆ

All the operations are currently done in /etc/rc.local. The content of the file is explained in the following lines.

The first step is to parse the user-data related to our ami

/usr/bin/env python /etc/salt/srv/others/ec2_ami_parser.py

By default this script loads from the user_data supplied to your virtual machine through OpenStack or Amazon. You can manually extract user_data from a config file by passing it as argument.

The next step updates the salt states, if necessary by getting the necessary files from the mercurial (hg) repository


The following commands replace the /etc/rc.local file on the machine as well as a few other files (see the update.sls state file for more information), so do NOT do this on your main machine !

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

(doing it twice is necessary so far to load new state/modules from the hg repository).


salt-call state.sls ami_builder

includes all the operations done in the image. The operations can be grouped in three steps:

  1. preparation (ami_pre): downloads the image, uncompresses it, resizes the filesystem, mounts it, and modify the relevant files to work in a chroot
  2. updates the image, downloads and executes the variation files from the mercurial variation URL
  3. postprocessing (ami_post): unmount, resize and upload the image either to Amazon or to OpenStack depending on user_data