auser-poolparty 1.2.7 → 1.2.8

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.
Files changed (63) hide show
  1. data/README.txt +1 -1
  2. data/VERSION.yml +1 -1
  3. data/bin/cloud-configure +1 -1
  4. data/bin/cloud-contract +1 -1
  5. data/bin/cloud-expand +1 -1
  6. data/bin/cloud-list +3 -3
  7. data/bin/cloud-ssh +1 -1
  8. data/bin/cloud-start +1 -1
  9. data/bin/server-cloud-elections +17 -23
  10. data/bin/server-list-active +24 -16
  11. data/bin/server-manage-election +13 -21
  12. data/bin/server-show-stats +1 -1
  13. data/examples/metavirt_cloud.rb +12 -8
  14. data/examples/{poolparty.rb → simple.rb} +0 -0
  15. data/examples/vmrun_cloud.rb +20 -0
  16. data/lib/poolparty/core/proc.rb +0 -7
  17. data/lib/poolparty/dependency_resolver/chef_resolver.rb +1 -1
  18. data/lib/poolparty/dependency_resolver/puppet.rb +0 -1
  19. data/lib/poolparty/helpers/console.rb +0 -5
  20. data/lib/poolparty/modules/callbacks.rb +7 -0
  21. data/lib/poolparty/modules/cloud_dsl.rb +0 -6
  22. data/lib/poolparty/modules/cloud_resourcer.rb +38 -20
  23. data/lib/poolparty/modules/searchable_paths.rb +5 -1
  24. data/lib/poolparty/net/init.rb +17 -4
  25. data/lib/poolparty/net/remoter/interactive.rb +1 -1
  26. data/lib/poolparty/net/remoter_base.rb +40 -19
  27. data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +7 -2
  28. data/lib/poolparty/net/remoter_bases/ec2/ec2_remote_instance.rb +1 -0
  29. data/lib/poolparty/net/remoter_bases/ec2/ec2_response_object.rb +2 -2
  30. data/lib/poolparty/net/remoter_bases/metavirt/metavirt.rb +21 -20
  31. data/lib/poolparty/plugins/apache2/apache.rb +24 -4
  32. data/lib/poolparty/plugins/authorized_key.rb +29 -0
  33. data/lib/poolparty/plugins/chef.rb +2 -2
  34. data/lib/poolparty/plugins/deploy_directory.rb +7 -2
  35. data/lib/poolparty/poolparty/cloud.rb +110 -23
  36. data/lib/poolparty/poolparty/plugin_model.rb +1 -0
  37. data/lib/poolparty/poolparty/poolparty_base_class.rb +25 -3
  38. data/lib/poolparty/poolparty/resource.rb +1 -6
  39. data/lib/poolparty/provision/boot_strapper.rb +5 -1
  40. data/lib/poolparty/resources/directory.rb +1 -1
  41. data/lib/poolparty/resources/symlink.rb +9 -2
  42. data/lib/poolparty/resources/user.rb +16 -1
  43. data/lib/poolparty/schema.rb +3 -4
  44. data/lib/poolparty/templates/haproxy.conf +1 -1
  45. data/lib/poolparty.rb +1 -1
  46. data/spec/poolparty/core/object_spec.rb +0 -24
  47. data/spec/poolparty/fixtures/fake_key.pub +1 -0
  48. data/spec/poolparty/modules/searchable_paths_spec.rb +12 -5
  49. data/spec/poolparty/net/remoter_bases/ec2_spec.rb +1 -1
  50. data/spec/poolparty/plugins/authorized_key_spec.rb +23 -0
  51. data/spec/poolparty/poolparty/cloud_spec.rb +3 -3
  52. data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +1 -1
  53. data/test/poolparty/net/remoter_bases/metavirt/metavirt_test.rb +1 -4
  54. data/test/poolparty/poolparty/cloud_test.rb +40 -0
  55. data/test/test_helper.rb +1 -1
  56. metadata +8 -10
  57. data/lib/poolparty/core/metaid.rb +0 -15
  58. data/lib/poolparty/core/module.rb +0 -40
  59. data/lib/poolparty/helpers/display.rb +0 -30
  60. data/lib/poolparty/net/remote_bases.rb +0 -22
  61. data/spec/poolparty/core/module_spec.rb +0 -15
  62. data/spec/poolparty/helpers/display_spec.rb +0 -13
  63. data/spec/poolparty/id_rsa +0 -27
