Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Capistrano plugin for deploying to AWS Auto Scaling groups - enhances abbandoned repository

License

Notifications You must be signed in to change notification settings

EmpaticoOrg/capistrano-asgroup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

capistrano-asgroup is a Capistrano plugin designed to simplify the task of deploying to infrastructure hosted on Amazon EC2. It was completely inspired by the capistrano-ec2group and capistrano-ec2tag plugins, to which all credit is due.

Both of the prior plugins gave you "a way" to deploy using Capistrano to AWS Auto Scaling groups but both required you to do so in a non-straightforward manner by putting your Auto Scaling group in its own security group or by providing a unique tag for your Auto Scaling group. This plugin simply takes the name of the Auto Scaling group and uses that to find the Auto Scaling instances that it should deploy to. It will work with straight up hand created Auto Scaling groups (exact match of the AS group name) or with Cloud Formation created Auto Scaling groups (looking for the name in the Cloud Formation format).

Installation

Set the Amazon AWS Credentials

In order for the plugin to list out the hostnames of your AWS Auto Scaling instances, it will need access to the Amazon AWS API. It is recommended to use IAM to create credentials with limited capabilities for this type of purpose. Specify the following in your Capistrano configuration:

You can use aws-sdk credentials described in AWS docs

set :aws_access_key_id, ENV['AWS_ACCESS_KEY_ID']
set :aws_secret_access_key, ENV['AWS_SECRET_ACCESS_KEY']

Or you can skip this if you have ~/.aws/credentials configured. If you want to select a specific profile for your credentials you can set:

set :aws_profile_name, 'my_profile'

Get the gem

The plugin is distributed as a Ruby gem.

Add the following to your Gemfile:

source "https://packagecloud.io/Empatico/packages" do
  gem "capistrano-asgroup"
end

Install the gems in your manifest using:

bundle install

Usage

Configure Capistrano

Add the gem to your Capfile

require 'capistrano/asgroup'

Then configure your AWS settings in your config/ file.

set :aws_region, 'eu-west-1' # set the region of AWS
set :asgroup_use_private_ips, true
set :aws_profile_name, 'profile_name'

The asgroup_use_private_ips is needed when deploying through a NAT Gateway into a VPC. It uses the instance's private IP addresses rather than their public addresses.

Then replace your role or similar statement with a statement like:

add_as_instances "<my-autoscale-group-name>"[, roles: <role>]

So instead of:

task :production do
  role :web, 'mysever1.example.com','myserver2.example.com'
  logger.info 'Deploying to the PRODUCTION environment!'
end

You would do:

task :production do
  add_as_instances "my-asg-name", roles: 'web'
  logger.info 'Deploying to the PRODUCTION environment!'
end

Add by tag

You can also add instances via the ASG's tagging system.

add_as_by_tag "Name", "#{fetch :stage}-website-webserver", roles: 'web',
user: 'ubuntu'

This would add any instances tagged with the stage plus -website-webserver, for example production-website-webserver.

License

This a continuation of Thomas Verbiscer's capistrano-asgroup, which was extended again by Piotr Jasiulewicz.

Originally developed by: Thomas Verbiscer, released under the MIT License

About

Capistrano plugin for deploying to AWS Auto Scaling groups - enhances abbandoned repository

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%