Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Amazon machine images (AMIs) are templates AWS uses when creating EC2 cloud servers. They are based on snapshots of existing servers.

Whenever you create an EC2 server, you will need to rely on an existing AMI. To save time when spinning up new servers, we maintain a set of AMIs that come pre-packaged with some of the more time-consuming software to compile and install, such as Ruby, Java, VIPS and ImageMagic.

We have automated the process of creating the AMIs themselves, using the build_ami ansible role.

Outline

build_ami spins up a new ec2 image; installs software on it; takes a snapshot of the server and creates an ami for later use; and finally destroys the ec2 image. The buildvariable determines what software is installed.

Later on, the AMI’s id can be used in building an ec2 servers.

Software installed

Aside from packages and system_setup, which are run on all new machines, the following three optional software installation roles are run:

Sample role

What it does

When it runs

ruby

Compiles and installs Ruby

If you pass --extra-vars "build=ruby_ami"

imagemagick

Compiles and installs imagemagick

If you pass --extra-vars "build=image_ami"

dzi

Compiles and installs vips

If you pass --extra-vars "build=image_ami"

Important files

File

Contents

build_ami.yml

Outline of the role

group_vars/ruby_ami

ami metadata (instance type, disk size, aws name and tags)

group_vars/ruby_image_ami

ami metadata

roles/dzi/vars/role_vars

Current vips version

roles/ruby/vars/role_vars

Current ruby version

roles/imagemagick/vars/role_vars

Current imagemagick version

Example invocations

ansible-playook --ask-vault-pass build_ami.yml --extra-vars "build=ruby_ami"

ansible-playook --ask-vault-pass build_ami.yml --extra-vars "build=ruby_image_ami"

ansible-playook --ask-vault-pass build_ami.yml --extra-vars "build=image_ami"

Viewing created AMIs in the AWS console

The images are visible at: https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Images . Note in particular that the value of the AMI ID column in the table is used to tell Ansible which AMI to use when building ec2 machines. The variable used is ec2_image .

Which ec2 instances are based on which AMIs

Running grep ec2_image group_vars/* lists the AMIs our ec2 servers are based on.

For instance, as of summer 2020, if you run grep ec2_image group_vars/kithe_solr
you will get:

ec2_image: ami-00e403112709795fd #Ubuntu 18 Ruby-Java 2.6.6

While the comment is helpful, it’s possible to get this info by simply looking up the ID in the AWS console under EC2 > Images > AMIs.

Obsolete AMI roles

There used to be a java_ami role we used for solr and fedora boxes, but is is no longer in use. ./group_vars/java_ami can be removed.

  • No labels