You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Daniel Carrillo ff04c06abc fix last minute bugs 9 months ago
builder Fixes, tidying up, and doc update 9 months ago
group_vars Add load balancer deploy 10 months ago
inventory fix last minute bugs 9 months ago
pics Fixes, tidying up, and doc update 9 months ago
roles fix last minute bugs 9 months ago
.gitignore Full automation when deploying app and add ASG handling 10 months ago
README.md fix last minute bugs 9 months ago
ansible.cfg Add load balancer deploy 10 months ago
app_deployer.yml First steps with app_deployer 10 months ago
infra_deployer.yml First steps with app_deployer 10 months ago
requirements.txt Make linter (almost) happy 9 months ago
requirements_dev.txt Make linter (almost) happy 9 months ago

README.md

Deployer

Quick-start guide

  1. Enable your virtual environment

  2. Load mandatory environment variables, ensure packer is somewhere in your $PATH and the local user can manage docker

  3. Deploying the infrastructure of a new environment

  4. Deploying a minimal VPC for automatic AMI creation

  5. Deploying the application in the new infrastructure

  6. Please be patient, wait for the application to be ready and point your browser to your new endpoint

Overview

architecture

Requirements

Virtual environment

The preferred way to run this deployer is using python virtualenvs, you can fulfill the requirements from requirements.txt using your distro packages but it is not recommended.

Using mkvirtualenv:

mkvirtualenv --python python3 -r requirements.txt deployer

Using venv:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Remember to activate your venv (workon deployer or source venv/bin/activate depending on your work mode).

docker

A recent version of docker is required and the user running the app deployer is expected to be allowed to manage docker without using sudo

ENV variables

The following env variables need to be exported (use of .env file is encouraged):

export AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=YYYYYYYYYYYYYY
export BOTO_USE_ENDPOINT_HEURISTICS=True

Where AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are credentials of a user with full permission to create/delete AWS infrastructure.

Packer 1.4.2

To build AMIs this deployer uses packer so please make sure to place packer binary somewhere on your $PATH

Deploy environments (infrastructure)

ansible-playbook -i inventory/pro infra_deployer.yml

The name of the inventory file (pro in the previous example) is used as prefix for tagging the environment elements, so take this into account before creating a new configuration file.

Another environment can be deployed in the same AWS account with a different name:

ansible-playbook -i inventory/dev infra_deployer.yml

Get the public endpoint for your load balancer

ansible-playbook -i inventory/pro infra_deployer.yml --tag get_endpoint

Build the environment where AMIs will be created

In order to build AMIs (self-contained application), a minimal independent VPC is needed, the same procedure used by the deployer can be here used but deploying with the minimum set of blocks necessary.

ansible-playbook -i ./inventory/builder infra_deployer.yml --tags vpc,subnets,internet_gateway,route_tables

The name of the inventory file (builder) is used as prefix for tagging the environment, this name can NOT be changed since the app builder expects to found a VPC tagged with this name.

Deploy the application

Build a backed AMI with the dockerized application and deploy it

ansible-playbook -i inventory/pro app_deployer.yml

Build a backed AMI with the dockerized application without deploying it

ansible-playbook -i inventory/pro app_deployer.yml --tags artifact,packer

Perform a rolling deploy of the pre-build AMI (the AMI must exists)

ansible-playbook -i inventory/pro app_deployer.yml --tag deploy

Destroy an environment

ansible-playbook -i inventory/pro infra_deployer.yml -e destroy=true

ansible-playbook -i inventory/builder infra_deployer.yml -e destroy=true --tags vpc,subnets,internet_gateway,route_tables