Skip to content

Starter project for automating deployment of a roadrunner-rails (Rails + rbenv) application to AWS

Notifications You must be signed in to change notification settings

gjanakiram/roadrunner-devops

 
 

Repository files navigation

Roadrunner DevOps

Starter project for automating deployment of a roadrunner-rails (Rails + rbenv) project in two steps:

  1. Automates installation of an application to an instance (local Vagrant, EC2, or any other system).
  2. Automates deployment of application instances to the AWS cloud environment by creating a production-ready AMI image.

What You Get: Overview

  • Launch a new instance
  • Deploy your rails application to the instance as a puma server (automatically detects and installs proper ruby version).
  • Configure application user and upstart script
  • Configure CloudWatch logs agent
  • Configure mechanism to pass environment variables to application via EC2 tags so the same image can be deployed to multiple environments without modification.
  • Take a production-ready snapshot of the instance
  • Create a new launch configuration with the newly created AMI
  • Modify existing auto-scaling group to use the newly created launch configuration.
  • Replace old instances in the auto-scaling group with new instances on a rolling basis (with configurable batch size).

Quickstart: AWS

Deploy a roadrunner application to Vagrant instance(s). Prerequisites:

  • Vagrant
  • Virtualbox
  1. Start vargrant
  2. SSH to "jumpbox" driving the ansible process
  3. Run ansible from local files (via default Vagrant synced_folder)
> vagrant up
> vagrant ssh ansible_host
$ ansible-playbook -i /vagrant/hosts.vagrant /vagrant/roadrunner-empty.yml -e "skip_update=true"

To verify,

  1. reboot an instance
  2. SSH into the instance
  3. Verify puma is running on desired port (or visit forwarded port on localhost)
$ curl localhost:3000
<!DOCTYPE html>
<html>
  <head>
    <title>Ruby on Rails: Welcome aboard</title>
  ...
  ...

Quickstart: AWS

Create an AMI image of a roadrunner application. Prerequisites:

  • Ansible to drive the process;
  • An AWS environment with
    • Subnet
    • Security group
    • Keypair
    • ELB
    • Auto-scaling group
  1. Edit the roadrunnner-empty-aws.yml file and modify the AWS-related variables.
  2. Run ansible
$ ansible-playbook -i localhost, roadrunner-empty-aws.yml --private-key [PATH TO YOUR KEY]

Customization

This project deploys a sample Rails application but the conventions can be used on any application:

  1. Configure base OS: centos role
  2. Install and configure dependencies: ruby
  3. Assemble application artifacts: git and rails-build
  4. Configure application: process

What You Get: Details

Step 1: Install application on target instance
  • Update OS
  • Install required packages
  • Configure OS for production use
    • Time zone, ntpd service
    • Appropriate ulimit, e.g., open files (sockets)
    • Create user accounts for sysadmins with keys
  • Obtain latest application, either
    1. Download pre-assembled from a central repository like S3
    2. Assemble from source by checking out and compiling
  • Copy environment-specific variables
  • Add upstart script
  • Install logging and monitoring agents (production)
Step 2: Deploy instance to cloud environment
  • "Bake" AMI of newly packaged instance (from above)
  • Previously provisioned auto-scaling group is running and behind ELB
  • The new launch configuration is applied to the existing auto-scaling group.
  • Instances are replaced in batches.

Resources

About

Starter project for automating deployment of a roadrunner-rails (Rails + rbenv) application to AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published