Logilab logo

Table Of Contents

Next topic

Using salt-ami-cloud-builder on a local machine

This Page

salt-ami-cloud-builder’s documentation

Objective

The goal is to automatically create variations of virtual machines images for a cloud infrastructure (OpenStack or Amazon are currently supported) using SaltStack based configuration files available in a given Mercurial repository.

The AMI builder tool can be used in two ways:

  • a simple developper mode, which will create new AMIs from your workstation (it requires root credentials on a the machine)
  • a production mode, in which the special cloud-builder AMI is used to build a preconfigured deployable AMI.

Why you need salt-ami-cloud-builder

For a virtual machine in the cloud (private or Amazon), having a preconfigured AMI helps you gain setup time and execution time.

Instead of having an “install and configure each instantiation of a machine” we go for a “install once, run multiple times” approach.

Another benefit of this approach is that you have a repeatable environnement.

If you’re already using SaltStack, you can easily reuse your salt states to setup a custom AMI.

Quick start

To create your first working image, follow these instructions:

  1. Get the code

    hg clone http://hg.logilab.org/master/salt-ami-cloud-builder/
  2. Install salt-minion and dependencies (as root)

    sudo apt-get install salt-minion python-apt
  3. Configure salt (edit /etc/salt/minion):

    • set to masterless mode

      file_client: local
    • set state and modules source as local folder

      file_roots:
        base:
         - /home/user/src/salt-ami-cloud-builder/
  4. Edit your configuration file

    cd salt-ami-cloud-builder
    cp user_data.cfg.sample user_data.cfg
    vim user_data.cfg

    You should remove the unsed parts.

  5. Set the environment variables by sourcing the config file

    sudo python others/ec2_ami_parser.py user_data.cfg
  6. Run salt

    sudo salt-call saltutil.sync_modules
    sudo salt-call saltutil.sync_states
    sudo salt-call state.sls ami_builder

Warning

At this point, do NOT run a highstate (salt-call state.highstate), as this would modify multiple important system files from your system.

If you got only green and blue outputs, everything should be ok.

You are now the proud owner of a variation.img file containing your dear AMI, in /mnt/output.

Indices and tables