@@ -51,8 +51,13 @@ module PoolParty
51
51
  :keypair_name =>nil
52
52
  })
53
53
 
54
- def ami
55
- image_id
54
+ # alias to image_id
55
+ def ami(n=nil)
56
+ if n.nil?
57
+ image_id
58
+ else
59
+ image_id n
60
+ end
56
61
  end
57
62
 
58
63
  # Requires a hash of options
@@ -1,3 +1,4 @@
1
+ require "#{::File.dirname(__FILE__)}/ec2"
1
2
  module PoolParty
2
3
  module Remote
3
4
  class Ec2RemoteInstance < RemoteInstance
@@ -1,7 +1,7 @@
1
1
  # Convenience class to convert standard amazon-ec2 responses from their camel cased style to a hash using underscore style.
2
2
  # For example: instanceId to instance_id
3
3
  class EC2ResponseObject
4
- def self.get_descriptions(resp)
4
+ def self.get_descriptions(resp)
5
5
  rs = get_instance_from_response(resp)
6
6
  group = get_group_from_response(resp)
7
7
 
@@ -58,7 +58,7 @@ class EC2ResponseObject
58
58
  :ip => resp.dnsName || "not-assigned",
59
59
  :internal_ip => resp.privateDnsName,
60
60
  :launching_time => resp.launchTime.parse_datetime,
61
- :keypair => resp.keyName,
61
+ :keypair => (resp.keyName rescue ""),
62
62
  :security_group => group
63
63
  }
64
64
  end
@@ -20,19 +20,22 @@ module PoolParty
20
20
  :keypair_path => nil,
21
21
  :authorized_keys => nil,
22
22
  :remoter_base => :vmrun,
23
- :remote_base => nil,
24
23
  :server_config => {}
25
24
  )
26
-
27
- def initialize(opts={}, &block)
25
+
26
+ def initialize(o={}, &block)
27
+ using o[:remoter_base], o.delete(:remote_base) if o.has_key?(:remoter_base)
28
28
  super
29
- # self.keypair_name = keypair.basename
30
- # # try and generate the public_key if needed
31
- # if self.authorized_keys.nil?
32
- # self.authorized_keys = keypair.public_key rescue nil
33
- # end
34
29
  end
35
30
 
31
+ def remote_base(n=nil)
32
+ if n.nil?
33
+ @remote_base
34
+ else
35
+ @remote_base = n
36
+ end
37
+ end
38
+
36
39
  def server
37
40
  if @server
38
41
  @server
@@ -46,21 +49,13 @@ module PoolParty
46
49
  end
47
50
  end
48
51
 
49
- def remoter_base_options
50
- dsl_options[:remoter_base_options] = remote_base.dsl_options.choose do |k,v|
51
- v && (v.respond_to?(:empty) ? !v.empty?: true)
52
- end
53
- end
54
-
55
52
  def self.launch_new_instance!(o={})
56
53
  new_instance(o).launch_new_instance!
57
54
  end
58
55
  def launch_new_instance!(o={})
59
- opts =dsl_options.merge(:remoter_base_options=>remoter_base_options)
56
+ opts = to_hash.merge(o)
60
57
  result = JSON.parse(server['/run-instance'].put(opts.to_json)).symbolize_keys!
61
- p result
62
58
  @id = result[:instance_id]
63
- puts "\nid = #{@id}\n---"
64
59
  result
