rig 0.6.0 → 0.6.1
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/CHANGELOG.md +110 -0
- data/Gemfile +1 -0
- data/Rakefile +17 -4
- data/bin/rig +0 -10
- data/conf/plugins/chef.rb +6 -6
- data/conf/plugins/mongo.rb +1 -1
- data/lib/rig/config.rb +2 -2
- data/lib/rig/log.rb +11 -2
- data/lib/rig/model/account.rb +2 -2
- data/lib/rig/model/balancer.rb +4 -4
- data/lib/rig/model/dns.rb +2 -2
- data/lib/rig/model/environment.rb +9 -16
- data/lib/rig/model/instance.rb +6 -4
- data/lib/rig/version.rb +1 -1
- metadata +3 -2
data/CHANGELOG.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## v0.6.0:
|
4
|
+
* add changelog task
|
5
|
+
* fix smarter_templates merge conflict
|
6
|
+
* smarter templates:
|
7
|
+
* use a ruby dsl instead of yaml
|
8
|
+
* clean up environment handling of templates
|
9
|
+
* changes required for supporting new template framework
|
10
|
+
* remove old yaml template examples
|
11
|
+
* add a duo template as a basis for new multi-instance templates
|
12
|
+
|
13
|
+
## v0.5.2:
|
14
|
+
* fix bug with 'rig init', do not fail if config file does not exist
|
15
|
+
|
16
|
+
## v0.5.1:
|
17
|
+
* copy paste bug was causing commands not to load
|
18
|
+
|
19
|
+
## v0.5.0:
|
20
|
+
* refactor commands down to single class each
|
21
|
+
* refactor commands
|
22
|
+
* remove database command in favor of plugin
|
23
|
+
* clean up plugin framework and add support for commands
|
24
|
+
* clean up account and configuration handling
|
25
|
+
* clean up log configuration handling
|
26
|
+
* clean up chef and scout plugins
|
27
|
+
* tweaks for chef userdata package
|
28
|
+
* change name hooks -> plugins. cleaned up code. chef and scout plugins working. changed configuration to be part of the plugins configuration block, rather than a separate block.
|
29
|
+
* hook framework working. supports event hooks and adding commands to the CLI
|
30
|
+
* getting hooks set up
|
31
|
+
|
32
|
+
## v0.4.5:
|
33
|
+
* userdata refactor.
|
34
|
+
* userdata packages allow customization of userdata scripts
|
35
|
+
* default userdata shouldn't call apt-get upgrade
|
36
|
+
* availability zones should be shown in ouput. make sure balancers only add zones that have instances
|
37
|
+
* missed updating the accounts default file with example database info
|
38
|
+
|
39
|
+
## v0.4.4:
|
40
|
+
* rvm integration. add mongo support to CLI.
|
41
|
+
|
42
|
+
## v0.4.3:
|
43
|
+
* fix bug in Instance#find_by_nick
|
44
|
+
|
45
|
+
## v0.4.2:
|
46
|
+
* additional info in instance lists
|
47
|
+
* fixes for ruby 1.9.3
|
48
|
+
* balancer test command, should do something similar to the elb test script
|
49
|
+
* get 'instance create' command working
|
50
|
+
* support user switch for 'rig ssh'
|
51
|
+
* set balancer DNS ttl to 30, to deal with timeout issues
|
52
|
+
* clean up Instance#find_by_nick: was more complicated than it needed to be
|
53
|
+
|
54
|
+
## v0.4.1:
|
55
|
+
* bump version again. remove 1.9.3 dependency
|
56
|
+
|
57
|
+
## v0.4.0:
|
58
|
+
* merge feature/config_refactor
|
59
|
+
* refactor configuration
|
60
|
+
* config.yml
|
61
|
+
* this file should only contain rig configuration, nothing related to accounts
|
62
|
+
* don't use redundant rig node at top level of this file
|
63
|
+
* accounts
|
64
|
+
* change the solo template to use a more standardized role name (appserver)
|
65
|
+
* clean up rig capistrano integration, don't need to pull environments and servers before we know what environment we're working with
|
66
|
+
* clean up configuration usage, use a standard Hash rather than Oconfig object
|
67
|
+
* this should make everything more standardized
|
68
|
+
* and solve the ruby 1.9.3 issues
|
69
|
+
* remove commented ribbon dependency
|
70
|
+
* get rid of unused command options
|
71
|
+
* bug fixes
|
72
|
+
* capistrano integration fix for handling environments
|
73
|
+
* clean up fog dependencies for balancer
|
74
|
+
|
75
|
+
## v0.3.8:
|
76
|
+
* config cleanup
|
77
|
+
* need to refactor config a bit, should remove global values from config, should be in account or template. config should be just for rig, nothing else
|
78
|
+
* removed some debug statements
|
79
|
+
* Listener Management from the CLI
|
80
|
+
* added listener subcommand for balancer
|
81
|
+
* added add subcommand for listener
|
82
|
+
* added rm subcommand for listener
|
83
|
+
* clean up configuration files
|
84
|
+
|
85
|
+
## v0.3.7:
|
86
|
+
|
87
|
+
## v0.3.6:
|
88
|
+
|
89
|
+
## v0.3.5:
|
90
|
+
* environment protection: now prevents environment#destroy if environment#protected?
|
91
|
+
* some bug fixes. capistrano / chef / rig conflicts worked out (makes it easier to run cap with rig). instance#find was using wrong fog call (should be #get, not #find). configuration clean up. account handling working better now. some minor console ui stuff. environment protection implemented, need to add the check before destroy
|
92
|
+
|
93
|
+
## v0.3.4:
|
94
|
+
* refactor complete. environments build successfully. still so much to do
|
95
|
+
* major refactor should be done. Moved 'cloud' classes to 'model'. worked out configuration overrides / precedence
|
96
|
+
* major refactor
|
97
|
+
* massive refactor
|
98
|
+
* some config and init changes, cleanup
|
99
|
+
|
100
|
+
## v0.3.3:
|
101
|
+
* fixes for stupid bugs. ami vs. image, should use generic term. bad configuration overrides, need a cleaner way to handle this
|
102
|
+
|
103
|
+
## v0.3.2:
|
104
|
+
* don't load chef until after configuration is loaded (was causing config to load much earlier than intended). clean up way we get account
|
105
|
+
* add account support, refactor configuration.
|
106
|
+
* refactor SSH support
|
107
|
+
* instance list shows private ip. Gemfile development dependencies
|
108
|
+
|
109
|
+
## v0.3.1:
|
110
|
+
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
|
4
|
-
|
4
|
+
def changelog(last=nil, single=false)
|
5
5
|
command="git --no-pager log --format='%an::::%h::::%s'"
|
6
6
|
|
7
7
|
list = `git tag`
|
8
|
-
last = nil
|
9
8
|
|
10
9
|
puts "# Changelog"
|
11
10
|
puts
|
@@ -20,8 +19,11 @@ task :changelog do
|
|
20
19
|
log.lines.each do |line|
|
21
20
|
(who, hash, msg) = line.split('::::')
|
22
21
|
unless check[msg]
|
23
|
-
unless msg =~ /^Merge branch/ || msg =~ /^(v|version|changes for|preparing|ready for release|ready to release|bump version)*\s*(v|version)*\d+\.\d+\.\d+/
|
24
|
-
|
22
|
+
unless msg =~ /^Merge branch/ || msg =~ /CHANGELOG/ || msg =~ /^(v|version|changes for|preparing|ready for release|ready to release|bump version)*\s*(v|version)*\d+\.\d+\.\d+/
|
23
|
+
msg.gsub(" *", "\n*").gsub(/^\*\*/, " *").lines.each do |l|
|
24
|
+
line = l =~ /^(\s+)*\*/ ? l : "* #{l}"
|
25
|
+
out << line
|
26
|
+
end
|
25
27
|
check[msg] = hash
|
26
28
|
end
|
27
29
|
end
|
@@ -33,5 +35,16 @@ task :changelog do
|
|
33
35
|
end
|
34
36
|
|
35
37
|
last = tag
|
38
|
+
exit if single
|
36
39
|
end
|
37
40
|
end
|
41
|
+
|
42
|
+
desc "generate changelog output"
|
43
|
+
task :changelog do
|
44
|
+
changelog
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "show current changes (changelog output from HEAD to most recent tag)"
|
48
|
+
task :current do
|
49
|
+
changelog("HEAD",true)
|
50
|
+
end
|
data/bin/rig
CHANGED
data/conf/plugins/chef.rb
CHANGED
@@ -23,10 +23,10 @@ module Rig
|
|
23
23
|
self.environment_destroy(name)
|
24
24
|
end
|
25
25
|
|
26
|
-
on "instance:create" do |args|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
26
|
+
#on "instance:create" do |args|
|
27
|
+
# # do nothing
|
28
|
+
# # the instance will add itself through the chef-client call in userdata package
|
29
|
+
#end
|
30
30
|
|
31
31
|
on "instance:destroy" do |args|
|
32
32
|
instance = args.shift
|
@@ -65,7 +65,7 @@ module Rig
|
|
65
65
|
env.save
|
66
66
|
true
|
67
67
|
rescue => e
|
68
|
-
|
68
|
+
Rig::Log.error "*** chef exception: #{e.message}"
|
69
69
|
false
|
70
70
|
end
|
71
71
|
|
@@ -75,7 +75,7 @@ module Rig
|
|
75
75
|
env.destroy if env
|
76
76
|
true
|
77
77
|
rescue => e
|
78
|
-
|
78
|
+
Rig::Log.error "*** chef exception: #{e.message}"
|
79
79
|
false
|
80
80
|
end
|
81
81
|
|
data/conf/plugins/mongo.rb
CHANGED
data/lib/rig/config.rb
CHANGED
@@ -30,10 +30,10 @@ module Rig
|
|
30
30
|
yaml = @config.to_yaml
|
31
31
|
file = "#@dir/config.yml"
|
32
32
|
back = "#{file}.#{Time.now.to_i}"
|
33
|
-
|
33
|
+
Rig::Log.info "backing up configuration -> #{back}"
|
34
34
|
FileUtils.cp(file, back)
|
35
35
|
File.open(file, "w") { |f| f.write(yaml+"\n") }
|
36
|
-
|
36
|
+
Rig::Log.info "new configuration saved."
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/rig/log.rb
CHANGED
@@ -15,6 +15,15 @@ module Rig
|
|
15
15
|
def load(logging)
|
16
16
|
logging ||= {}
|
17
17
|
begin
|
18
|
+
console = Logger.new(STDOUT)
|
19
|
+
console_level = nil
|
20
|
+
console_config = logging.delete(:console)
|
21
|
+
if console_config && console_config[:level]
|
22
|
+
console_level = LEVELS[console_config[:level].to_sym]
|
23
|
+
end
|
24
|
+
console.level = console_level || Logger::INFO
|
25
|
+
add(console, proc {|s, _, _, m| "#{m}\n"})
|
26
|
+
|
18
27
|
logging.each do |name, data|
|
19
28
|
level = data[:level]
|
20
29
|
opts = [*data[:opts]].flatten
|
@@ -42,8 +51,8 @@ module Rig
|
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
|
-
def add(logger)
|
46
|
-
logger.formatter = proc { |severity, datetime, progname, msg| "#{$$}:#{datetime.strftime("%s")} #{severity[0]} #{msg}\n" }
|
54
|
+
def add(logger, formatter=nil)
|
55
|
+
logger.formatter = formatter || proc { |severity, datetime, progname, msg| "#{$$}:#{datetime.strftime("%s")} #{severity[0]} #{msg}\n" }
|
47
56
|
@loggers << logger
|
48
57
|
end
|
49
58
|
|
data/lib/rig/model/account.rb
CHANGED
@@ -19,10 +19,10 @@ module Rig
|
|
19
19
|
yaml = data.to_yaml
|
20
20
|
file = "#{dir}/#{name}.yml"
|
21
21
|
back = "#{file}.#{Time.now.to_i}"
|
22
|
-
|
22
|
+
Rig::Log.info "backing up configuration -> #{back}"
|
23
23
|
FileUtils.cp(file, back)
|
24
24
|
File.open(file, "w") {|f| f.write(yaml+"\n")}
|
25
|
-
|
25
|
+
Rig::Log.info "new configuration saved."
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
data/lib/rig/model/balancer.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'awesome_print'
|
2
1
|
|
3
2
|
module Rig
|
4
3
|
module Model
|
@@ -22,7 +21,7 @@ module Rig
|
|
22
21
|
def create(name, listeners=[], zones=[])
|
23
22
|
b = self.new(name, listeners, zones)
|
24
23
|
b.save if b
|
25
|
-
|
24
|
+
Rig::Log.info ".. created: #{name}"
|
26
25
|
b
|
27
26
|
end
|
28
27
|
|
@@ -38,7 +37,7 @@ module Rig
|
|
38
37
|
list = [*list]
|
39
38
|
lbs = list.map { |e| e.kind_of?(String) ? self.find(e) : e }
|
40
39
|
lbs.each do |lb|
|
41
|
-
|
40
|
+
Rig::Log.info ".. destroying: #{lb.id}"
|
42
41
|
lb.destroy if lb
|
43
42
|
end
|
44
43
|
end
|
@@ -69,8 +68,9 @@ module Rig
|
|
69
68
|
elb = find(name)
|
70
69
|
(from_proto, from_port) = from.split(':')
|
71
70
|
match = elb.listeners.select {|l| l.protocol == from_proto && l.lb_port == from_port.to_i }
|
71
|
+
#TODO: handle output in command, not here
|
72
72
|
if match.count > 1
|
73
|
-
|
73
|
+
Rig::Log.info "more than one listener matched"
|
74
74
|
match.each do |l|
|
75
75
|
ap l.attributes
|
76
76
|
end
|
data/lib/rig/model/dns.rb
CHANGED
@@ -43,10 +43,10 @@ module Rig
|
|
43
43
|
list = zone.records.all.select {|e| e.attributes[:name] == "#{name}."}
|
44
44
|
record = list.first
|
45
45
|
if record
|
46
|
-
|
46
|
+
Rig::Log.info ".. destroying zone: #{name}"
|
47
47
|
record.destroy
|
48
48
|
else
|
49
|
-
|
49
|
+
Rig::Log.info "record not found: #{name}"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -33,7 +33,7 @@ module Rig
|
|
33
33
|
def destroy(name, template=nil, opts={ })
|
34
34
|
env = self.find(name, template, opts)
|
35
35
|
raise "environment has protected instances" if env.protected?
|
36
|
-
|
36
|
+
Rig::Log.info "destroying: #{name}"
|
37
37
|
env.destroy
|
38
38
|
true
|
39
39
|
rescue => e
|
@@ -57,7 +57,7 @@ module Rig
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def save
|
60
|
-
|
60
|
+
Rig::Log.info "creating instances"
|
61
61
|
load_config
|
62
62
|
set = { }
|
63
63
|
|
@@ -76,7 +76,7 @@ module Rig
|
|
76
76
|
# but you won't be able to easily connect to it
|
77
77
|
raise "No key_name (keypair) set." unless o[:key_name]
|
78
78
|
|
79
|
-
Rig::Log.
|
79
|
+
Rig::Log.info "creating instance: name:#{n} environment:#@name roles:#{s.roles.inspect}"
|
80
80
|
instance = Rig::Model::Instance.create(o, 'Name' => n, 'Environment' => name, 'Roles' => s.roles.join(","))
|
81
81
|
set[s.balancer] ||= []
|
82
82
|
set[s.balancer] << instance if s.balancer
|
@@ -104,7 +104,6 @@ module Rig
|
|
104
104
|
sleep 3
|
105
105
|
reload
|
106
106
|
|
107
|
-
|
108
107
|
Rig::Log.info "associating servers' DNS"
|
109
108
|
@servers.each do |server|
|
110
109
|
record = "#{server.tags['Name']}.#{Rig.get_config(:dns_zone)}"
|
@@ -115,7 +114,7 @@ module Rig
|
|
115
114
|
if dns
|
116
115
|
Rig::Model::Dns.create(record, dns)
|
117
116
|
else
|
118
|
-
Rig::Log.
|
117
|
+
Rig::Log.warn "server #{server.id} doesn't have public_ip_address"
|
119
118
|
end
|
120
119
|
end
|
121
120
|
|
@@ -123,35 +122,29 @@ module Rig
|
|
123
122
|
rescue => e
|
124
123
|
Rig::Log.error "error creating environment:\n#{e.message} at #{e.backtrace.join("\n")}"
|
125
124
|
destroy
|
126
|
-
Rig::Log.error "error creating environment: #{e.message} at #{e.backtrace.first}"
|
127
125
|
end
|
128
126
|
|
129
127
|
def destroy
|
130
|
-
|
128
|
+
Rig::Log.info "removing dns from servers"
|
131
129
|
@servers.each do |server|
|
132
130
|
Rig::Model::Dns.destroy("#{server.tags['Name']}.#{Rig.get_config(:dns_zone)}") if server.tags['Name']
|
133
131
|
end
|
134
132
|
|
135
133
|
roles = @servers.collect { |s| s.tags['Role'] }.compact
|
136
134
|
roles.each do |r|
|
137
|
-
|
135
|
+
Rig::Log.info "removing role balancer dns"
|
138
136
|
Rig::Model::Dns.destroy("#{r}.#{name}.env.#{Rig.get_config(:dns_zone)}")
|
139
137
|
end
|
140
138
|
|
141
|
-
|
139
|
+
Rig::Log.info "removing primary dns"
|
142
140
|
Rig::Model::Dns.destroy("#{name}.env.#{Rig.get_config(:dns_zone)}")
|
143
141
|
|
144
|
-
|
142
|
+
Rig::Log.info "destroying servers"
|
145
143
|
Rig::Model::Instance.destroy(@servers)
|
146
144
|
|
147
|
-
|
145
|
+
Rig::Log.info "destroying balancers"
|
148
146
|
Rig::Model::Balancer.destroy(@balancers)
|
149
147
|
|
150
|
-
#if Rig.config[:chef]
|
151
|
-
# puts "destroying chef environment"
|
152
|
-
# Rig::Chef.environment_destroy(name)
|
153
|
-
#end
|
154
|
-
|
155
148
|
Rig::Plugin.run "environment:destroy", self
|
156
149
|
end
|
157
150
|
|
data/lib/rig/model/instance.rb
CHANGED
@@ -14,11 +14,11 @@ module Rig
|
|
14
14
|
|
15
15
|
def find(id)
|
16
16
|
if id =~ /^i-/
|
17
|
-
|
17
|
+
Rig::Log.info "find #{id}"
|
18
18
|
Rig::Connection.compute.servers.get(id)
|
19
19
|
else
|
20
20
|
# must be tag:Name
|
21
|
-
|
21
|
+
Rig::Log.info "all tag:Name => #{id}"
|
22
22
|
Rig::Connection.compute.servers.all({"tag:Name"=>id})
|
23
23
|
end
|
24
24
|
end
|
@@ -34,13 +34,15 @@ module Rig
|
|
34
34
|
def find_by_nick(name)
|
35
35
|
(role, env) = name.match(/(\w+)\.(\w+)/)[1..2]
|
36
36
|
find_by_environment(env).select {|s| s.tags['Name'] =~ /^#{role}/ }
|
37
|
+
rescue => e
|
38
|
+
Rig::Log.error "error finding server by nickname #{name}. name should be of the form: role#.environment"
|
37
39
|
end
|
38
40
|
|
39
41
|
def create(opts, tags={})
|
40
42
|
fog = Rig::Connection.compute
|
41
43
|
server = fog.servers.create(opts)
|
42
44
|
fog.create_tags(server.id, tags) if tags.count > 0
|
43
|
-
|
45
|
+
Rig::Log.info ".. created: #{server.id}"
|
44
46
|
Rig::Plugin.run "instance:create", server
|
45
47
|
server
|
46
48
|
end
|
@@ -51,7 +53,7 @@ module Rig
|
|
51
53
|
if list.count > 0
|
52
54
|
compute = Rig::Connection.compute
|
53
55
|
ids = list.map {|e| e.kind_of?(String) ? e : e.id}
|
54
|
-
|
56
|
+
Rig::Log.info ".. destroying: #{ids.inspect}"
|
55
57
|
|
56
58
|
# destroy the instances
|
57
59
|
list.each do |e|
|
data/lib/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
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: 2012-06-
|
12
|
+
date: 2012-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
119
|
- .rvmrc
|
120
|
+
- CHANGELOG.md
|
120
121
|
- Gemfile
|
121
122
|
- LICENSE
|
122
123
|
- README.md
|