https://github.com/cdriehuys/ansible-role-ami-builder
Ansible role to create an EC2 instance to construct an AMI for an application.
https://github.com/cdriehuys/ansible-role-ami-builder
Last synced: 4 months ago
JSON representation
Ansible role to create an EC2 instance to construct an AMI for an application.
- Host: GitHub
- URL: https://github.com/cdriehuys/ansible-role-ami-builder
- Owner: cdriehuys
- License: mit
- Created: 2017-08-04T19:42:11.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-11T05:03:22.000Z (almost 8 years ago)
- Last Synced: 2025-01-07T07:44:23.134Z (5 months ago)
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cdriehuys.ami-builder
### Overview
This role allows for construction of an AMI for an application.
### Requirements
Since this role interacts with AWS, we require the `boto` library be installed.
### Variables
#### Required Variables
These variables must be set in order for the role to run.
```YAML
aws_access_key: # Or the AWS_ACCESS_KEY_ID environment variable can be set
aws_secret_key: # Or the AWS_SECRET_ACCESS_KEY environment variable can be set
aws_region: # Or the AWS_REGION environment variable can be setami_builder_base: # ID of the AMI to build off of
```#### Common Variables
These are variables shared across some AWS-related roles that are used to provide defaults for other variables.
```YAML
aws_application_name: my-application
aws_tags: {}
```#### Other Variables
In order to access the instance used to create the AMI we first have to create an SSH key to access the instance with.
```YAML
# The path to the SSH public key for accessing the AMI builder
ami_builder_key_file: "~/.ssh/id_rsa.pub"# Controls the name of the SSH key used to access the AMI builder instance
ami_builder_key_name: "{{ aws_application_name }}-key"
```You can control the attributes of the instance used to create the AMI with the following variables.
```YAML
ami_builder_instance_type: t2.nanoami_builder_default_tags:
application: "{{ aws_application_name }}"
role: ami-builder
ami_builder_tags: "{{ ami_builder_default_tags | combine(aws_tags) }}"
```The created AMI will be registered under the name `application_ami` for the host running the role with the following attributes:
```YAML
ami_builder_ami_name: "{{ aws_application_name }}-{{ ansible_date_time.iso8601 | regex_replace('[^a-zA-Z0-9]', '-') }}"
```### Usage
The role should be included 2 separate times. Once to create the AMI builder, and once to finalize the AMI.
```YAML
- hosts: localhost
connection: localroles:
- { role: cdriehuys.ami-builder, ami_builder_task: create }- hosts: amibuilder
tasks:
- debug:
msg: Perform some task on the AMI builder- hosts: localhost
connection: localroles:
- { role: cdriehuys.ami-builder, ami_builder_task: finalize }
```### License
MIT
### Author
Chathan Driehuys ([email protected])