65
60
  end
66
61
  # Terminate an instance by id
@@ -68,27 +63,33 @@ module PoolParty
68
63
  new(nil, o).terminate_instance!
69
64
  end
70
65
  def terminate_instance!(o={})
71
- puts "ID= #{id(o)}"
66
+ opts = to_hash.merge(o)
72
67
  raise "id or instance_id must be set before calling describe_instace" if !id(o)
73
68
  server["/instance/#{id(o)}"].delete
74
69
  end
75
70
 
76
71
  # Describe an instance's status, must pass :vmx_file in the options
77
72
  def self.describe_instance(o={})
78
- new_instance(o).describe_instance
73
+ new(o).describe_instance
79
74
  end
80
75
  def describe_instance(o={})
76
+ opts = to_hash.merge(o)
81
77
  raise "id or instance_id must be set before calling describe_instace" if !id(o)
82
78
  server["/instance/#{id(o)}"].get.json_parse
83
79
  end
84
80
 
85
81
  def self.describe_instances(o={})
86
- new_instance(o).describe_instances
82
+ new(o).describe_instances
87
83
  end
88
84
  def describe_instances(o={})
85
+ opts = to_hash.merge(o)
89
86
  JSON.parse( server["/instances/"].get ).collect{|i| i.symbolize_keys!}
90
87
  end
91
88
 
89
+ def to_hash
90
+ dsl_options.merge(:remote_base => remote_base.to_hash)
91
+ end
92
+
92
93
  private
93
94
  def id(o={})
94
95
  @id = ( o[:id] || o[:instance_id] || @id || dsl_options[:id] || dsl_options[:instance_id] )
@@ -278,17 +278,37 @@ eof
278
278
 
279
279
  def loaded(opts={}, prnt=nil)
280
280
  enable_passenger
281
-
282
281
  port "80" unless self.port
283
282
 
284
- appended_path "current" if opts[:with_deployment_directories]
283
+ has_directory(:name => dir, :owner => www_user, :mode => '0744')
284
+ has_directory(:name => "#{site_directory}", :owner => www_user, :mode => '0744')
285
+ has_directory(:name => "#{site_directory}/logs", :owner => www_user, :mode => '0744')
286
+ if opts[:with_deployment_directories]
287
+ has_directory(:name => "#{site_directory}/shared", :owner => www_user, :mode=>'0744')
288
+ has_directory(:name => "#{site_directory}/shared/public", :owner => www_user, :mode=>'0744')
289
+ has_directory(:name => "#{site_directory}/shared/config", :owner => www_user, :mode=>'0744')
290
+ has_directory(:name => "#{site_directory}/shared/log", :owner => www_user, :mode=>'0744')
291
+ has_directory(:name => "#{site_directory}/releases", :owner => www_user, :mode=>'0744')
292
+ do_once do |variable|
293
+ # setup an initial symlink so apache will start even if there have not been any deploys yet
294
+ has_directory(:name => "#{site_directory}/releases/initial/public", :owner => www_user, :mode=>'0744')
295
+ #FIXME the following line is chef specific. It will fail with puppet
296
+
297
+ # has_symlink(:target_file => "#{dir}/#{name}/current", :to => "#{dir}/#{name}/releases/initial")
298
+ end
299
+ log_dir = "#{site_directory}/shared/log"
300
+ appended_path "current"
301
+ else
302
+ log_dir = "#{site_directory}/log"
303
+ end
304
+
285
305
  passenger_entry <<-EOE
286
306
  <VirtualHost *:#{port}>
287
307
  ServerName #{name}
288
308
  DocumentRoot #{site_directory}/public
289
309
  RailsEnv #{enviornment}
290
- ErrorLog #{site_directory}/log/error_log
291
- CustomLog #{site_directory}/log/access_log common
310
+ ErrorLog #{log_dir}/error_log
311
+ CustomLog #{log_dir}/access_log common
292
312
  </VirtualHost>
