judo 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ Jeweler::Tasks.new do |s|
8
8
  s.email = "orion@heroku.com"
9
9
  s.homepage = "http://github.com/orionz/judo"
10
10
  s.rubyforge_project = "judo"
11
- s.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
11
+ s.files = FileList["[A-Z]*", "{bin,default,lib,spec}/**/*"]
12
12
  s.executables = %w(judo)
13
13
  s.add_dependency "aws", [">= 2.3.8"]
14
14
  s.add_dependency "json"
data/TODO CHANGED
@@ -1,6 +1,5 @@
1
1
  ### NEEDED for new gem launch
2
2
 
3
- ### [ ] ubuntu 10.04
4
3
  ### [ ] snapshot percent complete in do_snapshots()
5
4
  ### [ ] judo swap (x) (y) -> swaps elastic IP's and name
6
5
  ### [ ] snapshots/init/virgin
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.6
1
+ 0.3.7
data/bin/judo CHANGED
@@ -10,9 +10,7 @@ defaults = Judo::Base.default_options(Dir.pwd)
10
10
 
11
11
  options = {}
12
12
 
13
- action = ARGV.shift
14
-
15
- ARGV.unshift "-h" unless action
13
+ ARGV.unshift "-h" if ARGV.size == 0
16
14
 
17
15
  optparse = OptionParser.new do|opts|
18
16
  opts.banner = <<banner
@@ -70,14 +68,16 @@ banner
70
68
  opts.on( '-r', '--repo DIR', 'Specify the location of the repo dir' ) do |dir|
71
69
  options[:repo] = dir
72
70
  end
73
- opts.on( '-D', '--data DATA', 'Specify an instance specific string to be used during boot on create or launch' ) do |data|
74
- options[:data] = data
75
- end
76
71
  opts.on( '-t', '--type TYPE', 'Specify an instance type different from the config on server start' ) do |type|
77
72
  options[:instance_type] = type
78
73
  end
79
- opts.on( '-B', '--boot BOOT', 'Instance specific string (like --data) but for this boot only' ) do |data|
80
- options[:boot] = data
74
+ opts.on( '-D', '--data KEY=VALUE', 'Specify metadata to attach to a server at creation time' ) do |data|
75
+ key,value = data.split("=")
76
+ (options[:metadata] ||= {})[key] = value
77
+ end
78
+ opts.on( '-B', '--boot KEY=VALUE', 'Specify special boot parameters' ) do |data|
79
+ key,value = data.split("=")
80
+ (options[:boot] ||= {})[key] = value
81
81
  end
82
82
  opts.on( '-i', '--ip IP', 'Specify an exsiting elastic_ip address on server creation' ) do |ip|
83
83
  options[:elastic_ip] = ip
@@ -104,9 +104,6 @@ banner
104
104
  opts.on( '-g', '--group GROUP', 'Specify the default group of the repo dir' ) do |group|
105
105
  options[:group] = group
106
106
  end
107
- opts.on( '-n', '--note NOTE', 'Add a note to a server as you create or launch it') do |note|
108
- options[:note] = note
109
- end
110
107
  opts.on( '-v', '--version VERSION', 'Update the servers config version on create/start/launch' ) do |version|
111
108
  options[:version] = version
112
109
  end
@@ -118,6 +115,7 @@ end
118
115
 
119
116
  optparse.parse!
120
117
 
118
+ action = ARGV.shift
121
119
  judo = Judo::Base.new(defaults.merge(options))
122
120
  judo.check_version if action != "setup"
123
121
 
@@ -141,7 +139,7 @@ begin
141
139
  when "snapshots" then do_snapshots(judo, ARGV)
142
140
  when "config" then
143
141
  puts "Judo DB Version: #{judo.db_version}"
144
- puts "Judo Keypair: #{judo.key_name}"
142
+ puts "Judo Key Pair: #{judo.key_name}"
145
143
  puts "Judo Bucket: #{judo.bucket_name}"
