rig 0.3.7 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/conf/accounts/default.yml +6 -0
- data/conf/config.yml +32 -50
- data/conf/templates/multi.yml +13 -3
- data/conf/templates/solo.yml +3 -7
- data/lib/rig/capistrano.rb +4 -9
- data/lib/rig/chef.rb +1 -1
- data/lib/rig/command.rb +1 -0
- data/lib/rig/command/abstract.rb +2 -2
- data/lib/rig/command/account.rb +5 -5
- data/lib/rig/command/balancer/listener.rb +31 -0
- data/lib/rig/command/config.rb +2 -2
- data/lib/rig/command/environment/create.rb +0 -2
- data/lib/rig/command/instance/create.rb +1 -9
- data/lib/rig/command/instance/destroy.rb +0 -1
- data/lib/rig/command/instance/tag/get.rb +0 -1
- data/lib/rig/command/instance/tag/remove.rb +1 -1
- data/lib/rig/command/instance/tag/set.rb +0 -1
- data/lib/rig/command/main.rb +1 -1
- data/lib/rig/command/options.rb +0 -64
- data/lib/rig/command/ssh.rb +1 -1
- data/lib/rig/config.rb +7 -7
- data/lib/rig/model/account.rb +2 -2
- data/lib/rig/model/balancer.rb +47 -16
- data/lib/rig/model/connection.rb +4 -4
- data/lib/rig/model/environment.rb +10 -39
- data/lib/rig/model/instance.rb +1 -1
- data/lib/rig/version.rb +2 -2
- data/rig.gemspec +0 -2
- metadata +7 -6
data/conf/accounts/default.yml
CHANGED
@@ -13,6 +13,12 @@ dns_zone: blah.com
|
|
13
13
|
# this is the key that you will use to SSH to the server
|
14
14
|
keypair: keyname
|
15
15
|
|
16
|
+
# security groups to use when creating instances
|
17
|
+
# groups configuration precedence:
|
18
|
+
# template instances -> template -> account -> config
|
19
|
+
# groups:
|
20
|
+
# - default
|
21
|
+
|
16
22
|
# Common settings.
|
17
23
|
# In most cases, you will be using the same provider
|
18
24
|
# for all of the different components within your
|
data/conf/config.yml
CHANGED
@@ -1,50 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
ssh
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# the default region to use
|
34
|
-
# accounts can specify different regions
|
35
|
-
# meaning you can have a different rig account
|
36
|
-
# file for each deployment region
|
37
|
-
region: us-east-1
|
38
|
-
|
39
|
-
# AWS images (AMI's) are different per region
|
40
|
-
# for ubuntu, go to: http://cloud.ubuntu.com/ami/
|
41
|
-
image:
|
42
|
-
us-east-1: ami-8baa73e2 # ubuntu 11.10, non-ebs storage
|
43
|
-
|
44
|
-
# this is the key that you will use to SSH to the server
|
45
|
-
# keypair in account takes precedence
|
46
|
-
keypair: keyname
|
47
|
-
|
48
|
-
# specifying a flavor here will force all instances to
|
49
|
-
# be that flavor, overrides flavor in template
|
50
|
-
#flavor: m1.large
|
1
|
+
# the account to use if one is not specified on the command line
|
2
|
+
:default_account: default
|
3
|
+
|
4
|
+
# uncomment this and specify the accounts you want to support
|
5
|
+
# all others will be filtered from use.
|
6
|
+
#:accounts:
|
7
|
+
# - default
|
8
|
+
# - production
|
9
|
+
|
10
|
+
# ssh options for "rig ssh" command
|
11
|
+
:ssh:
|
12
|
+
# user to connect as, when ssh'ing to server
|
13
|
+
# AWS defaults to the user "ubuntu"
|
14
|
+
:user: ubuntu
|
15
|
+
|
16
|
+
# if you're using chef, set this to the knife.rb configuration file
|
17
|
+
# this will allow Rig to manage the chef nodes, environments, etc.
|
18
|
+
#
|
19
|
+
#:chef:
|
20
|
+
# :knife: /path/to/chef/knife.rb
|
21
|
+
|
22
|
+
#TODO: Figure out the same thing for puppet
|
23
|
+
|
24
|
+
#
|
25
|
+
# DO NOT PUT ACCOUNT RELATED INFORMATION
|
26
|
+
# IN THIS FILE. IT WILL BE IGNORED.
|
27
|
+
#
|
28
|
+
# This file contains only Rig configuration.
|
29
|
+
# Anything related to cloud accounts and
|
30
|
+
# provisioning should be stored in the accounts
|
31
|
+
# configuration files.
|
32
|
+
#
|
data/conf/templates/multi.yml
CHANGED
@@ -7,10 +7,20 @@
|
|
7
7
|
:count: 3
|
8
8
|
:flavor: c1.large
|
9
9
|
:balance: true
|
10
|
+
:listeners:
|
11
|
+
- :from: HTTP:80
|
12
|
+
:to: HTTP:80
|
13
|
+
- :from: HTTPS:443
|
14
|
+
:to: HTTP:80
|
15
|
+
:cert: arn:cert:name
|
10
16
|
:webserver:
|
11
17
|
:count: 3
|
12
18
|
:flavor: c1.large
|
13
19
|
:balance: true
|
14
|
-
:
|
15
|
-
:
|
16
|
-
|
20
|
+
:listeners:
|
21
|
+
- :from: HTTP:80
|
22
|
+
:to: HTTP:80
|
23
|
+
- :from: HTTPS:443
|
24
|
+
:to: HTTP:80
|
25
|
+
:cert: arn:cert:name
|
26
|
+
:primary: true
|
data/conf/templates/solo.yml
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
---
|
2
2
|
:instances:
|
3
|
-
- :
|
3
|
+
- :appserver:
|
4
4
|
:count: 1
|
5
5
|
:flavor: c1.medium
|
6
6
|
:balance: true
|
7
|
-
|
8
|
-
#{"ListenerDescriptions"=>[{"PolicyNames"=>[], "Listener"=>{"InstancePort"=>80, "SSLCertificateId"=>nil, "Protocol"=>"HTTP", "LoadBalancerPort"=>80, "InstanceProtocol"=>"HTTP"}}]}
|
7
|
+
:primary: true
|
9
8
|
:listeners:
|
10
9
|
- :from: HTTP:80
|
11
10
|
:to: HTTP:80
|
12
11
|
- :from: HTTPS:443
|
13
12
|
:to: HTTP:80
|
14
|
-
:cert:
|
15
|
-
:primary: true
|
16
|
-
:groups:
|
17
|
-
- default
|
13
|
+
:cert: arn:cert:name
|
data/lib/rig/capistrano.rb
CHANGED
@@ -9,8 +9,8 @@ require 'capistrano'
|
|
9
9
|
module Rig
|
10
10
|
module Capistrano
|
11
11
|
def servers
|
12
|
-
env = ENV['ENVIRONMENT'] || Rig.config
|
13
|
-
role = ENV['ROLE'] || Rig.config
|
12
|
+
env = ENV['ENVIRONMENT'] || Rig.config[:environment]
|
13
|
+
role = ENV['ROLE'] || Rig.config[:role]
|
14
14
|
servers = Rig::Model::Environment.find(env).servers
|
15
15
|
list = role == 'all' ? servers : servers.select { |s| s.tags['Role'] == role }
|
16
16
|
|
@@ -31,15 +31,10 @@ configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
|
31
31
|
Capistrano.configuration(:must_exist)
|
32
32
|
|
33
33
|
configuration.load do
|
34
|
-
|
35
34
|
puts " * reading rig information..."
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
set :rigroles, servers.collect { |s| s.tags['Role'] }.compact
|
40
|
-
|
41
|
-
Rig.config.environment = ARGV[0]
|
42
|
-
Rig.config.role = ARGV[1]
|
36
|
+
Rig.config[:environment] = ARGV[0]
|
37
|
+
Rig.config[:role] = ARGV[1]
|
43
38
|
|
44
39
|
# create dummy tasks for environment and role
|
45
40
|
begin
|
data/lib/rig/chef.rb
CHANGED
@@ -10,7 +10,7 @@ module Rig
|
|
10
10
|
module Chef
|
11
11
|
class << self
|
12
12
|
def configure
|
13
|
-
@chef ||= ::Chef::Config.from_file(File.expand_path(Rig.config
|
13
|
+
@chef ||= ::Chef::Config.from_file(File.expand_path(Rig.config[:chef][:knife]))
|
14
14
|
end
|
15
15
|
|
16
16
|
def environment_create(name)
|
data/lib/rig/command.rb
CHANGED
@@ -23,6 +23,7 @@ require 'rig/command/balancer/main'
|
|
23
23
|
require 'rig/command/balancer/list'
|
24
24
|
require 'rig/command/balancer/view'
|
25
25
|
require 'rig/command/balancer/destroy'
|
26
|
+
require 'rig/command/balancer/listener'
|
26
27
|
|
27
28
|
require 'rig/command/dns/main'
|
28
29
|
require 'rig/command/dns/list'
|
data/lib/rig/command/abstract.rb
CHANGED
@@ -4,12 +4,12 @@ module Rig
|
|
4
4
|
module Command
|
5
5
|
class Abstract < Clamp::Command
|
6
6
|
option ["-n", "--test"], :flag, "use Fog.mock! to test command without creating / destroying cloud resources" do |o|
|
7
|
-
Rig.config
|
7
|
+
Rig.config[:mock] = true
|
8
8
|
Fog.mock!
|
9
9
|
end
|
10
10
|
|
11
11
|
option ["-a", "--account"], "ACCOUNT", "set the rig account to use", :default => "default" do |a|
|
12
|
-
Rig.config
|
12
|
+
Rig.config[:account] = a
|
13
13
|
a
|
14
14
|
end
|
15
15
|
|
data/lib/rig/command/account.rb
CHANGED
@@ -6,7 +6,7 @@ module Rig
|
|
6
6
|
list = Rig::Model::Account.list
|
7
7
|
rows = []
|
8
8
|
list.each do |n, f|
|
9
|
-
rows << [(Rig.config
|
9
|
+
rows << [(Rig.config[:default_account] == n.to_s), (Rig.account[:name] == n.to_s), n, f]
|
10
10
|
end
|
11
11
|
print_table(%w{Default Current Name Location}, rows)
|
12
12
|
end
|
@@ -20,16 +20,16 @@ module Rig
|
|
20
20
|
# def execute
|
21
21
|
# case property
|
22
22
|
# when "awsid"
|
23
|
-
# Rig.account
|
23
|
+
# Rig.account[:common][:aws_access_key_id] = value
|
24
24
|
# Rig.save_account
|
25
25
|
# when "awskey"
|
26
|
-
# Rig.account
|
26
|
+
# Rig.account[:common][:aws_secret_access_key] = value
|
27
27
|
# Rig.save_account
|
28
28
|
# when "dnszone"
|
29
|
-
# Rig.account
|
29
|
+
# Rig.account[:dns_zone] = value
|
30
30
|
# Rig.save_account
|
31
31
|
# when "region"
|
32
|
-
# Rig.account
|
32
|
+
# Rig.account[:region] = value
|
33
33
|
# Rig.save_account
|
34
34
|
# else
|
35
35
|
# puts "Property #{property} not supported"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Rig
|
2
|
+
module Command
|
3
|
+
module Listener
|
4
|
+
class Main < Abstract
|
5
|
+
subcommand "add", "add a listener to a balancer" do
|
6
|
+
parameter "BALANCER", "balancer name"
|
7
|
+
parameter "LISTENER", "listener data PROTO:PORT/PROTO:PORT"
|
8
|
+
parameter "[CERT]", "arn for server certificate"
|
9
|
+
parameter "[POLICY] ...", "policy names"
|
10
|
+
|
11
|
+
def execute
|
12
|
+
(from, to) = listener.split('/')
|
13
|
+
#newlist = elb.listeners.create()
|
14
|
+
Rig::Model::Balancer.add_listener(balancer, from, to, cert, policy_list)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
subcommand "rm", "remove a listener from a balancer" do
|
19
|
+
parameter "BALANCER", "balancer name"
|
20
|
+
parameter "LISTENER", "listener data PROTO:PORT (just the elb side)"
|
21
|
+
|
22
|
+
def execute
|
23
|
+
Rig::Model::Balancer.destroy_listener(balancer, listener)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Rig::Command::Balancer::Main.subcommand "listener", "manage balancer listeners (protocols and ports", Rig::Command::Listener::Main
|
data/lib/rig/command/config.rb
CHANGED
@@ -8,10 +8,10 @@ module Rig
|
|
8
8
|
def execute
|
9
9
|
case property
|
10
10
|
when "knife"
|
11
|
-
Rig.config
|
11
|
+
Rig.config[:chef][:knife] = value
|
12
12
|
Rig.save_configuration
|
13
13
|
when "user"
|
14
|
-
Rig.config
|
14
|
+
Rig.config[:ssh][:user] = value
|
15
15
|
Rig.save_configuration
|
16
16
|
else
|
17
17
|
puts "Property #{property} not supported"
|
@@ -5,8 +5,6 @@ module Rig
|
|
5
5
|
module Command
|
6
6
|
module Environment
|
7
7
|
class Create < Abstract
|
8
|
-
include Options::AwsKey
|
9
|
-
include Options::AwsSecret
|
10
8
|
|
11
9
|
parameter "NAME", "the name of the environment"
|
12
10
|
parameter "TEMPLATE", "the template to use (solo, multi, etc)", :default => "solo"
|
@@ -4,20 +4,12 @@ module Rig
|
|
4
4
|
module Command
|
5
5
|
module Instance
|
6
6
|
class Create < Abstract
|
7
|
-
include Options::Config
|
8
7
|
|
9
|
-
include Options::AwsKey
|
10
|
-
include Options::AwsSecret
|
11
|
-
include Options::AwsRegion
|
12
|
-
include Options::AwsAmi
|
13
|
-
include Options::AwsKeypair
|
14
|
-
|
15
|
-
parameter "CLUSTER", "the cluster this instance should belong to"
|
16
8
|
parameter "ENVIRONMENT", "the environment this instance should belong to"
|
17
9
|
parameter "ROLE", "the instance role", :default => 'solo'
|
18
10
|
|
19
11
|
def execute
|
20
|
-
puts "create:
|
12
|
+
puts "create: env:#{environment} role:#{role}"
|
21
13
|
end
|
22
14
|
end
|
23
15
|
end
|
@@ -4,12 +4,12 @@ module Rig
|
|
4
4
|
module Instance
|
5
5
|
module Tag
|
6
6
|
class Remove < Abstract
|
7
|
-
include Options::Config
|
8
7
|
include Options::Instance
|
9
8
|
include Options::InstanceName
|
10
9
|
|
11
10
|
parameter "TAG", "tag key to remove", :attribute_name => :raw_tag
|
12
11
|
|
12
|
+
# TODO: fix this to use Model instead
|
13
13
|
def execute
|
14
14
|
unless iname || iid
|
15
15
|
raise "Must set either instance name or instance id (-iname or -iid)"
|
data/lib/rig/command/main.rb
CHANGED
data/lib/rig/command/options.rb
CHANGED
@@ -5,70 +5,6 @@ module Rig
|
|
5
5
|
module Command
|
6
6
|
module Options
|
7
7
|
|
8
|
-
module Config
|
9
|
-
#def self.included(base)
|
10
|
-
# base.class_eval do
|
11
|
-
# option %w{-c --config}, "CONFIG", "configuration file" do |f|
|
12
|
-
# e = File.expand_path(f)
|
13
|
-
# raise "Config file #{f} (#{e}) does not exist" unless File.exists?(e)
|
14
|
-
# e
|
15
|
-
# end
|
16
|
-
# def default_config
|
17
|
-
# ENV['RIG_CONFIG'] || "~/.rig"
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
#end
|
21
|
-
end
|
22
|
-
|
23
|
-
module AwsKey
|
24
|
-
def self.included(base)
|
25
|
-
base.class_eval do
|
26
|
-
option %w{-k --key}, "KEY", "aws access key id"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module AwsSecret
|
32
|
-
def self.included(base)
|
33
|
-
base.class_eval do
|
34
|
-
option %w{-s --secret}, "SECRET", "aws secret access key"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
module AwsAmi
|
40
|
-
def self.included(base)
|
41
|
-
base.class_eval do
|
42
|
-
option %w{--ami}, "AMI", "aws ami id"
|
43
|
-
def default_ami
|
44
|
-
ENV['RIG_AWS_AMI'] || Rig.config.ami || nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
module AwsRegion
|
51
|
-
def self.included(base)
|
52
|
-
base.class_eval do
|
53
|
-
option %w{--region}, "AMI", "aws region"
|
54
|
-
def default_region
|
55
|
-
ENV['RIG_AWS_REGION'] || Rig.config.region || nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
module AwsKeypair
|
62
|
-
def self.included(base)
|
63
|
-
base.class_eval do
|
64
|
-
option %w{--keypair}, "KEYPAIR", "aws key pair name"
|
65
|
-
def default_keypair
|
66
|
-
ENV['RIG_AWS_KEYPAIR'] || Rig.config.keypair || nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
8
|
module Instance
|
73
9
|
def self.included(base)
|
74
10
|
base.class_eval do
|
data/lib/rig/command/ssh.rb
CHANGED
@@ -3,7 +3,7 @@ module Rig
|
|
3
3
|
class Ssh < Abstract
|
4
4
|
parameter "NAME", "name of the host. <role><#>.<env>, eg: solo1.stable for the first solo role in environment stable"
|
5
5
|
def execute
|
6
|
-
user = Rig.config
|
6
|
+
user = Rig.config[:ssh][:user] rescue nil
|
7
7
|
unless user
|
8
8
|
puts "must set rig:ssh:user in configuration."
|
9
9
|
exit(1)
|
data/lib/rig/config.rb
CHANGED
@@ -8,14 +8,14 @@ module Rig
|
|
8
8
|
|
9
9
|
def config
|
10
10
|
@configuration ||= begin
|
11
|
-
c =
|
11
|
+
c = YAML::load_file("#{configdir}/config.yml")
|
12
12
|
|
13
13
|
# prevent Chef and Capistrano being loaded at the same time
|
14
14
|
# requirements on net-ssh conflict (chef ~> 2.1.4)
|
15
15
|
#
|
16
16
|
# this makes it so we don't have to use bundler to run
|
17
17
|
# rig and cap together.
|
18
|
-
if c
|
18
|
+
if c[:chef] && !defined?(Rig::Capistrano)
|
19
19
|
require 'rig/chef'
|
20
20
|
end
|
21
21
|
|
@@ -36,13 +36,13 @@ module Rig
|
|
36
36
|
def account(name=get_account)
|
37
37
|
@account ||= begin
|
38
38
|
a = Rig::Model::Account.load(name)
|
39
|
-
a
|
39
|
+
a[:name] = name
|
40
40
|
a
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def save_account
|
45
|
-
name = Rig.account
|
45
|
+
name = Rig.account[:name]
|
46
46
|
Rig::Model::Account.save(name, Rig.account)
|
47
47
|
end
|
48
48
|
|
@@ -56,9 +56,9 @@ module Rig
|
|
56
56
|
|
57
57
|
def get_account
|
58
58
|
return ENV['RIG_ACCOUNT'] if ENV['RIG_ACCOUNT']
|
59
|
-
return Rig.config
|
60
|
-
return Rig.config
|
61
|
-
return Rig.config
|
59
|
+
return Rig.config[:account] if Rig.config[:account]
|
60
|
+
return Rig.config[:default_account] if Rig.config[:default_account]
|
61
|
+
return Rig.config[:accounts].first if Rig.config[:accounts] && Rig.config[:accounts].count > 0
|
62
62
|
"default"
|
63
63
|
end
|
64
64
|
|
data/lib/rig/model/account.rb
CHANGED
data/lib/rig/model/balancer.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'fog/aws/models/elb/listeners'
|
2
|
-
require 'fog/aws/models/elb/load_balancers'
|
3
1
|
require 'awesome_print'
|
4
2
|
|
5
3
|
module Rig
|
@@ -13,10 +11,10 @@ module Rig
|
|
13
11
|
def new(name, listeners=[])
|
14
12
|
listeners.map! do |listener|
|
15
13
|
ld = new_listener_description(listener)
|
16
|
-
ap ld
|
14
|
+
#ap ld
|
17
15
|
ld
|
18
16
|
end
|
19
|
-
ap listeners
|
17
|
+
#ap listeners
|
20
18
|
Rig::Connection.balancer.load_balancers.new({ :id => name, "ListenerDescriptions" => listeners })
|
21
19
|
end
|
22
20
|
|
@@ -44,27 +42,60 @@ module Rig
|
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
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] || []
|
45
|
+
def new_listener(from, to, cert=nil, policy_names=nil)
|
46
|
+
new_listener_description({ :from => from, :to => to, :cert => cert, :policy_names => policy_names })
|
47
|
+
end
|
55
48
|
|
56
|
-
|
49
|
+
def add_listener(name, from, to, cert, policy_list)
|
50
|
+
elb = find(name)
|
51
|
+
(from_proto, from_port) = from.split(':')
|
52
|
+
(to_proto, to_port) = to.split(':')
|
53
|
+
sslcert = cert || nil
|
54
|
+
policy_names = policy_list || []
|
55
|
+
new_listener = elb.listeners.new(
|
57
56
|
:policy_names => policy_names,
|
58
57
|
:instance_port => to_port,
|
59
58
|
:instance_protocol => to_proto,
|
60
59
|
:lb_port => from_port,
|
61
60
|
:protocol => from_proto,
|
62
|
-
:ssl_id => sslcert
|
61
|
+
:ssl_id => sslcert,
|
62
|
+
:load_balancer => elb
|
63
63
|
)
|
64
|
+
new_listener.save
|
65
|
+
end
|
66
|
+
|
67
|
+
def destroy_listener(name, from)
|
68
|
+
elb = find(name)
|
69
|
+
(from_proto, from_port) = from.split(':')
|
70
|
+
match = elb.listeners.select {|l| l.protocol == from_proto && l.lb_port == from_port.to_i }
|
71
|
+
if match.count > 1
|
72
|
+
puts "more than one listener matched"
|
73
|
+
match.each do |l|
|
74
|
+
ap l.attributes
|
75
|
+
end
|
76
|
+
return
|
77
|
+
end
|
78
|
+
match.first.destroy
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def new_listener_description(listener)
|
84
|
+
(from_proto, from_port) = listener[:from].split(/:/)
|
85
|
+
(to_proto, to_port) = listener[:to].split(/:/)
|
86
|
+
sslcert = listener[:cert] || nil
|
87
|
+
policy_names = listener[:policy_names] || []
|
64
88
|
|
65
89
|
{
|
66
|
-
'Listener'
|
67
|
-
|
90
|
+
'Listener' => {
|
91
|
+
"Protocol" => from_proto,
|
92
|
+
"LoadBalancerPort" => from_port,
|
93
|
+
"InstanceProtocol" => to_proto,
|
94
|
+
"InstancePort" => to_port,
|
95
|
+
"SSLCertificateId" => sslcert,
|
96
|
+
"PolicyNames" => policy_names
|
97
|
+
},
|
98
|
+
'PolicyNames' => policy_names
|
68
99
|
}
|
69
100
|
end
|
70
101
|
end
|
data/lib/rig/model/connection.rb
CHANGED
@@ -6,18 +6,18 @@ module Rig
|
|
6
6
|
class << self
|
7
7
|
def compute
|
8
8
|
@compute ||= begin
|
9
|
-
Fog::Compute.new(Rig.account
|
9
|
+
Fog::Compute.new(Rig.account[:compute])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
def balancer
|
13
13
|
@balancer ||= begin
|
14
|
-
#
|
15
|
-
Fog::AWS::ELB.new(Rig.account
|
14
|
+
#TODO: figure out the standardized way of handling balancers
|
15
|
+
Fog::AWS::ELB.new(Rig.account[:balancer])
|
16
16
|
end
|
17
17
|
end
|
18
18
|
def dns
|
19
19
|
@dns ||= begin
|
20
|
-
Fog::DNS.new(Rig.account
|
20
|
+
Fog::DNS.new(Rig.account[:dns])
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -10,29 +10,6 @@ module Rig
|
|
10
10
|
attr_reader :region
|
11
11
|
attr_reader :flavor
|
12
12
|
|
13
|
-
#TEMPLATES = {
|
14
|
-
# :solo => {
|
15
|
-
# :groups => %w{app-server db-inqcloud-dev},
|
16
|
-
# :instances => [
|
17
|
-
# :solo => {
|
18
|
-
# :flavor => 'c1.medium',
|
19
|
-
# :count => 1,
|
20
|
-
# :balance => true,
|
21
|
-
# :primary => true
|
22
|
-
# }
|
23
|
-
# ]
|
24
|
-
# },
|
25
|
-
# :multi => {
|
26
|
-
# :groups => %w{app-server db-inqcloud-dev},
|
27
|
-
# :instances => [
|
28
|
-
# :harvester => { :flavor => 'c1.large', :count => 3, :image => "ami-faketest" },
|
29
|
-
# :queue => { :flavor => 'c1.medium', :count => 3 },
|
30
|
-
# :cache => { :flavor => 'm1.medium', :count => 3 },
|
31
|
-
# :app => { :flavor => 'c1.large', :count => 3, :balance => true, :primary => true }
|
32
|
-
# ]
|
33
|
-
# }
|
34
|
-
#}
|
35
|
-
|
36
13
|
class << self
|
37
14
|
def list
|
38
15
|
filters = { }
|
@@ -69,16 +46,11 @@ module Rig
|
|
69
46
|
#TODO: overall, need better handling for global config, template and local overrides
|
70
47
|
def initialize(name, template=nil, opts={ })
|
71
48
|
@options = {
|
72
|
-
|
49
|
+
|
73
50
|
}.merge(opts)
|
74
51
|
|
75
52
|
@name = name
|
76
53
|
@template_name = template
|
77
|
-
#@region = @options[:region]
|
78
|
-
##TODO: allow global config setting for image (in AWS, the ami)
|
79
|
-
#@image = @options[:image] # || Rig.config.compute.image[@region] || Rig.config.compute.image
|
80
|
-
##TODO: allow global config setting for flavor (in AWS, the size, like: m1.large)
|
81
|
-
#@flavor = @options[:flavor] # || Rig.config.flavor[@region] || Rig.config.flavor
|
82
54
|
@servers = []
|
83
55
|
@balancers = []
|
84
56
|
end
|
@@ -97,7 +69,7 @@ module Rig
|
|
97
69
|
count = tmpl[:count] || 1
|
98
70
|
count.times do |i|
|
99
71
|
n = "#{role}#{i+1}.#{name}.env"
|
100
|
-
chef = Rig.config
|
72
|
+
chef = Rig.config[:chef] ? true : false
|
101
73
|
|
102
74
|
o = {
|
103
75
|
:image_id => tmpl[:image] || @image,
|
@@ -148,7 +120,7 @@ module Rig
|
|
148
120
|
end
|
149
121
|
|
150
122
|
# if we've got a chef config, use it
|
151
|
-
if Rig.config
|
123
|
+
if Rig.config[:chef]
|
152
124
|
puts "creating chef environment"
|
153
125
|
Rig::Chef.environment_create(name)
|
154
126
|
end
|
@@ -198,7 +170,7 @@ module Rig
|
|
198
170
|
puts "destroying balancers"
|
199
171
|
Rig::Model::Balancer.destroy(@balancers)
|
200
172
|
|
201
|
-
if Rig.config
|
173
|
+
if Rig.config[:chef]
|
202
174
|
puts "destroying chef environment"
|
203
175
|
Rig::Chef.environment_destroy(name)
|
204
176
|
end
|
@@ -218,23 +190,22 @@ module Rig
|
|
218
190
|
|
219
191
|
def load_config
|
220
192
|
@region = @options[:region] ||
|
221
|
-
Rig.
|
193
|
+
Rig.account[:region] ||
|
222
194
|
nil
|
223
195
|
@image = @options[:image] ||
|
224
|
-
Rig.account.image ||
|
225
|
-
Rig.config.image.kind_of?(Oconfig) ? Rig.config.image[@region] : Rig.config.image ||
|
196
|
+
Rig.account[:image].is_a?(Hash) ? Rig.account[:image][@region.to_sym] : Rig.account[:image] ||
|
226
197
|
nil
|
227
198
|
@flavor = @options[:flavor] ||
|
228
|
-
Rig.
|
199
|
+
Rig.account[:flavor] ||
|
229
200
|
nil
|
230
201
|
@zone = @options[:dns_zone] ||
|
231
|
-
Rig.
|
202
|
+
Rig.account[:dns_zone] ||
|
232
203
|
nil
|
233
204
|
@keypair = @options[:keypair] ||
|
234
|
-
Rig.
|
205
|
+
Rig.account[:keypair] ||
|
235
206
|
nil
|
236
207
|
@groups = @options[:groups] ||
|
237
|
-
Rig.
|
208
|
+
Rig.account[:groups] ||
|
238
209
|
nil
|
239
210
|
end
|
240
211
|
|
data/lib/rig/model/instance.rb
CHANGED
@@ -53,7 +53,7 @@ module Rig
|
|
53
53
|
puts ".. destroying: #{ids.inspect}"
|
54
54
|
|
55
55
|
# if we've got a chef config, use it
|
56
|
-
if Rig.config
|
56
|
+
if Rig.config[:chef]
|
57
57
|
list.each do |e|
|
58
58
|
Rig::Chef.client_delete(e.tags['Name']) if e.tags['Name']
|
59
59
|
Rig::Chef.node_delete(e.tags['Name']) if e.tags['Name']
|
data/lib/rig/version.rb
CHANGED
data/rig.gemspec
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: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
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-05-
|
18
|
+
date: 2012-05-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: clamp
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/rig/command/account.rb
|
130
130
|
- lib/rig/command/balancer/destroy.rb
|
131
131
|
- lib/rig/command/balancer/list.rb
|
132
|
+
- lib/rig/command/balancer/listener.rb
|
132
133
|
- lib/rig/command/balancer/main.rb
|
133
134
|
- lib/rig/command/balancer/view.rb
|
134
135
|
- lib/rig/command/config.rb
|
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
198
|
requirements: []
|
198
199
|
|
199
200
|
rubyforge_project:
|
200
|
-
rubygems_version: 1.8.
|
201
|
+
rubygems_version: 1.8.24
|
201
202
|
signing_key:
|
202
203
|
specification_version: 3
|
203
204
|
summary: Cloud provisioning tool built on ruby fog
|