293
313
  EOE
294
314
 
@@ -0,0 +1,29 @@
1
+ =begin rdoc
2
+ Authorized key
3
+
4
+ Usage:
5
+ has_authorized_key :for_user => "username",
6
+ :public_key_file => "/Users/alerner/.ssh/id_rsa.pub"
7
+ =end
8
+ module PoolParty
9
+ class Base
10
+ plugin :authorized_key do
11
+
12
+ default_options(
13
+ :for_user => "root",
14
+ :public_key_file => nil
15
+ )
16
+
17
+ def loaded(o={}, &block)
18
+ has_directory "~#{for_user}/.ssh", :owner => for_user
19
+ has_file "~#{for_user}/.ssh/authorized_keys", :content => ""
20
+ has_line_in_file(:line => public_key_content, :file => "~#{for_user}/.ssh/authorized_keys")
21
+ end
22
+
23
+ def public_key_content
24
+ open(public_key_file).read
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -37,8 +37,8 @@ module PoolParty
37
37
 
38
38
  def recipe(file=nil, o={}, &block)
39
39
  if file
40
- file = ::File.expand_path(file)
41
- raise RecipeNotFoundError.new(file) unless ::File.file?(file)
40
+ file = search_in_known_locations(file)
41
+ raise RecipeNotFoundError.new(file) unless file
42
42
 
43
43
  ::FileUtils.mkdir_p "#{basedir}/recipes" unless ::File.directory?("#{basedir}/recipes")
44
44
  ::FileUtils.rm "#{basedir}/recipes/default.rb" if ::File.file?("#{basedir}/recipes/default.rb")
@@ -32,14 +32,14 @@ This will place the contents of ~/path/to/my/site from your machine to /mnt/bob
32
32
  end
33
33
 
34
34
  def package_deploy_directory
35
- ::Suitcase::Zipper.add("#{::File.expand_path(from)}", "user_directory/")
35
+ ::Suitcase::Zipper.add("#{from}", "user_directory/")
36
36
  end
37
37
 
38
38
  def add_unpack_directory
39
39
  has_directory(to)
40
40
  has_exec("unpack-#{::File.basename(to)}-deploy-directory",
41
41
  :requires => get_directory(to),
42
- :command => "cp -R /var/poolparty/dr_configure/user_directory/#{name}/* #{to}")
42
+ :command => "cp -R /var/poolparty/dr_configure/user_directory/#{dir_name}/* #{to}")
43
43
  if owner
44
44
  has_exec(:name => "chown-#{name}", :command => "chown #{owner} -R #{to}")
45
45
  end
@@ -53,6 +53,11 @@ This will place the contents of ~/path/to/my/site from your machine to /mnt/bob
53
53
  `cd #{from} && git pull`
54
54
  end
55
55
 
56
+ private
57
+ def dir_name
58
+ ::File.basename(from)
59
+ end
60
+
56
61
  end
57
62
  end
58
63
  end
@@ -33,8 +33,7 @@ module PoolParty
33
33
  :maximum_instances => 5,
34
34
  :ec2_dir => ENV["EC2_HOME"],
35
35
  :minimum_runtime => Default.minimum_runtime,
36
- :dependency_resolver => ChefResolver,
37
- :remote_base => nil,
36
+ # :dependency_resolver => ChefResolver,
38
37
  :remoter_base => Default.remoter_base,
39
38
  :keypair => nil,
40
39
  :keypair_path => nil,
@@ -128,6 +127,25 @@ module PoolParty
128
127
  setup_defaults
129
128
  end
130
129
 
