elbow 0.0.4 → 0.0.5
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/README.md +5 -1
- data/lib/elbow/capistrano_v2.rb +38 -0
- data/lib/elbow/version.rb +1 -1
- metadata +5 -4
data/README.md
CHANGED
@@ -6,7 +6,7 @@ In the cloud, your web instances are forever changing. This Gem allows you to de
|
|
6
6
|
your cap file that a host is using an ELB and it will detect the EC2 instances and deploy
|
7
7
|
your app to each of them.
|
8
8
|
|
9
|
-
** Version 0.0.4 and above
|
9
|
+
** Version 0.0.4 and above support Capistrano 3 **
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -28,6 +28,10 @@ In your `config/deploy/yourstage.rb`
|
|
28
28
|
|
29
29
|
require 'elbow/capistrano'
|
30
30
|
|
31
|
+
**Important** if you are using Capistrano version 2 then:
|
32
|
+
|
33
|
+
require 'elbow/capistrano_v2'
|
34
|
+
|
31
35
|
`elbow` requires your aws credentials, set them in your `config/deploy/yourstage.rb`
|
32
36
|
|
33
37
|
set :aws_access_key_id, 'YOUR_ACCESS_KEY_ID'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'net/dns'
|
3
|
+
|
4
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
5
|
+
|
6
|
+
def elastic_load_balancer(name, *args)
|
7
|
+
|
8
|
+
packet = Net::DNS::Resolver.start(name)
|
9
|
+
all_cnames= packet.answer.reject { |p| !p.instance_of? Net::DNS::RR::CNAME }
|
10
|
+
cname = all_cnames.find { |c| c.name == "#{name}."}.cname[0..-2]
|
11
|
+
|
12
|
+
aws_region= fetch(:aws_region, 'us-east-1')
|
13
|
+
AWS.config(:access_key_id => fetch(:aws_access_key_id),
|
14
|
+
:secret_access_key => fetch(:aws_secret_access_key),
|
15
|
+
:ec2_endpoint => "ec2.#{aws_region}.amazonaws.com",
|
16
|
+
:elb_endpoint => "elasticloadbalancing.#{aws_region}.amazonaws.com")
|
17
|
+
|
18
|
+
load_balancer = AWS::ELB.new.load_balancers.find { |elb| elb.dns_name.downcase == cname.downcase }
|
19
|
+
raise "EC2 Load Balancer not found for #{name} in region #{aws_region}" if load_balancer.nil?
|
20
|
+
|
21
|
+
hostnames = load_balancer.instances.collect do |instance|
|
22
|
+
hostname = instance.dns_name || instance.private_ip_address
|
23
|
+
end
|
24
|
+
|
25
|
+
if args.first.instance_of? Hash
|
26
|
+
options = args.first
|
27
|
+
if options.key?(:all)
|
28
|
+
hostnames.each { |h| server(h, *options[:all]) }
|
29
|
+
end
|
30
|
+
if options.key?(:first)
|
31
|
+
server(hostnames.first, options[:first])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
hostnames.each { |h| server(h, *args) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/elbow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elbow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- elbow.gemspec
|
59
59
|
- lib/elbow.rb
|
60
60
|
- lib/elbow/capistrano.rb
|
61
|
+
- lib/elbow/capistrano_v2.rb
|
61
62
|
- lib/elbow/version.rb
|
62
63
|
homepage: https://github.com/srbartlett/elbow
|
63
64
|
licenses:
|
@@ -74,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
75
|
version: '0'
|
75
76
|
segments:
|
76
77
|
- 0
|
77
|
-
hash:
|
78
|
+
hash: 1159005379921469876
|
78
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
80
|
none: false
|
80
81
|
requirements:
|
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
version: '0'
|
84
85
|
segments:
|
85
86
|
- 0
|
86
|
-
hash:
|
87
|
+
hash: 1159005379921469876
|
87
88
|
requirements: []
|
88
89
|
rubyforge_project:
|
89
90
|
rubygems_version: 1.8.23
|