rig 0.3.6 → 0.3.7
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 -0
- data/conf/templates/solo.yml +8 -0
- data/lib/rig/command/balancer/list.rb +6 -1
- data/lib/rig/model/balancer.rb +39 -6
- data/lib/rig/model/environment.rb +6 -5
- data/lib/rig/version.rb +1 -1
- metadata +4 -4
data/Gemfile
CHANGED
data/conf/templates/solo.yml
CHANGED
@@ -4,6 +4,14 @@
|
|
4
4
|
:count: 1
|
5
5
|
:flavor: c1.medium
|
6
6
|
:balance: true
|
7
|
+
#[{"PolicyNames"=>[], "Listener"=>{"InstancePort"=>80, "SSLCertificateId"=>nil, "Protocol"=>"HTTP", "LoadBalancerPort"=>80, "InstanceProtocol"=>"HTTP"}}]
|
8
|
+
#{"ListenerDescriptions"=>[{"PolicyNames"=>[], "Listener"=>{"InstancePort"=>80, "SSLCertificateId"=>nil, "Protocol"=>"HTTP", "LoadBalancerPort"=>80, "InstanceProtocol"=>"HTTP"}}]}
|
9
|
+
:listeners:
|
10
|
+
- :from: HTTP:80
|
11
|
+
:to: HTTP:80
|
12
|
+
- :from: HTTPS:443
|
13
|
+
:to: HTTP:80
|
14
|
+
:cert: inqlabs.com
|
7
15
|
:primary: true
|
8
16
|
:groups:
|
9
17
|
- default
|
@@ -8,8 +8,13 @@ module Rig
|
|
8
8
|
list = Rig::Model::Balancer.all
|
9
9
|
list.each do |lb|
|
10
10
|
puts lb.id
|
11
|
+
puts "- listeners"
|
12
|
+
lb.listeners.each do |l|
|
13
|
+
puts " - #{l.protocol}:#{l.lb_port} => #{l.instance_protocol}:#{l.instance_port}"
|
14
|
+
end
|
15
|
+
puts "- instances"
|
11
16
|
lb.instances.each do |inst|
|
12
|
-
puts "- #{inst}"
|
17
|
+
puts " - #{inst}"
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
data/lib/rig/model/balancer.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'fog/aws/models/elb/listeners'
|
2
|
+
require 'fog/aws/models/elb/load_balancers'
|
3
|
+
require 'awesome_print'
|
1
4
|
|
2
5
|
module Rig
|
3
6
|
module Model
|
@@ -7,12 +10,18 @@ module Rig
|
|
7
10
|
Rig::Connection.balancer.load_balancers.all
|
8
11
|
end
|
9
12
|
|
10
|
-
def new(name)
|
11
|
-
|
13
|
+
def new(name, listeners=[])
|
14
|
+
listeners.map! do |listener|
|
15
|
+
ld = new_listener_description(listener)
|
16
|
+
ap ld
|
17
|
+
ld
|
18
|
+
end
|
19
|
+
ap listeners
|
20
|
+
Rig::Connection.balancer.load_balancers.new({ :id => name, "ListenerDescriptions" => listeners })
|
12
21
|
end
|
13
22
|
|
14
|
-
def create(name)
|
15
|
-
b = self.new(name)
|
23
|
+
def create(name, listeners=[])
|
24
|
+
b = self.new(name, listeners)
|
16
25
|
b.save if b
|
17
26
|
puts ".. created: #{name}"
|
18
27
|
b
|
@@ -23,17 +32,41 @@ module Rig
|
|
23
32
|
end
|
24
33
|
|
25
34
|
def find_by_environment(name)
|
26
|
-
self.all.select {|e| e.id =~ /^#{name}/}
|
35
|
+
self.all.select { |e| e.id =~ /^#{name}/ }
|
27
36
|
end
|
28
37
|
|
29
38
|
def destroy(list)
|
30
39
|
list = [*list]
|
31
|
-
lbs
|
40
|
+
lbs = list.map { |e| e.kind_of?(String) ? self.find(e) : e }
|
32
41
|
lbs.each do |lb|
|
33
42
|
puts ".. destroying: #{lb.id}"
|
34
43
|
lb.destroy if lb
|
35
44
|
end
|
36
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def new_listener_description(listener)
|
50
|
+
desc = { }
|
51
|
+
(from_proto, from_port) = listener[:from].split(/:/)
|
52
|
+
(to_proto, to_port) = listener[:to].split(/:/)
|
53
|
+
sslcert = listener[:cert] || nil
|
54
|
+
policy_names = listener[:policy_names] || []
|
55
|
+
|
56
|
+
new_listener = Fog::AWS::ELB::Listener.new(
|
57
|
+
:policy_names => policy_names,
|
58
|
+
:instance_port => to_port,
|
59
|
+
:instance_protocol => to_proto,
|
60
|
+
:lb_port => from_port,
|
61
|
+
:protocol => from_proto,
|
62
|
+
:ssl_id => sslcert
|
63
|
+
)
|
64
|
+
|
65
|
+
{
|
66
|
+
'Listener' => new_listener.to_params,
|
67
|
+
'PolicyNames' => new_listener.policy_names
|
68
|
+
}
|
69
|
+
end
|
37
70
|
end
|
38
71
|
end
|
39
72
|
end
|
@@ -118,7 +118,7 @@ module Rig
|
|
118
118
|
|
119
119
|
if tmpl[:balance]
|
120
120
|
puts "creating balancer"
|
121
|
-
balancer = Rig::Model::Balancer.create("#{name}-#{role}")
|
121
|
+
balancer = Rig::Model::Balancer.create("#{name}-#{role}", tmpl[:listeners])
|
122
122
|
balancer.register_instances(setinstances.collect { |e| e.id })
|
123
123
|
balancer.save
|
124
124
|
|
@@ -138,14 +138,15 @@ module Rig
|
|
138
138
|
puts ".. primary: #{name}.env.#@zone #{balancer.attributes[:dns_name]}"
|
139
139
|
Rig::Model::Dns.create("#{name}.env.#@zone", balancer.attributes[:dns_name])
|
140
140
|
end
|
141
|
+
else
|
142
|
+
#TODO: handle no balancer, but primary - point to server instance
|
143
|
+
#if tmpl[:primary]
|
144
|
+
# puts ".. primary #{name}.env.#@zone #{}"
|
145
|
+
#end
|
141
146
|
end
|
142
147
|
end
|
143
148
|
end
|
144
149
|
|
145
|
-
#print "waiting"
|
146
|
-
#@servers.first.wait_for { print "."; attributes[:public_ip_address] }
|
147
|
-
#puts
|
148
|
-
|
149
150
|
# if we've got a chef config, use it
|
150
151
|
if Rig.config.chef
|
151
152
|
puts "creating chef environment"
|
data/lib/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 7
|
10
|
+
version: 0.3.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shawn Catanzarite
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-05-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: clamp
|