130
+ # CALLBACKS
131
+ # To hook into the chain of processes that PoolParty uses
132
+ # when launching, bootstrapping, configuring tasks, call
133
+ # these methods in your clouds.rb.
134
+ # Example:
135
+ #
136
+ # after :bootstrap do
137
+ # stuff
138
+ # end
139
+ #
140
+ # These store the blocks into the after/before_blocks on self
141
+ # and are called as appropriate at the runtime
142
+ def after time, &block
143
+ (after_blocks[time.to_sym] ||= []) << block
144
+ end
145
+ def before time, &block
146
+ (before_blocks[time.to_sym] ||= []) << block
147
+ end
148
+
131
149
  # setup defaults for the cloud
132
150
  def setup_defaults
133
151
  set_vars_from_options(:keypair_name => key.basename, :keypair_path => key.full_filepath) rescue nil
@@ -135,8 +153,8 @@ module PoolParty
135
153
  dsl_options[:rules] = {:expand => "#{dsl_options[:expand_when]}",
136
154
  :contract => dsl_options[:contract_when]}
137
155
 
138
- set_dependency_resolver 'chef'
139
- using Default.remoter_base unless remote_base
156
+ dependency_resolver 'chef'
157
+ using Default.remoter_base unless @remote_base
140
158
  end
141
159
 
142
160
  def after_launch_instance(inst=nil)
@@ -256,30 +274,104 @@ module PoolParty
256
274
  true
257
275
  end
258
276
 
259
- def to_json
260
- to_properties_hash.reject{|k,v| k == :remote_base }.to_json
277
+ def to_hash
278
+ hsh = to_properties_hash
279
+ hsh[:options].merge!({:remote_base => remote_base.to_hash})
280
+ # hsh.reject{|k,v| k == :remote_base || k == :cloud}
281
+ hsh
282
+ end
283
+
284
+ def to_h
285
+ to_hash
261
286
  end
262
287
 
263
288
  # TODO: test
264
289
  # ruby -rrubygems -e 'require "poolparty";puts Cloud.load_from_json(open("/etc/poolparty/clouds.json").read).minimum_instances'
265
- def self.load_from_json(str)
266
- parsed = JSON.parse(str).each {|k,v| dsl_options[k.to_sym] = v}
267
- opts= parsed.options
290
+ def self.load_from_json(str, o={})
291
+ if ::File.file?(str)
292
+ str = open(str).read
293
+ end
294
+ parsed = JSON.parse(str).symbolize_keys!
295
+ opts = parsed.options
268
296
  opts["keypair"] = opts["keypair_path"] = opts["keypair_name"]
269
- # cld.remoter_base = PoolParty::Remote.module_eval( schema.options.remoter_base.camelcase )
270
- # opts.remoter_base_class = PoolParty::Remote.module_eval( opts.remoter_base.camelcase )
271
- # opts.remoter_base_class.new opts.remote_base
272
- opts["dependency_resolver"] = options.dependency_resolver.send(:new, opts)
297
+
273
298
  cld = Cloud.new opts.cloud_name.to_sym
274
- cld.dsl_options.merge opts
275
- cld.using opts.remoter_base.to_sym
276
- cld.dsl_options.symbolize_keys!
299
+ cld.dsl_options.merge! opts
300
+ cld.using opts.remoter_base.to_sym, opts.remote_base
301
+ cld.dependency_resolver opts[:dependency_resolver]
302
+
303
+ #TODO: will never run
304
+ unless true || o[:full_stack]
305
+ context_stack.push cld
306
+ cld.ordered_resources = parsed.resources.map do |r|
307
+ case typ = r.delete(:pp_type)
308
+ when "plugin"
309
+ # This may become a problem on the server where the plugins
310
+ # cannot be found. TODO: Fix?!? How? Uh... fake plugin maybe?
311
+ cld.send(r[:name].gsub(/_class/, '').to_sym) do
312
+ set_vars_from_options(r)
313
+ end
314
+ else
315
+ cld.send("has_#{typ}".to_sym, r)
316
+ end
317
+ context_stack.pop
318
+ end
319
+ else
320
+ cld.ordered_resources = parsed.resources
321
+ end
277
322
  cld
