capistrano-ec2tag 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +71 -0
- data/capistrano-ec2tag.gemspec +3 -2
- data/lib/capistrano/ec2tag.rb +18 -13
- data/lib/capistrano/ec2tag/version.rb +5 -0
- metadata +7 -6
- data/README.markdown +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f188593d827fed3038a2315de953cb656809b8bd
|
4
|
+
data.tar.gz: b7a39128c4eb64836caf8abecad1f09efe1f228b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9682b271b3aba6bdabcc03499f79ffb0f7c888d7cd27c2209f26008eb8d044b8b3ae7dddd9d229342417c0f0c93c8ced143cf709fe22db7a7af324e867fe875
|
7
|
+
data.tar.gz: 80854965b7cc82c0b0bb15b02b672777d9b66d35b5219861976221f0def0c486be1384a9c9f1239ba739263fed1f636860e72475b025161624902c85b069ee69
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
## Introduction
|
2
|
+
|
3
|
+
capistrano-ec2tag is a [Capistrano](https://github.com/capistrano/capistrano) plugin designed to simplify the
|
4
|
+
task of deploying to infrastructure hosted on [Amazon EC2](http://aws.amazon.com/ec2/). It was inspired by the [capistrano-ec2group](https://github.com/logandk/capistrano-ec2group) plugin, to which all credit is due.
|
5
|
+
|
6
|
+
While the original [capistrano-ec2group](https://github.com/logandk/capistrano-ec2group) plugin served me well, I started to run into cases where I wanted more flexibility. More specifically, in order to change security groups, instances have to be restarted.
|
7
|
+
|
8
|
+
I created capistrano-ec2tag to bypass this limitation. Now, modifying the list of instances that are deployable is as easy as modifying tags.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```
|
15
|
+
gem 'capistrano-ec2tag'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
```
|
21
|
+
$ bundle
|
22
|
+
```
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
```
|
27
|
+
$ gem install capistrano-ec2tag
|
28
|
+
```
|
29
|
+
|
30
|
+
## Configuration
|
31
|
+
|
32
|
+
Tag your instances, using `deploy` as the key. For example:
|
33
|
+
|
34
|
+

|
35
|
+
|
36
|
+
The tag value can be any string, but I suggest using something like `APP-ENVIRONMENT`.
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
Add this to the top of your `deploy.rb`:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
require 'capistrano/ec2tag'
|
44
|
+
```
|
45
|
+
|
46
|
+
Then supply your AWS credentials with the environment variables (default):
|
47
|
+
|
48
|
+
```zsh
|
49
|
+
# aws
|
50
|
+
export AWS_ACCESS_KEY_ID='...'
|
51
|
+
export AWS_SECRET_ACCESS_KEY='...'
|
52
|
+
```
|
53
|
+
|
54
|
+
Or in your `deploy.rb` with capistrano variables:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
set :aws_access_key_id, '...'
|
58
|
+
set :aws_secret_access_key, '...'
|
59
|
+
```
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# old & busted
|
63
|
+
server 'web1.example.com', :web
|
64
|
+
|
65
|
+
# new hotness
|
66
|
+
tag 'github-staging', :web
|
67
|
+
```
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
capistrano-ec2tag is copyright 2013 by [Douglas Jarquin](http://douglasjarquin.com/), released under the MIT License (see LICENSE for details).`
|
data/capistrano-ec2tag.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'capistrano/ec2tag/version'
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = 'capistrano-ec2tag'
|
6
|
-
s.version =
|
7
|
+
s.version = Capistrano::Ec2tag::VERSION
|
7
8
|
s.authors = ['Douglas Jarquin']
|
8
9
|
s.email = ['douglasjarquin@me.com']
|
9
10
|
s.homepage = 'https://github.com/douglasjarquin/capistrano-ec2tag'
|
@@ -17,6 +18,6 @@ Gem::Specification.new do |s|
|
|
17
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
19
|
s.require_paths = ['lib']
|
19
20
|
|
20
|
-
s.add_dependency 'capistrano', '>=2.
|
21
|
+
s.add_dependency 'capistrano', '>=2.15.5'
|
21
22
|
s.add_dependency 'aws-sdk', '>=1.8.5'
|
22
23
|
end
|
data/lib/capistrano/ec2tag.rb
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
+
require 'capistrano'
|
1
2
|
require 'aws-sdk'
|
2
3
|
|
3
|
-
unless Capistrano::Configuration.respond_to?(:instance)
|
4
|
-
abort 'capistrano/ec2tag requires Capistrano >= 2'
|
5
|
-
end
|
6
|
-
|
7
4
|
module Capistrano
|
8
|
-
|
9
|
-
|
5
|
+
module Ec2tag
|
6
|
+
def self.extend(configuration)
|
7
|
+
configuration.load do
|
8
|
+
Capistrano::Configuration.instance.load do
|
9
|
+
_cset(:access_key_id, ENV['AWS_ACCESS_KEY_ID'])
|
10
|
+
_cset(:secret_access_key, ENV['AWS_SECRET_ACCESS_KEY'])
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
def tag(which, *args)
|
13
|
+
@ec2 ||= AWS::EC2.new({access_key_id: fetch(:aws_access_key_id), secret_access_key: fetch(:aws_secret_access_key)}.merge! fetch(:aws_params, {}))
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
@ec2.instances.filter('tag-key', 'deploy').filter('tag-value', which).each do |instance|
|
16
|
+
server instance.ip_address || instance.private_ip_address, *args if instance.status == :running
|
17
|
+
end
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
19
21
|
end
|
20
|
-
|
21
|
-
include Tags
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
if Capistrano::Configuration.instance
|
26
|
+
Capistrano::Ec2tag.extend(Capistrano::Configuration.instance)
|
27
|
+
end
|
28
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ec2tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Douglas Jarquin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.15.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.15.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,11 +50,12 @@ files:
|
|
50
50
|
- .gitignore
|
51
51
|
- Gemfile
|
52
52
|
- LICENSE
|
53
|
-
- README.
|
53
|
+
- README.md
|
54
54
|
- Rakefile
|
55
55
|
- capistrano-ec2tag.gemspec
|
56
56
|
- lib/capistrano-ec2tag.rb
|
57
57
|
- lib/capistrano/ec2tag.rb
|
58
|
+
- lib/capistrano/ec2tag/version.rb
|
58
59
|
homepage: https://github.com/douglasjarquin/capistrano-ec2tag
|
59
60
|
licenses: []
|
60
61
|
metadata: {}
|
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
version: '0'
|
75
76
|
requirements: []
|
76
77
|
rubyforge_project: capistrano-ec2tag
|
77
|
-
rubygems_version: 2.0.
|
78
|
+
rubygems_version: 2.0.6
|
78
79
|
signing_key:
|
79
80
|
specification_version: 4
|
80
81
|
summary: A Capistrano plugin aimed at easing the pain of deploying to Amazon EC2 instances.
|
data/README.markdown
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
## Introduction
|
2
|
-
|
3
|
-
capistrano-ec2tag is a [Capistrano](https://github.com/capistrano/capistrano) plugin designed to simplify the
|
4
|
-
task of deploying to infrastructure hosted on [Amazon EC2](http://aws.amazon.com/ec2/). It was
|
5
|
-
completely inspired by the [capistrano-ec2group](https://github.com/logandk/capistrano-ec2group) plugin, to which all credit is due.
|
6
|
-
|
7
|
-
While the original [capistrano-ec2group](https://github.com/logandk/capistrano-ec2group) plugin served me well, I started to run into limitations pretty quickly. I will say that at the time that the capistrano-ec2group plugin was written, I don't think Amazon EC2 supported tags yet.
|
8
|
-
|
9
|
-
Using Tags instead of Security Groups gives you the ability to change which servers get deployed to at any time, without having to reboot the instance. This implementation is particularly useful for A/B deployments, or in auto-scaling environments.
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
### Set the Amazon AWS Credentials
|
14
|
-
|
15
|
-
In order for the plugin to list out the hostnames of your EC2 instances, it
|
16
|
-
will need access to the Amazon EC2 API. Specify the following in your
|
17
|
-
Capistrano configuration:
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
set :aws_access_key_id, '...'
|
21
|
-
set :aws_secret_access_key, '...'
|
22
|
-
```
|
23
|
-
|
24
|
-
**Suggestion**
|
25
|
-
|
26
|
-
My preferred method of passing Amazon AWS credentials to the different tools is to use environment variables. A trick I picked up from the [Chef help site](http://help.opscode.com/discussions/questions/246-best-practices-for-multiple-developers-kniferb-in-chef-repo-or-not).
|
27
|
-
|
28
|
-
In my `~/.zshrc` I have:
|
29
|
-
|
30
|
-
|
31
|
-
```zsh
|
32
|
-
# aws credentials
|
33
|
-
export AWS_ACCESS_KEY_ID='...'
|
34
|
-
export AWS_SECRET_ACCESS_KEY='...'
|
35
|
-
```
|
36
|
-
|
37
|
-
Then, in a `~/.caprc` I do the following:
|
38
|
-
|
39
|
-
``` ruby
|
40
|
-
set :aws_access_key_id, ENV['AWS_ACCESS_KEY_ID']
|
41
|
-
set :aws_secret_access_key, ENV['AWS_SECRET_ACCESS_KEY']
|
42
|
-
```
|
43
|
-
|
44
|
-
### Get the gem
|
45
|
-
|
46
|
-
The plugin is distributed as a Ruby gem.
|
47
|
-
|
48
|
-
**Ruby Gems**
|
49
|
-
|
50
|
-
```bash
|
51
|
-
gem install capistrano-ec2tag
|
52
|
-
```
|
53
|
-
|
54
|
-
**Bundler**
|
55
|
-
|
56
|
-
Using [bundler](http://gembundler.com/)?
|
57
|
-
|
58
|
-
``` ruby
|
59
|
-
source 'http://rubygems.org'
|
60
|
-
gem 'capistrano-ec2tag'
|
61
|
-
```
|
62
|
-
|
63
|
-
Install the gems in your manifest using:
|
64
|
-
|
65
|
-
``` bash
|
66
|
-
bundle install
|
67
|
-
```
|
68
|
-
|
69
|
-
## Usage
|
70
|
-
|
71
|
-
### Tag your instances
|
72
|
-
|
73
|
-
Using the Amazon EC2 API or the AWS Management Console, add a `deploy` tag to all the instances you want Capistrano to deploy to.
|
74
|
-
|
75
|
-
The value can be any string, but I do recommend it be both unique and easy to recognize. If you have used the [capistrano-ec2group](https://github.com/logandk/capistrano-ec2group), then this might be equal to whatever security group names you use.
|
76
|
-
|
77
|
-
Personally, we use the folowing convention:
|
78
|
-
|
79
|
-
```
|
80
|
-
APP-ENVIRONMENT
|
81
|
-
```
|
82
|
-
|
83
|
-
### Configure Capistrano
|
84
|
-
|
85
|
-
```ruby
|
86
|
-
require 'capistrano/ec2tag'
|
87
|
-
|
88
|
-
task :production do
|
89
|
-
tag 'github-production', :web
|
90
|
-
logger.info 'Deploying to the PRODUCTION environment!'
|
91
|
-
end
|
92
|
-
|
93
|
-
task :staging do
|
94
|
-
tag 'github-staging', :web
|
95
|
-
logger.info 'Deploying to the STAGING environment!'
|
96
|
-
end
|
97
|
-
```
|
98
|
-
|
99
|
-
## License
|
100
|
-
|
101
|
-
capistrano-ec2tag is copyright 2013 by [Douglas Jarquin](http://douglasjarquin.com/), released under the MIT License (see LICENSE for details).
|