146
144
  when "rename" then
147
145
  raise JudoError, "usage: judo rename SERVER SERVER" unless ARGV.size == 2
@@ -174,7 +172,7 @@ begin
174
172
  snapshot.animate(new_server).start(options)
175
173
  when "destroy" then
176
174
  raise JudoError, "You must specify what servers to destroy" if ARGV.empty?
177
- find_either(judo, ARGV) do |i|
175
+ find_servers(judo, ARGV) do |i|
178
176
  i.destroy
179
177
  end
180
178
  else
@@ -0,0 +1,8 @@
1
+ {
2
+ "ami32":"ami-2d4aa444", // public ubuntu 10.04 ami - 32 bit
3
+ "ami64":"ami-fd4aa494", // public ubuntu 10.04 ami - 64 bit
4
+ "user":"ubuntu", // this is for ssh acccess - defaults to ubuntu not root
5
+ "security_group":"judo",
6
+ "my_data": "world world",
7
+ "availability_zone":"us-east-1d"
8
+ }
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+ <%
3
+
4
+ ## the variables available for use in the erb are as follows
5
+
6
+ ## id - this is random string that uniqily identifies the server for its lifetime
7
+ ## name - the name of the server
8
+ ## group_name - the name of group the server is in
9
+ ## domain - this is the JUDO_DOMAIN currently running
10
+ ## secret - this is a 128bit random string assigned to an instance at creation time - great for passwords
11
+ ## metadata - a hash of metadata associated with the server with --data KEY=VALUE
12
+ ## boot - a hash of boot options passed to the server with --boot KEY=VALUE
13
+ ## first_boot? - is set to true or false depending on if this is the instance's first boot
14
+ ## url - the URL to the group verson file in the s3 bucket
15
+
16
+ %>
17
+
18
+ export JUDO_ID='<%= id %>'
19
+ export JUDO_NAME='<%= name %>'
20
+ export JUDO_DOMAIN='<%= domain %>'
21
+ export JUDO_SECRET='<%= secret %>'
22
+ export JUDO_FIRST_BOOT='<%= first_boot? %>'
23
+
24
+ export DEBIAN_FRONTEND="noninteractive"
25
+ export DEBIAN_PRIORITY="critical"
26
+ apt-get update
27
+ apt-get install -y ruby rubygems ruby-dev irb libopenssl-ruby libreadline-ruby
28
+
29
+ cd /tmp/ ; curl --silent '<%= url %>' | tar xvz ; cd <%= group_name %>
30
+
31
+ gem install kuzushi --no-rdoc --no-ri --version
32
+ echo 'export PATH=`ruby -r rubygems -e "puts Gem.bindir"`:$PATH' >> /etc/profile ; . /etc/profile
33
+ export LOG=/var/log/kuzushi.log
34
+
35
+ kuzushi-setup >> $LOG ## this will properly mount / configure and formal all ebs drives
36
+ bash setup.sh >> $LOG
37
+
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'erb'
2
3
  require 'active_support'
3
4
  require 'right_aws'
4
5
  require 'socket'
@@ -1,27 +1,3 @@
1
-
2
- =begin
3
- module Aws
4
- class Ec2
5
- API_VERSION = "2009-11-30" ## this didnt work
6
- def start_instances(instance_id)
7
- link = generate_request("StartInstances", { 'InstanceId' => instance_id } )
8
- request_info(link, QEc2TerminateInstancesParser.new(:logger => @logger))
9
- rescue Exception
10
- on_exception
11
- end
12
-
13
- def stop_instances(instance_id)
14
- link = generate_request("StopInstances", { 'InstanceId' => instance_id } )
15
- puts link.inspect
16
- result = request_info(link, QEc2TerminateInstancesParser.new(:logger => @logger))
17
- puts result.inspect
18
- rescue Exception
19
- on_exception
20
- end
21
- end
22
- end
23
- =end
24
-
25
1
  module Judo
26
2
  class Base