278
323
  end
279
324
 
325
+ def remote_base(n=nil)
326
+ if n.nil?
327
+ @remote_base
328
+ else
329
+ @remote_base = n
330
+ end
331
+ end
332
+
280
333
  def tmp_path
281
334
  Default.tmp_path / pool.name / name
282
335
  end
336
+
337
+ # Reset the entire cloud
338
+ def reset!
339
+ reset_remoter_base!
340
+ @build_manifest = @describe_instances = @remote_instances_list = nil
341
+ end
342
+
343
+ # Call before and after configure callbacks
344
+ # on the cloud.
345
+ # These are called from the dynamically defined callback method
346
+ # call_before/after_configure/bootstrap_callbacks
347
+ # from within callbacks.rb
348
+ # If there is a callback block defined for the specific runtime
349
+ # method being called, then the appropriate callback blocks
350
+ # will be accessed and called from within the before/after_ callback
351
+ def before_bootstrap
352
+ before_blocks[:bootstrap].each {|b| b.call(self) } if before_blocks.has_key?(:bootstrap)
353
+ end
354
+ def after_bootstrap
355
+ after_blocks[:bootstrap].each {|b| b.call(self) } if after_blocks.has_key?(:bootstrap)
356
+ end
357
+ def before_configure
358
+ before_blocks[:configure].each {|b| b.call(self) } if before_blocks.has_key?(:configure)
359
+ end
360
+ def after_configure
361
+ after_blocks[:configure].each {|b| b.call(self) } if after_blocks.has_key?(:configure)
362
+ end
363
+
364
+ private
365
+
366
+ # Storage for the after and before callback blocks
367
+ # when calling the callbacks in the cloud. They are stored as hashes with
368
+ # and are filled with arrays of blocks during load-time
369
+ def after_blocks
370
+ @after_blocks ||= {}
371
+ end
372
+ def before_blocks
373
+ @before_blocks ||= {}
374
+ end
283
375
 
284
376
  def pool
285
377
  parent && parent.is_a?(Pool) ? parent : self
@@ -294,14 +386,9 @@ module PoolParty
294
386
  def add_poolparty_base_requirements
295
387
  # poolparty_base_heartbeat
296
388
  poolparty_base_ruby
297
- poolparty_base_packages
389
+ poolparty_base_packages
298
390
  end
299
-
300
- # Reset the entire cloud
301
- def reset!
302
- reset_remoter_base!
303
- @build_manifest = @describe_instances = @remote_instances_list = nil
304
- end
391
+
305
392
  end
306
393
  end
307
394
  end
@@ -37,6 +37,7 @@ module PoolParty
37
37
  EOM
38
38
 
39
39
  PoolParty::Cloud::Cloud.class_eval meth
40
+ PoolParty::Service.add_has_and_does_not_have_methods_for(lowercase_class_name.to_sym)
40
41
  end
41
42
 
42
43
  end
@@ -13,13 +13,17 @@ module PoolParty
13
13
  $context_stack ||= []
14
14
  end
15
15
 
16
- class PoolPartyBaseClass
16
+ class PoolPartyBaseClass
17
17
  attr_reader :init_opts
18
18
 
19
19
  include Parenting, Dslify
20
20
 
21
21
  include PoolParty::DependencyResolverCloudExtensions
22
- # attr_accessor :depth
22
+ include PoolParty::SearchablePaths
23
+
24
+ # attr_accessor :depth
25
+ has_searchable_paths
26
+
23
27
  default_options Default.dsl_options
24
28
 
25
29
  def initialize(opts={}, extra_opts={}, &block)
@@ -49,6 +53,10 @@ module PoolParty
49
53
  loaded(o, &block)
50
54
  end
51
55
  end
56
+
57
+ def search_in_known_locations(filepath, additional_search_paths=[])
58
+ find_file(filepath, [::File.dirname(pool_specfile)])
59
+ end
52
60
 
