Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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=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 Fedora, but that is no longer in use. ./group_vars/java_ami can be removed.