27
3
  attr_accessor :judo_dir, :repo, :group, :domain
@@ -162,9 +138,17 @@ module Judo
162
138
  rand(2**32).to_s(36)
163
139
  end
164
140
 
141
+ def default_group_dir
142
+ File.expand_path(File.dirname(__FILE__) + "/../../default")
143
+ end
144
+
145
+ def default_file(name)
146
+ "#{default_group_dir}/#{name}"
147
+ end
148
+
165
149
  def mk_server_name(group)
166
150
  index = servers.map { |s| (s.name =~ /^#{s.group.name}.(\d*)$/); $1.to_i }.sort.last.to_i + 1
167
- "#{group.name}.#{index}"
151
+ "#{group}.#{index}"
168
152
  end
169
153
 
170
154
  def create_server(name, group, options)
@@ -452,9 +436,8 @@ module Judo
452
436
  def default_config
453
437
  <<DEFAULT
454
438
  {
455
- "instance_type":"m1.small",
456
- "ami32":"ami-bb709dd2", // public ubuntu 9.10 ami - 32 bit
457
- "ami64":"ami-55739e3c", // public ubuntu 9.10 ami - 64 bit
439
+ "ami32":"ami-2d4aa444", // public ubuntu 10.04 ami - 32 bit
440
+ "ami64":"ami-fd4aa494", // public ubuntu 10.04 ami - 64 bit
458
441
  "user":"ubuntu",
459
442
  "security_group":"judo",
460
443
  "availability_zone":"us-east-1d"
@@ -46,19 +46,6 @@ module JudoCommandLineHelpers
46
46
  servers.flatten.each { |s| judo_yield(s, blk) if blk }
47
47
  end
48
48
 
49
- def find_either(judo, args, &blk)
50
- results = []
51
- args.each do |arg|
52
- server,group = split(arg)
53
- if server != ""
54
- results << judo.servers.select { |s| s.name == server }
55
- else
56
- results << judo.groups.select { |g| g.name == group }
57
- end
58
- end
59
- results.flatten.each { |i| judo_yield(i, blk) if blk }
60
- end
61
-
62
49
  def find_servers(judo, args, use_default = true, &blk)
63
50
  servers = judo.servers if args.empty?
64
51
  servers ||= args.map { |a| find_server(judo, a, use_default) }.flatten
@@ -161,6 +148,9 @@ module JudoCommandLineHelpers
161
148
  printf " %-24s: %s\n",k, i[k]
162
149
  end
163
150
  end
151
+ sub_info("METADATA", server.metadata.keys) do |key|
152
+ printf(" %-24s: %s\n", key, server.metadata[key] )
153
+ end
164
154
  sub_info("VOLUMES", server.ec2_volumes) do |v|
165
155
  printf " %-13s %-10s %-10s %4d %-10s %-8s\n",
166
156
  v[:aws_id],
@@ -8,12 +8,12 @@ module Judo
8
8
  @version = version
9
9
  end
10
10
 
11
- def config
12
- @config ||= load_config
11
+ def userdata(version)
12
+ (@userdata ||= {})[version] ||= load_userdata(version)
13
13
  end
14
14
 
15
- def build_config
16
- @build_config ||= all_configs.reverse.inject({}) { |sum,conf| sum.merge(conf) }
15
+ def config(version)
16
+ (@config ||= {})[version] ||= load_config(version)
17
17
  end
18
18
 
19
19
  def server_ids
@@ -24,8 +24,14 @@ module Judo
24
24
  @base.servers.select { |s| server_ids.include?(s.name) }
25
25
  end
26
26
 
27
- def load_config
28
- JSON.load @base.s3_get(version_config_file)
27
+ def load_userdata(version)
28
+ @base.s3_get(version_userdata_file(version))
29
+ rescue Aws::AwsError
30
+ raise JudoError, "No userdata stored: try 'judo commit #{to_s}'"
31
+ end
32
+
33
+ def load_config(version)
34
+ JSON.load @base.s3_get(version_config_file(version))
29
35
  rescue Aws::AwsError
30
36
  raise JudoError, "No config stored: try 'judo commit #{to_s}'"
31
37
  end
@@ -35,41 +41,34 @@ module Judo
35
41
  end
36
42
 
37
43
  def compile
38
- tmpdir = "/tmp/kuzushi/#{name}"
39
44
  @base.task("Compiling #{self} version #{version + 1}") do
40
45
  @version = @version + 1
41
- FileUtils.rm_rf(tmpdir)
42
- FileUtils.mkdir_p(tmpdir)
43
- new_config = build_config
44
- Dir.chdir(tmpdir) do |d|
45
- attachments(new_config).each do |to,from|
46
- FileUtils.mkdir_p(File.dirname(to))
47
- if from =~ /^http:\/\//
48
- # puts "curl '#{from}'"
49
- system "curl '#{from}' > #{to}"
50
- # puts "#{to} is #{File.stat(to).size} bytes"
51
- else
52
- FileUtils.cp(from,to)
53
- end
54
- end
55
- File.open("config.json", "w") { |f| f.write(new_config.to_json) }
56
- Dir.chdir("..") do
46
+ raise JudoError, "can not find group folder #{dir}" unless File.exists?(dir)
47
+ conf = JSON.parse(read_file('config.json'))
48
+ raise JudoError, "config option 'import' no longer supported" if conf["import"]
49
+ Dir.chdir(@base.repo) do |d|
57
50
  puts ""
58
51
  system "tar czvf #{tar_file} #{name}"
59
52
  puts "Uploading config to s3..."
60
- @base.s3_put(version_config_file, new_config.to_json)
53
+ @base.s3_put(version_config_file(@version), conf.to_json)
54
+ puts "Uploading userdata.erb to s3..."
55
+ @base.s3_put(version_userdata_file(@version), read_file('userdata.erb'))
61
56
  puts "Uploading tar file to s3..."
62
57
  @base.s3_put(tar_file, File.new(tar_file).read(File.stat(tar_file).size))
63
- end
58
+ File.delete(tar_file)
64
59
  end
65
60
  set_version
66
61
  end
67
62
  end
68
63
 
69
- def version_config_file
64
+ def version_config_file(version)
70
65
  "#{name}.#{version}.json"
71
66
  end
72
67
 
68
+ def version_userdata_file(version)
69
+ "#{name}.#{version}.erb"
70
+ end
71
+
73
72
  def tar_file
74
73
  "#{name}.#{version}.tar.gz"
75
74
  end
@@ -78,66 +77,6 @@ module Judo
78
77
  @url = @base.s3_url(tar_file)
79
78
  end
80
79
 
81
- def cp_file
82
- FileUtil.mkdir_p(tmpdir)
83
- end
84
-
85
- def extract_file(type, name, files)
86
- path = "#{dir}/#{type}s/#{name}"
87
- found = Dir[path]
88
- if not found.empty?
89
- found.each { |f| files["#{type}s/#{File.basename(f)}"] = f }
90
- elsif parent
91
- parent.extract_file(type, name, files)
92
- else
93
- raise "Cannot find file #{name} of type #{type}"
94
- end
95
- end
96
-
97
- def extract(config, files)
98
- config.each do |key,value|
99
- [value].flatten.each do |v| ### cover "packages" : ["a","b"], "packages" : "a", "packages":[{ "file" : "foo.pkg"}]
100
- if v.is_a? Hash
101
- extract(v, files)
102
- else
103
- case key
104
- when *[ "init", "before", "after" ]
105
- extract_file(:script, v, files) unless v =~ /^#!/
106
- when "package"
107
- files["packages/#{v}_i386.deb"] = "#{config["source"]}#{v}_i386.deb"
108
- files["packages/#{v}_amd64.deb"] = "#{config["source"]}#{v}_amd64.deb"
109
- when "local_packages"
110
- extract_file(:package, "#{v}_i386.deb", files)
111
- extract_file(:package, "#{v}_amd64.deb", files)
112
- when "git"
113
- ## do nothing - is a remote
114
- when "template"
115
- extract_file(:template, v, files)
116
- when "source"
117
- extract_file(:file, v, files) unless config["template"] or config["package"]
118
- when "file"
119
- ## this is getting messy
120
- extract_file(:file, File.basename(v), files) unless config["template"] or config["source"] or config["git"]
121
- end
122
- end
123
- end
124
- end
125
- files
126
- end
127
-
128
- def attachments(c = config)
129
- extract(c, {})
130
- end
131
-
132
- def raw_config
133
- @raw_config ||= read_config
134
- end
135
-
136
- def parent
137
- @parent ||= @base.groups.detect { |p| p.name == raw_config["import"] }
138
- (@parent ||= Judo::Group.new(@base, raw_config["import"], 0 )) if raw_config["import"] ## make a mock incase the parent was never committed
139
- @parent
140
- end
141
80
 
142
81
  def destroy
143
82
  servers.each { |s| s.destroy }
@@ -148,22 +87,20 @@ module Judo
148
87
  end
149
88
  end
150
89
 
151
- def all_configs
152
- parent ? parent.all_configs.clone.unshift(raw_config) : [ raw_config ]
153
- end
154
-
155
90
  def dir
156
91
  "#{@base.repo}/#{name}/"
157
92
  end
158
93
 
159
- def config_file
160
- "#{dir}/config.json"
94
+ def default_userdata_file
95
+ File.expand_path(File.dirname(__FILE__) + "/../../default/userdata.erb")
161
96
  end
162
97
 
163
- def read_config
164
- JSON.parse(File.read(config_file))
98
+ def read_file(name)
99
+ File.read("#{dir}/#{name}")
165
100
  rescue Errno::ENOENT
166
- raise JudoError, "No config file #{config_file}"
101
+ default = @base.default_file(name)
102
+ puts "File #{name} not found: using #{default} instead"
103
+ File.read default
167
104
  end
168
105
 
169
106
  def delete_server(server)
@@ -1,11 +1,12 @@
1
1
  module Judo
2
2
  class Server
3
- attr_accessor :id,:group_name
3
+ attr_accessor :id
4
4
 
5
5
  def initialize(base, id, group, version = nil)
6
6
  @base = base
7
7
  @id = id
8
- @group_name = group
8
+ @group = group
9
+ @judo_domain = base.domain
9
10
  end
10
11
 
11
12
  def create(name, options)
@@ -14,8 +15,7 @@ module Judo
14
15
  options[:virgin] = true if options[:virgin].nil?
15
16
 
16
17
  snapshots = options[:snapshots]
17
- note = options[:note] ## a user defined note field
18
- data = options[:data] ## instance specific data passed in JUDO_DATA
18
+ metadata = options[:metadata]
19
19
  ip = options[:elastic_ip] ## if the ip was allocated beforehand
20
20
  virgin = options[:virgin] ## should the server init?
21
21
  clone = options[:clone] ## if it was cloned from a snapshot
@@ -27,11 +27,11 @@ module Judo
27
27
  raise JudoError, "there is already a server with id #{id}" if @base.servers.detect { |s| s.id == id and s != self}
28
28
 
29
29
  task("Creating server #{name}") do
30
- update "name" => name, "group" => group_name,
31
- "note" => note, "virgin" => virgin,
30
+ update("name" => name, "group" => group_name,
31
+ "virgin" => virgin, "elastic_ip" => ip,
32
32
  "secret" => new_secret, "version" => version,
33
- "data" => data, "elastic_ip" => ip,
34
- "clone" => clone, "created_at" => Time.now.to_i
33
+ "clone" => clone, "created_at" => Time.now.to_i)
34
+ set_metadata(metadata) if metadata
35
35
  @base.sdb.put_attributes(@base.base_domain, "groups", group_name => id)
36
36
  end
37
37
 
@@ -41,8 +41,37 @@ module Judo
41
41
  self
42
42
  end
43
43
 
44
+ def set_metadata(new_metadata)
45
+ puts new_metadata.inspect
46
+ clean_metadata = new_metadata.inject({}) { |buf,(k,v)|
47
+ puts [ buf, k , v ].inspect
48
+ buf[k.to_s] = v.to_s; buf }
49
+ puts clean_metadata.inspect
50
+ keys_to_remove = clean_metadata.keys - clean_metadata.keys
51
+ @metadata = clean_metadata
52
+ update encode_metadata(clean_metadata) unless clean_metadata.empty?
53
+ keys_to_remove.each { |key| remove key }
54
+ end
55
+
56
+ def encode_metadata(data)
57
+ data.inject({}) { |buf,(key,value)| buf["metadata_#{key.to_s}"] = [value].to_json; buf }
58
+ end
59
+
60
+ def metadata
61
+ @metadata ||= get_metadata
62
+ end
63
+
64
+ def get_metadata
65
+ state.inject({}) do |buf,(key,value)|
66
+ if key =~ /^metadata_(.*)/
67
+ buf[$1] = JSON.load(value.first)
68
+ end
69
+ buf
70
+ end
71
+ end
72
+
44
73
  def group
45
- @group ||= @base.groups.detect { |g| g.name == group_name }
74
+ @group_obj ||= @base.groups.detect { |g| g.name == @group }
46
75
  end
47
76
 
48
77
  def fetch_state
@@ -53,10 +82,6 @@ module Judo
53
82
  @base.servers_state[id] ||= fetch_state
54
83
  end
55
84
 
56
- def get(key)
57
- state[key] && [state[key]].flatten.first
58
- end
59
-
60
85
  def created_at
61
86
  Time.at(get("created_at").to_i)
62
87
  end
@@ -125,6 +150,10 @@ module Judo
125
150
  !!clone
126
151
  end
127
152
 
153
+ def first_boot?
154
+ virgin?
155
+ end
156
+
128
157
  def virgin?
129
158
  get("virgin").to_s == "true" ## I'm going to set it to true and it will come back from the db as "true" -> could be "false" or false or nil also
130
159
  end
@@ -141,6 +170,12 @@ module Judo
141
170
  (state["volumes"] || []).inject({}) { |out, kv| k, v = kv.split(':'); out[k] = v; out }
142
171
  end
143
172
 
173
+ ######## begin simple DB access #######
174
+
175
+ def get(key)
176
+ state[key] && [state[key]].flatten.first
177
+ end
178
+
144
179
  def update(attrs)
145
180
  @base.sdb.put_attributes(@base.server_domain, id, attrs, :replace)
146
181
  state.merge! attrs
@@ -170,11 +205,11 @@ module Judo
170
205
 
171
206
  def instance_type
172
207
  ## need instance_size to be backward compatible - needed for configs made before v 0.3.0
173
- get("instance_type") || config["instance_type"] || config["instance_size"]
208
+ get("instance_type") || config["instance_type"] || config["instance_size"] || "m1.small"
174
209
  end
175
210
 
176
211
  def config
177
- group.config
212
+ group.config(version)
178
213
  end
179
214
 
180
215
  def to_s
@@ -295,6 +330,7 @@ module Judo
295
330
  end
296
331
 
297
332
  def start(options = {})
333
+ @boot= options[:boot]
298
334
  new_version = options[:version]
299
335
  set_instance_type(options[:instance_type]) if options[:instance_type]
300
336
 
@@ -302,7 +338,7 @@ module Judo
302
338
  invalid "No config has been commited yet, type 'judo commit'" unless group.version > 0
303
339
 
304
340
  task("Updating server version") { update_version(options[:version]) } if options[:version]
305
- task("Starting server #{name}") { launch_ec2(options[:boot]) }
341
+ task("Starting server #{name}") { launch_ec2 }
306
342
  task("Wait for server") { wait_for_running } if elastic_ip or has_volumes?
307
343
  task("Attaching ip") { attach_ip } if elastic_ip
308
344
  task("Attaching volumes") { attach_volumes } if has_volumes?
@@ -344,11 +380,11 @@ module Judo
344
380
  update "stopped_at" => Time.now.to_i
345
381
  end
346
382
 
347
- def launch_ec2(boot = nil)
383
+ def launch_ec2
348
384
  # validate
349
385
 
350
386
  ## EC2 launch_instances
351
- ud = user_data(boot)
387
+ ud = user_data
352
388
  debug(ud)
353
389
  result = @base.ec2.launch_instances(ami,
354
390
  :instance_type => instance_type,
@@ -361,7 +397,9 @@ module Judo
361
397
 
362
398
  def debug(str)
363
399
  return unless ENV['JUDO_DEBUG'] == "1"
364
- puts "<JUDO_DEBUG>#{str}</JUDO_DEBUG>"
400
+ puts "<DEBUG>"
401
+ puts str
402
+ puts "</DEBUG>"
365
403
  end
366
404
 
367
405
  def security_groups
@@ -516,29 +554,18 @@ module Judo
516
554
  @base.servers_state.delete(id)
517
555
  end
518
556
 
519
- def user_data(judo_boot = nil)
520
- <<USER_DATA
521
- #!/bin/sh
522
-
523
- export DEBIAN_FRONTEND="noninteractive"
524
- export DEBIAN_PRIORITY="critical"
525
- export JUDO_ID='#{id}'
526
- export JUDO_NAME='#{name}'
527
- export JUDO_DOMAIN='#{@base.domain}'
528
- export JUDO_BOOT='#{judo_boot}'
529
- export JUDO_DATA='#{data}'
530
- export SECRET='#{secret}'
531
- apt-get update
532
- apt-get install ruby rubygems ruby-dev irb libopenssl-ruby libreadline-ruby -y
533
- gem install kuzushi --no-rdoc --no-ri
534
- GEM_BIN=`ruby -r rubygems -e "puts Gem.bindir"`
535
- echo "$GEM_BIN/kuzushi #{virgin? && "init" || "start"} '#{url}'" > /var/log/kuzushi.log
536
- $GEM_BIN/kuzushi #{virgin? && "init" || "start"} '#{url}' >> /var/log/kuzushi.log 2>&1
537
- USER_DATA
557
+ def user_data
558
+ erb = group.userdata(version)
559
+ debug erb
560
+ ERB.new(erb, 0, '<>').result(binding)
538
561
  end
539
562
 
540
563
  def url
541
- @url ||= group.s3_url
564
+ group.s3_url
565
+ end
566
+
567
+ def domain
568
+ @base.domain
542
569
  end
543
570
 
544
571
  def validate
@@ -596,12 +623,20 @@ USER_DATA
596
623
  end
597
624
 
598
625
  def <=>(s)
599
- [group.name, name] <=> [s.group.name, s.name]
626
+ [group.to_s, name.to_s] <=> [s.group.to_s, s.name.to_s]
600
627
  end
601
628
 
602
629
  def new_secret
603
630
  rand(2 ** 128).to_s(36)
604
631
  end
605
632
 
633
+ def group_name
634
+ @group
635
+ end
636
+
637
+ def boot
638
+ @boot || {}
639
+ end
640
+
606
641
  end
607
642
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 6
9
- version: 0.3.6
8
+ - 7
9
+ version: 0.3.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Orion Henry
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-24 00:00:00 -04:00
17
+ date: 2010-05-31 00:00:00 -04:00
18
18
  default_executable: judo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -58,6 +58,9 @@ files:
58
58
  - TODO
59
59
  - VERSION
60
60
  - bin/judo
61
+ - default/config.json
62
+ - default/setup.sh
63
+ - default/userdata.erb
61
64
  - lib/judo.rb
62
65
  - lib/judo/base.rb
63
66
  - lib/judo/commandline_helpers.rb