53
61
  # Add the parent's options to my own and add myself as a service if I am not a resource
54
62
  def add_to_parent_if_parent_exists_and_is_a_service
@@ -73,7 +81,20 @@ module PoolParty
73
81
  # services.merge!({lowercase_class_name.to_sym => serv})
74
82
  end
75
83
  # Container for the services
84
+
85
+ def inspect
86
+ to_properties_hash.inspect
87
+ end
76
88
 
89
+ def to_hash
90
+ to_properties_hash
91
+ end
92
+
93
+ def to_json
94
+ to_hash.to_json
95
+ # JSON.generate(to_hash)
96
+ end
97
+
77
98
  def resources
78
99
  @resources ||= OrderedHash.new
79
100
  end
@@ -141,7 +162,8 @@ module PoolParty
141
162
 
142
163
  def ordered_resources
143
164
  @ordered_resources ||= []
144
- end
165
+ end
166
+ attr_writer :ordered_resources
145
167
 
146
168
  def is_plugin?
147
169
  false
@@ -8,18 +8,13 @@
8
8
  =end
9
9
  module PoolParty
10
10
  module Resources
11
-
12
11
 
13
12
  def custom_file(path, str)
14
13
  write_to_file_in_storage_directory(path, str)
15
14
  end
16
15
 
17
16
  class Resource < PoolParty::PoolPartyBaseClass
18
- include JSON
19
- attr_accessor :prestring, :poststring
20
-
21
- # include CloudResourcer
22
-
17
+
23
18
  # For the time being, we'll make puppet the only available dependency resolution
24
19
  # base, but in the future, we can rip this out and make it an option
25
20
  # include PoolParty::DependencyResolutions::Puppet
@@ -23,6 +23,9 @@ module PoolParty
23
23
  net-scp
24
24
  net-ssh-gateway
25
25
  highline
26
+ flexmock
27
+ lockfile
28
+ rubigen
26
29
  json
27
30
  activesupport
28
31
  grempe-amazon-ec2
@@ -34,6 +37,7 @@ module PoolParty
34
37
  thin
35
38
  logging
36
39
  ruby2ruby
40
+ extlib
37
41
  )
38
42
  end
39
43
 
@@ -127,7 +131,7 @@ module PoolParty
127
131
  def default_commands
128
132
  pack_the_dependencies
129
133
  ::FileUtils.rm_rf "#{cloud.tmp_path}/dependencies/gems/cache"
130
- rsync "#{cloud.tmp_path}/dependencies", '/var/poolparty'
134
+ rsync "#{cloud.tmp_path}/dependencies", '/var/poolparty', ['-v', '-a', '--delete']
131
135
 
