Logilab logo

Previous topic

How it works

Next topic

Test your AMI

This Page

How to build an AMIΒΆ

Prerequisite : having an AMI builder image on AWS or OpenStack

Creating an AMI is as simple as instanciating the salt-creator image in your cloud infrastructure with proper user-data content.

What will be installed and configured in the built AMI image will depend on the configuration description that will be used as SaltStack highstate.

So to summarize, the process of building a customized AMI image is:

  1. Edit/commit/push the file “variation.sls” and all its dependencies in a Mercurial repository (must be accessible from the cloud instance) so that a:
  user@host:~$ salt-call state.sls variation.sls

will create the machine you want.
  1. Then, launch an instance of the “ami-creator” image in your cloud. Use at least 5Gb of disk (add more if your sls file requires more).

    In the userdata form of your instance, copy something like (if you do not put anything, what will be used will be the latest revision from the default repo).

    Warning : the file needs to un-indented (remove whitespaces at beginning of lines)

#salt-grains #interpreter flag
### necessary unless you want the standard image ###
ami.hg_address_variation: http://hg.logilab.org/users/ptonelli/salt-ami-cloud-builder/variation
ami.hg_rev_variation: 9ed741a55f17 #optionnal
ami.name: my_variation
ami.type: ubuntu #or debian

ami.source_address: http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64.tar.gz
ami.source_hash: md5=1d72ed9c56abb899be02e7cae0822f1d

### optionnal if your image uses existing kernel/ramdisk id in openstack ###
kernel_id:a5b900bd-c009-40b2-a763-32b32996b1ee
initrd_id:b953e40a-2605-402b-8663-c8556a5899f2

### optionnal (ami_creation code update) ###
ami.hg_address_server: http://hg.logilab.org/master/salt-ami-cloud-builder/

### optionnal (necessary to upload to openstack) ###
keystone.user: username
keystone.password: password
keystone.tenant: tenant
keystone.tenant_id: 00000000000000000000000000000000
keystone.auth_url: 'http://control.example.com:5000/v2.0'
keystone.insecure: False   #(optional)

### optionnal (necessary to upload to amazon aws) ###
### remove the BEGIN and END statements found in the files ###
### do not forget the ' ' at each newline for ConfigParser ###
aws.region: eu-west-1
aws.private_key: 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
aws.certificate: 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000
 0000000000000000000000000000000000000000000000000000000000000000

  1. you can then connect to your instance and wait until everything in /mnt is unmounted. Upload to glance (openstack) or amazon aws is automatic if you provided the correct user data. test