项目作者: kintoandar

项目描述 :
Baking delicious cloud instances 🍰
高级语言:
项目地址: git://github.com/kintoandar/bakery.git
创建时间: 2017-06-11T13:00:40Z
项目社区:https://github.com/kintoandar/bakery

开源协议:MIT License

下载


Table of Contents

Bakery - Baking delicious cloud instances

This repository illustrates the proposed workflow described on this blogpost for baking AMIs, launching instances and using Ansible to abstract both configuration logic flows, so I highly recommend you read it first.

Workflow

The following sequence diagram describes the workflow:

bakery_sequence

Example

In this example, we want to spin up an instance with Prometheus using a separated data volume, which is useful for instance failures and service upgrades. The flow is something like this:

bakery_flow

Requirements

This demo has the following requirements:

  • AWS API access tokens
  • Packer >= 1.0.0
  • Ansible >= 2.3.0.0

How to

To generate an AMI to be used in this workflow you’ll just need to run:

  1. # Get the repo
  2. git clone https://github.com/kintoandar/bakery.git
  3. cd bakery
  4. # Download ansible roles dependencies
  5. ansible-galaxy install -r ./requirements.yml -p ./roles
  6. # Use packer to build the AMI (using ansible)
  7. export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXX
  8. export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXX
  9. packer build ./packer.json

Testing

Now, to test the new AMI, just launch it with an extra EBS volume and use the provided cloud-init configuration example as the user-data. After the boot, you can check the cloud-init log in the instance:

  1. less /var/log/cloud-init-output.log

Be sure that /root/bakery/cloud-init.json was created with all the required overrides for Ansible, specially the cloud_init=true.

Ready to be served

Happy baking 🍰