132
136
  commands << [
133
137
  "mkdir -p /etc/poolparty",
@@ -30,7 +30,7 @@ The above example will place the contents of '/local/path' at '/path/on/server/n
30
30
 
31
31
  default_options({
32
32
  :recursive => true,
33
- :mode => 0644
33
+ :mode => "0644"
34
34
  })
35
35
 
36
36
  def present
@@ -9,7 +9,7 @@ The symlink resource sets a symlink
9
9
 
10
10
  == Usage
11
11
 
12
- has_symlink(:key => '...') do
12
+ has_symlink(:name => 'target', :source=>'/where/to' ) do
13
13
  # More options.
14
14
  # This block is optional
15
15
  end
@@ -21,11 +21,18 @@ The symlink resource sets a symlink
21
21
 
22
22
  == Examples
23
23
 
24
+ puppet style:
24
25
  has_symlink(:name => "/var/www/poolpartyrb.com/public", :source => "/var/www/poolpartyrb.com/poolparty-website/site")
26
+ chef style:
27
+ has_symlink(:to => "/var/www/poolpartyrb.com/public", :target_file => "/var/www/poolpartyrb.com/poolparty-website/site")
25
28
  =end
26
29
  class Symlink < Resource
27
30
 
28
- dsl_methods :source
31
+ dsl_methods :source,
32
+ :to,
33
+ :target_file
34
+
35
+ default_options :link_type => :symbolic
29
36
 
30
37
  def present
31
38
  :create
@@ -5,13 +5,28 @@ module PoolParty
5
5
 
6
6
  dsl_methods :name, # Name of the user
7
7
  :password, # Password for the user
8
- :home # Home directory
8
+ :home, # Home directory
9
+ :authorized_keys
9
10
 
10
11
 
11
12
  default_options({
12
13
  :shell => "/bin/sh"
13
14
  })
14
15
 
16
+ def after_create
17
+ if authorized_keys
18
+ cloud.has_file :name=>"/home/#{name}/.ssh/authorized_keys", :content => authorized_keys
19
+ end
20
+ end
21
+
22
+ def present
23
+ :create
24
+ end
25
+
26
+ def absent
27
+ :remove
28
+ end
29
+
15
30
  end
16
31
 
17
32
  end
@@ -17,7 +17,6 @@ module PoolParty
17
17
  JSON.parse(h).each {|k,v| self[k.to_sym] = v}
18
18
  end
19
19
  end
20
-
21
20
 
22
21
  def [](k)
23
22
  hsh[k]
@@ -28,7 +27,7 @@ module PoolParty
28
27
  hsh[k.to_sym] = self.class.new(v)
29
28
  else
30
29
  hsh[k.to_sym] = v
31
- end
30
+ end
32
31
  end
33
32
 
34
33
  def to_hash
@@ -51,14 +50,14 @@ module PoolParty
51
50
 
52
51
  def to_cloud(node={})
53
52
  require "ostruct"
54
-
53
+
55
54
  $pool_specfile = "/etc/poolparty/clouds.rb"
56
55
 
57
56
  # TODO: Seriously, make this sexier
58
57
  cld = OpenStruct.new(options)
59
58
  cld.keypair = ::PoolParty::Key.new("/etc/poolparty/#{node[:keypair]}")
60
59
  # cld.remoter_base = PoolParty::Remote.module_eval( schema.options.remoter_base.camelcase )
61
- cld.remote_base = PoolParty::Remote.module_eval( schema.options.remoter_base.camelcase )
60
+ cld.remote_base = PoolParty::Remote.module_eval( self.options.remoter_base.camelcase )
62
61
  cld.build_and_store_new_config_file = "/etc/poolparty/clouds.json"
63
62
  cld.dependency_resolver = PoolParty.module_eval(options.dependency_resolver.split("::")[-1].camelcase).send(:new)
64
63
 
@@ -34,5 +34,5 @@ listen PoolParty-site-<%= @node[:poolparty][:haproxy_name] %>
34
34
  bind 0.0.0.0:<%= @node[:poolparty][:ports_haproxy].join(",0.0.0.0:") %>
35
35
  cookie POOLPARTY
36
36
  <% %x[/usr/bin/server-list-active internal_ip].split("\t").each_with_index do |ip, index| %>
37
- server <%= index == 0 ? "master" : "node#{index}" %> <%= ip %>:<%= @node[:poolparty][:forwarding_port] %> weight 1 check cookie
37
+ server <%= index == 0 ? "master" : "node#{index}" %> <% ip %>:<% @node[:poolparty][:forwarding_port] %> weight 1 check cookie
38
38
  <% end %>
data/lib/poolparty.rb CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH<< File.dirname(__FILE__)
2
2
  # Load required gems
3
3
  #TODO: remove activesupport
4
4
  @required_software = Array.new
5
- %w(rubygems activesupport ftools logging resolv ruby2ruby digest/sha2 json pp).each do |lib|
5
+ %w(rubygems activesupport ftools logging resolv digest/sha2 json pp).each do |lib|
6
6
  begin
7
7
  require lib
8
8
  rescue Exception => e