capistrano-ec2group 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +71 -0
- data/Rakefile +23 -0
- data/lib/capistrano/ec2group.rb +30 -0
- data/test/ec2group_test.rb +18 -0
- metadata +77 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Logan Raarup
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
capistrano-ec2group
|
2
|
+
=================================================
|
3
|
+
|
4
|
+
Capistrano plugin for deploying to Amazon EC2 instances by security groups.
|
5
|
+
|
6
|
+
|
7
|
+
Introduction
|
8
|
+
============
|
9
|
+
|
10
|
+
This plugin supports the deployment strategy of using the *security groups* feature of Amazon EC2. If you are using
|
11
|
+
auto-scaling of instances, new hostnames will be added and removed regularly, causing problems when you have to specify
|
12
|
+
your servers hostnames in your Capistrano recipes.
|
13
|
+
|
14
|
+
By using *security groups* to organize your instances by roles, you have created a simple database of instances that is
|
15
|
+
automatically updated as auto-scaling happens. By using a provisioning tool like Sprinkle, Moonshine, Chef, Puppet, Rubber
|
16
|
+
(etc.) to automatically configure instances upon launch (through EC2 `user-data`), you have a completely automated workflow for
|
17
|
+
configuring and deploying auto-scaling instances.
|
18
|
+
|
19
|
+
|
20
|
+
Installation
|
21
|
+
============
|
22
|
+
|
23
|
+
`capistrano-ec2group` is provided as a Ruby gem, with the following dependencies:
|
24
|
+
|
25
|
+
* Capistrano 2 gem
|
26
|
+
* RightAWS gem
|
27
|
+
|
28
|
+
You can install it with RubyGems:
|
29
|
+
|
30
|
+
$ gem sources -a http://gems.github.com (you only have to do this once)
|
31
|
+
$ gem install logandk-capistrano-ec2group
|
32
|
+
|
33
|
+
|
34
|
+
Usage
|
35
|
+
=====
|
36
|
+
|
37
|
+
In order to use the `capistrano-ec2group` plugin, you must require it in your `deploy.rb`:
|
38
|
+
|
39
|
+
require 'capistrano/ec2group'
|
40
|
+
|
41
|
+
Then you must specify your Amazon EC2 credentials:
|
42
|
+
|
43
|
+
set :aws_access_key_id, '???'
|
44
|
+
set :aws_secret_access_key, '???'
|
45
|
+
|
46
|
+
Optionally setting additional parameters, such as the region:
|
47
|
+
|
48
|
+
set :aws_params, :region => 'eu-west-1'
|
49
|
+
|
50
|
+
In order to define your instance groups, you must specify the security group name, the roles and params:
|
51
|
+
|
52
|
+
group :webserver, :web
|
53
|
+
group :app_myappname, :app
|
54
|
+
group :lamp, :web, :app
|
55
|
+
group "MySQL Servers", :db, :port => 22000
|
56
|
+
|
57
|
+
Then just sit back, relax and `cap deploy`!
|
58
|
+
|
59
|
+
|
60
|
+
Documentation
|
61
|
+
=============
|
62
|
+
Additional RDoc documentation is available at: [http://rdoc.info/projects/logandk/capistrano-ec2group](http://rdoc.info/projects/logandk/capistrano-ec2group)
|
63
|
+
|
64
|
+
|
65
|
+
Credits
|
66
|
+
=======
|
67
|
+
* Capistrano: [http://github.com/jamis/capistrano](http://github.com/jamis/capistrano)
|
68
|
+
* RightAws: [http://rightaws.rubyforge.org](http://rightaws.rubyforge.org)
|
69
|
+
* Amazon AWS: [http://aws.amazon.com](http://aws.amazon.com)
|
70
|
+
|
71
|
+
Copyright (c) 2009 Logan Raarup, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the capistrano-ec2group plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the capistrano-ec2group plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'capistrano-ec2group'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README.markdown')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'right_aws'
|
2
|
+
|
3
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
4
|
+
abort "capistrano/ec2group requires Capistrano 2"
|
5
|
+
end
|
6
|
+
|
7
|
+
module Capistrano
|
8
|
+
class Configuration
|
9
|
+
module Groups
|
10
|
+
# Associate a group of EC2 instances with a role. In order to use this, you
|
11
|
+
# must use the security groups feature in Amazon EC2 to group your servers
|
12
|
+
# by role.
|
13
|
+
#
|
14
|
+
# First, specify the security group name, then the roles and params:
|
15
|
+
#
|
16
|
+
# group :webserver, :web
|
17
|
+
# group :app_myappname, :app
|
18
|
+
# group "MySQL Servers", :db, :port => 22000
|
19
|
+
def group(which, *args)
|
20
|
+
@ec2_api ||= RightAws::Ec2.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key), fetch(:aws_params, {}))
|
21
|
+
|
22
|
+
@ec2_api.describe_instances.each do |instance|
|
23
|
+
server(instance[:dns_name], *args) if instance[:aws_groups].include?(which.to_s)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
include Groups
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'yaml'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
|
5
|
+
class CapistranoTest < Test::Unit::TestCase
|
6
|
+
def test_build_gem
|
7
|
+
data = File.read(File.join(File.dirname(__FILE__), '..', 'capistrano-ec2group.gemspec'))
|
8
|
+
spec = nil
|
9
|
+
|
10
|
+
if data !~ %r{!ruby/object:Gem::Specification}
|
11
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
12
|
+
else
|
13
|
+
spec = YAML.load(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
assert spec.validate
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-ec2group
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Logan Raarup
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-19 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: capistrano
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: right_aws
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description:
|
36
|
+
email: logan@logan.dk
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- MIT-LICENSE
|
45
|
+
- Rakefile
|
46
|
+
- README.markdown
|
47
|
+
- lib/capistrano/ec2group.rb
|
48
|
+
- test/ec2group_test.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/logandk/capistrano-ec2group
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --line-numbers
|
54
|
+
- --inline-source
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: capistrano-ec2g
|
72
|
+
rubygems_version: 1.3.1
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: Capistrano plugin for deploying to Amazon EC2 instances by security groups.
|
76
|
+
test_files: []
|
77
|
+
|