capistrano-ec2tag 0.0.2 → 0.0.3
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.
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.markdown +24 -18
- data/Rakefile +1 -1
- data/capistrano-ec2tag.gemspec +12 -12
- data/lib/capistrano-ec2tag.rb +1 -1
- data/lib/capistrano/ec2tag.rb +3 -3
- metadata +20 -10
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
# capistrano-ec2tag
|
2
|
-
|
3
|
-
A Capistrano plugin aimed at easing the pain of deploying to Amazon EC2
|
4
|
-
instances by using a simple "deploy" tag.
|
5
|
-
|
6
1
|
## Introduction
|
7
2
|
|
8
3
|
capistrano-ec2tag is a [Capistrano](https://github.com/capistrano/capistrano) plugin designed to simplify the
|
@@ -11,11 +6,16 @@ completely inspired by the [capistrano-ec2group](https://github.com/logandk/capi
|
|
11
6
|
|
12
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.
|
13
8
|
|
9
|
+
Using Tags instead of Security Groups gives you the ability to change
|
10
|
+
which servers get deployed to at any time, without having to reboot the
|
11
|
+
instance. This implementation is particularly useful for A/B deployments, or in
|
12
|
+
auto-scaling environments.
|
13
|
+
|
14
14
|
## Installation
|
15
15
|
|
16
16
|
### Set the Amazon AWS Credentials
|
17
17
|
|
18
|
-
In order for the plugin to list out hostnames of your EC2 instances, it
|
18
|
+
In order for the plugin to list out the hostnames of your EC2 instances, it
|
19
19
|
will need access to the Amazon EC2 API. Specify the following in your
|
20
20
|
Capistrano configuration:
|
21
21
|
|
@@ -30,7 +30,7 @@ My prefferred method of passing Amazon AWS credentials to the different
|
|
30
30
|
tools is to use environment variables. A trick I picked up from the [Chef
|
31
31
|
help site](http://help.opscode.com/discussions/questions/246-best-practices-for-multiple-developers-kniferb-in-chef-repo-or-not).
|
32
32
|
|
33
|
-
In my
|
33
|
+
In my `~/.zshrc` I have:
|
34
34
|
|
35
35
|
```zsh
|
36
36
|
# Set the Amazon AWS credentials as environment variables
|
@@ -38,7 +38,7 @@ export AWS_ACCESS_KEY_ID='...'
|
|
38
38
|
export AWS_SECRET_ACCESS_KEY='...'
|
39
39
|
```
|
40
40
|
|
41
|
-
Then, in
|
41
|
+
Then, in a `~/.caprc` I do the following:
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
set :aws_access_key_id, $AWS_ACCESS_KEY_ID
|
@@ -66,8 +66,8 @@ gem install bundler
|
|
66
66
|
Then add the following to your Gemfile:
|
67
67
|
|
68
68
|
```ruby
|
69
|
-
source
|
70
|
-
gem
|
69
|
+
source 'http://rubygems.org'
|
70
|
+
gem 'capistrano-ec2tag'
|
71
71
|
```
|
72
72
|
|
73
73
|
Install the gems in your manifest using:
|
@@ -84,7 +84,13 @@ Using the Amazon EC2 API or the AWS Management Console, add a `deploy`
|
|
84
84
|
tag to all the instances you want Capistrano to deploy to.
|
85
85
|
|
86
86
|
The value can be any string, but I do recommend it be both unique and
|
87
|
-
|
87
|
+
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.
|
88
|
+
|
89
|
+
Personally, we use the folowing convention:
|
90
|
+
|
91
|
+
```
|
92
|
+
ENVIRONMENT-APP-STACK
|
93
|
+
```
|
88
94
|
|
89
95
|
### Configure Capistrano
|
90
96
|
|
@@ -92,19 +98,19 @@ somehow explicit to the type of server this is. If you have used the [capistrano
|
|
92
98
|
require 'capistrano/ec2tag'
|
93
99
|
|
94
100
|
task :production do
|
95
|
-
tag
|
96
|
-
tag
|
97
|
-
logger.info
|
101
|
+
tag 'production-github-web', :web
|
102
|
+
tag 'production-github-job', :job
|
103
|
+
logger.info 'Deploying to the PRODUCTION environment!'
|
98
104
|
end
|
99
105
|
|
100
106
|
task :staging do
|
101
|
-
tag
|
102
|
-
tag
|
103
|
-
logger.info
|
107
|
+
tag 'staging-github-web', :web
|
108
|
+
tag 'staging-github-job', :job
|
109
|
+
logger.info 'Deploying to the STAGING environment!'
|
104
110
|
end
|
105
111
|
```
|
106
112
|
|
107
113
|
## License
|
108
114
|
|
109
|
-
capistrano-ec2tag is copyright
|
115
|
+
capistrano-ec2tag is copyright 2012 by [Douglas Jarquin](http://douglasjarquin.com/), released under the MIT License (see LICENSE for details).
|
110
116
|
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/capistrano-ec2tag.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
6
|
-
s.version =
|
7
|
-
s.authors = [
|
8
|
-
s.email = [
|
9
|
-
s.homepage =
|
10
|
-
s.summary =
|
11
|
-
s.description =
|
5
|
+
s.name = 'capistrano-ec2tag'
|
6
|
+
s.version = '0.0.3'
|
7
|
+
s.authors = ['Douglas Jarquin']
|
8
|
+
s.email = ['douglasjarquin@me.com']
|
9
|
+
s.homepage = 'https://github.com/douglasjarquin/capistrano-ec2tag'
|
10
|
+
s.summary = 'A Capistrano plugin aimed at easing the pain of deploying to Amazon EC2 instances.'
|
11
|
+
s.description = 'capistrano-ec2tag 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 plugin, to which all credit is due.'
|
12
12
|
|
13
|
-
s.rubyforge_project =
|
13
|
+
s.rubyforge_project = 'capistrano-ec2tag'
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
-
s.require_paths = [
|
18
|
+
s.require_paths = ['lib']
|
19
19
|
|
20
|
-
s.add_dependency
|
21
|
-
s.add_dependency
|
20
|
+
s.add_dependency 'capistrano', '>=2.1.0'
|
21
|
+
s.add_dependency 'right_aws'
|
22
22
|
end
|
data/lib/capistrano-ec2tag.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'capistrano/ec2tag'
|
data/lib/capistrano/ec2tag.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'right_aws'
|
2
2
|
|
3
3
|
unless Capistrano::Configuration.respond_to?(:instance)
|
4
|
-
abort
|
4
|
+
abort 'capistrano/ec2tag requires Capistrano >= 2'
|
5
5
|
end
|
6
6
|
|
7
7
|
module Capistrano
|
@@ -11,8 +11,8 @@ module Capistrano
|
|
11
11
|
def tag(which, *args)
|
12
12
|
@ec2 ||= RightAws::Ec2.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key), fetch(:aws_params, {}))
|
13
13
|
|
14
|
-
@ec2.describe_instances(:filters => {
|
15
|
-
server(instance[:dns_name], *args) unless instance[:aws_state] !=
|
14
|
+
@ec2.describe_instances(:filters => { 'tag-key' => 'deploy', 'tag-value' => "#{which}" }).each do |instance|
|
15
|
+
server(instance[:dns_name].empty? ? instance[:ip_address] : instance[:dns_name], *args) unless instance[:aws_state] != 'running'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-ec2tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 2.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: right_aws
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,12 +37,17 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
description: capistrano-ec2tag is a Capistrano plugin designed to simplify the task
|
37
47
|
of deploying to infrastructure hosted on Amazon EC2. It was completely inspired
|
38
48
|
by the capistrano-ec2group plugin, to which all credit is due.
|
39
49
|
email:
|
40
|
-
- douglasjarquin@
|
50
|
+
- douglasjarquin@me.com
|
41
51
|
executables: []
|
42
52
|
extensions: []
|
43
53
|
extra_rdoc_files: []
|
@@ -70,9 +80,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
80
|
version: '0'
|
71
81
|
requirements: []
|
72
82
|
rubyforge_project: capistrano-ec2tag
|
73
|
-
rubygems_version: 1.8.
|
83
|
+
rubygems_version: 1.8.24
|
74
84
|
signing_key:
|
75
85
|
specification_version: 3
|
76
|
-
summary: A Capistrano plugin aimed at easing the pain of deploying to Amazon EC2 instances
|
77
|
-
by using a simple "deploy" tag.
|
86
|
+
summary: A Capistrano plugin aimed at easing the pain of deploying to Amazon EC2 instances.
|
78
87
|
test_files: []
|
88
|
+
has_rdoc:
|