auser-poolparty 0.2.57 → 0.2.58

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/Manifest.txt CHANGED
@@ -225,8 +225,10 @@ lib/poolparty/net/remote_bases/ec2.rb
225
225
  lib/poolparty/net/remote_instance.rb
226
226
  lib/poolparty/net/remoter.rb
227
227
  lib/poolparty/net/remoter_base.rb
228
+ lib/poolparty/plugins/deploydirectory.rb
228
229
  lib/poolparty/plugins/git.rb
229
230
  lib/poolparty/plugins/line.rb
231
+ lib/poolparty/plugins/rsyncmirror.rb
230
232
  lib/poolparty/plugins/runit.rb
231
233
  lib/poolparty/plugins/svn.rb
232
234
  lib/poolparty/pool/base.rb
@@ -313,6 +315,7 @@ spec/poolparty/net/remote_instance_spec.rb
313
315
  spec/poolparty/net/remote_spec.rb
314
316
  spec/poolparty/net/remoter_base_spec.rb
315
317
  spec/poolparty/net/remoter_spec.rb
318
+ spec/poolparty/plugins/deploydirectory_spec.rb
316
319
  spec/poolparty/plugins/git_spec.rb
317
320
  spec/poolparty/plugins/line_spec.rb
318
321
  spec/poolparty/plugins/svn_spec.rb
data/bin/pool-init ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ # First, let's generate the spec
7
+ if %w(-v --version).include? ARGV.first
8
+ require 'poolspec/version'
9
+ puts "#{File.basename($0)} #{Poolspec::VERSION::STRING}"
10
+ exit(0)
11
+ end
12
+
13
+ name = ARGV.first
14
+
15
+ vputs "Creating pool named #{name}"
16
+
17
+ require 'rubigen/scripts/generate'
18
+ source = RubiGen::PathSource.new(:application,
19
+ File.join(File.dirname(__FILE__), "../generators"))
20
+ RubiGen::Base.reset_sources
21
+ RubiGen::Base.append_sources source
22
+ RubiGen::Scripts::Generate.new.run(*ARGV, :generator => 'poolspec')
23
+
24
+ # Now add the keypairs for the pool based on the default pool name and cloud name
25
+
26
+ @pool = load_pool(self.spec || Binary.get_existing_spec_location)
27
+ @clouds = [@pool.cloud("#{name}_app")]
28
+
29
+ @clouds.each do |cloud|
30
+ with_cloud(cloud) do
31
+ vputs header("Creating keypair for #{name}")
32
+ create_keypair unless testing
33
+ end
34
+ end
@@ -6,8 +6,9 @@ module PoolParty
6
6
  # Build hostsfile
7
7
  # TODO: COME BACK AND CLEAN THIS UP
8
8
  (self.respond_to?(:list_of_running_instances) ? self : parent).list_of_running_instances.each do |ri|
9
- has_host({:name => "#{ri.name}", :ip => ri.ip })
10
- end
9
+ has_host({:name => "gen_#{ri.name}", :ip => ri.ip, :alias => "#{ri.name}" })
10
+ end
11
+ has_host({:alias => "$hostname", :name => "$hostname", :ip => "localhost"})
11
12
 
12
13
  has_package(:name => "erlang")
13
14
  has_package(:name => "erlang-dev")
@@ -27,6 +27,9 @@ class String
27
27
  def sanitize
28
28
  self.gsub(/[ \.\/\-]*/, '')
29
29
  end
30
+ def dir_safe
31
+ self.downcase.gsub(/[ ]/, '_')
32
+ end
30
33
  def nice_runnable(quite=true)
31
34
  self.split(/ && /).join("\n")
32
35
  end
@@ -13,11 +13,13 @@ module PoolParty
13
13
  def binary_directory
14
14
  "#{::File.dirname(__FILE__)}/../../../bin"
15
15
  end
16
+ # These are the locations the spec file can be before the cloud
17
+ # aborts because it cannot load the cloud
16
18
  def get_existing_spec_location
17
19
  [
18
20
  "#{Base.remote_storage_path}/#{Base.default_specfile_name}",
19
- ENV["POOL_SPEC"],
20
21
  "#{Base.default_specfile_name}",
22
+ ENV["POOL_SPEC"],
21
23
  "#{Base.storage_directory}/#{Base.default_specfile_name}",
22
24
  "#{Base.default_project_specfile_name}"
23
25
  ].reject {|a| a.nil?}.reject do |f|
@@ -25,7 +25,9 @@ module PoolParty
25
25
  setup_autosigning,
26
26
  install_poolparty,
27
27
  setup_poolparty,
28
- start_puppetmaster
28
+ start_puppetmaster,
29
+ restart_puppetd,
30
+ clean_master_certs
29
31
  ] << configure_tasks
30
32
  end
31
33
 
@@ -129,7 +131,6 @@ ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string} #
129
131
  rm -rf /etc/puppet/ssl
130
132
  # Start it back up
131
133
  puppetmasterd --verbose
132
- /usr/bin/puppetcleaner
133
134
  # /etc/init.d/puppetmaster start #{unix_hide_string}
134
135
  EOS
135
136
  end
@@ -168,6 +169,7 @@ cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolpa
168
169
  returning String.new do |s|
169
170
  s << "puppetca --clean master.compute-1.internal 2>&1 > /dev/null;"
170
171
  s << "puppetca --clean master.ec2.internal 2>&1 > /dev/null"
172
+ s << "/usr/bin/puppetcleaner"
171
173
  end
172
174
  end
173
175
 
@@ -41,7 +41,8 @@ module PoolParty
41
41
  end
42
42
  def make_base_path(path)
43
43
  unless FileTest.directory?(path)
44
- begin
44
+ begin
45
+ ::FileUtils.rm path if ::File.file?(path)
45
46
  ::FileUtils.mkdir_p path
46
47
  rescue Errno::ENOTDIR
47
48
  rescue Errno::EEXIST
@@ -50,11 +51,21 @@ module PoolParty
50
51
  end
51
52
  end
52
53
  def make_base_directory
53
- FileUtils.mkdir_p Base.storage_directory unless ::File.directory?(Base.storage_directory)
54
+ begin
55
+ FileUtils.mkdir_p Base.storage_directory unless ::File.directory?(Base.storage_directory)
56
+ rescue Errno::EEXIST
57
+ FileUtils.rm Base.storage_directory
58
+ make_base_directory
59
+ end
54
60
  end
55
61
  def make_template_directory(dir=nil)
56
62
  path = dir ? ::File.join(Base.tmp_path, Base.template_directory, ::File.basename(dir)) : ::File.join(Base.tmp_path, Base.template_directory)
57
- FileUtils.mkdir_p path unless ::File.directory?(path)
63
+ begin
64
+ FileUtils.mkdir_p path unless ::File.directory?(path)
65
+ rescue Errno::EEXIST
66
+ FileUtils.rm path
67
+ make_template_directory(dir)
68
+ end
58
69
  path
59
70
  end
60
71
  def clear_base_directory
@@ -7,10 +7,8 @@ require File.dirname(__FILE__) + "/../helpers/provisioner_base"
7
7
  module PoolParty
8
8
  module Remote
9
9
  module Remoter
10
- def rsync_storage_files_to_command(remote_instance)
11
- if remote_instance
12
- "#{rsync_command} #{Base.storage_directory}/ #{remote_instance.ip}:#{Base.remote_storage_path}"
13
- end
10
+ def rsync_storage_files_to_command(remote_instance)
11
+ "#{rsync_command} #{Base.storage_directory}/ #{remote_instance.ip}:#{Base.remote_storage_path}" if remote_instance
14
12
  end
15
13
  def run_command_on_command(cmd="ls -l", remote_instance=nil)
16
14
  vputs "Running #{cmd} on #{remote_instance.name == %x[hostname].chomp ? "self (master)" : "#{remote_instance.name}"}"
@@ -0,0 +1,51 @@
1
+ module PoolParty
2
+ class Deploydirectory
3
+
4
+ virtual_resource(:deploydirectory) do
5
+
6
+ def loaded(opts={}, parent=self)
7
+ package_directory
8
+ execute_on_master do
9
+ unpack_directory
10
+ end
11
+ has_rsync_mirror(:dir => cwd)
12
+ end
13
+
14
+ def package_directory
15
+ path = ::File.join( Base.tmp_path, "#{::File.basename(from_dir)}.tar.gz" )
16
+ # cd /Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/poolparty/spec/poolparty/plugins/ && tar -czf plugins.tar.gz . && mv plugins.tar.gz /tmp/poolparty && cd /tmp/poolparty
17
+ cmd = "cd #{::File.expand_path(from_dir)} && tar -czf #{name.dir_safe}.tar.gz . && mv #{name.dir_safe}.tar.gz #{Base.tmp_path}"
18
+ `#{cmd}` unless testing
19
+ end
20
+
21
+ def unpack_directory
22
+ has_exec({:name => "deploy-directory-#{name}", :requires => get_directory("#{cwd}"), :cwd => cwd}) do
23
+ command "cd #{parent.cwd}; tar -zxf #{Base.remote_storage_path}/#{parent.name.dir_safe}.tar.gz && rm #{Base.tmp_path}/#{parent.name.dir_safe}.tar.gz"
24
+ end
25
+ end
26
+
27
+ def from(dir)
28
+ from_dir (dir.include?(" ") ? dir.gsub(/[ ]/, '') : dir)
29
+ end
30
+
31
+ def to(dir)
32
+ cwd dir
33
+ has_directory(:name => "#{dir}", :requires => get_directory("#{::File.dirname(dir)}"))
34
+ end
35
+
36
+ # Since git is not a native type, we have to say which core resource
37
+ # it is using to be able to require it
38
+ def class_type_name
39
+ "exec"
40
+ end
41
+
42
+ # Because we are requiring an exec, instead of a built-in package of the git, we have to overload
43
+ # the to_s method and prepend it with the same name as above
44
+ def key
45
+ "deploy-directory-#{name}"
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,29 @@
1
+ module PoolParty
2
+ class Git
3
+
4
+ virtual_resource(:rsyncmirror) do
5
+
6
+ def loaded(opts={}, parent=self)
7
+ has_rsync_mirror(opts, parent)
8
+ end
9
+
10
+ def has_rsync_mirror(opts={}, parent=self)
11
+ has_exec(:command => "rsync -aRqv --no-implied-dirs --delete --delete-excluded '#{Base.user}@master:#{opts[:dir]}' '#{opts[:dir]}'", :name => "rsync-#{name}")
12
+ end
13
+
14
+ # Since git is not a native type, we have to say which core resource
15
+ # it is using to be able to require it
16
+ def class_type_name
17
+ "exec"
18
+ end
19
+
20
+ # Because we are requiring an exec, instead of a built-in package of the git, we have to overload
21
+ # the to_s method and prepend it with the same name as above
22
+ def key
23
+ "rsync-#{name}"
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -168,7 +168,7 @@ module PoolParty
168
168
  :subscribe, :owner, :group, :path, :mode, :source, :notify, :subscribe, :check, :creates, :cwd, :command, :ensure,
169
169
  :require, :schedule, :range, :alias, :hour, :minute, :user, :month, :monthday, :name, :onlyif, :unless, :refreshonly,
170
170
  :refresh, :content, :template, :ip, :repeat, :provider, :key, :device, :fstype, :remounts, :options, :atboot, :before,
171
- :binary, :status, :start, :stop, :restart, :pattern
171
+ :binary, :status, :start, :stop, :restart, :pattern, :recurse
172
172
  ]
173
173
  end
174
174
  def key
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 57
5
+ TINY = 58
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/poolparty.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.57
4
+ version: 0.2.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner
@@ -333,8 +333,10 @@ files:
333
333
  - lib/poolparty/net/remote_instance.rb
334
334
  - lib/poolparty/net/remoter.rb
335
335
  - lib/poolparty/net/remoter_base.rb
336
+ - lib/poolparty/plugins/deploydirectory.rb
336
337
  - lib/poolparty/plugins/git.rb
337
338
  - lib/poolparty/plugins/line.rb
339
+ - lib/poolparty/plugins/rsyncmirror.rb
338
340
  - lib/poolparty/plugins/runit.rb
339
341
  - lib/poolparty/plugins/svn.rb
340
342
  - lib/poolparty/pool/base.rb
@@ -421,6 +423,7 @@ files:
421
423
  - spec/poolparty/net/remote_spec.rb
422
424
  - spec/poolparty/net/remoter_base_spec.rb
423
425
  - spec/poolparty/net/remoter_spec.rb
426
+ - spec/poolparty/plugins/deploydirectory_spec.rb
424
427
  - spec/poolparty/plugins/git_spec.rb
425
428
  - spec/poolparty/plugins/line_spec.rb
426
429
  - spec/poolparty/plugins/svn_spec.rb
@@ -147,6 +147,9 @@ listen web_proxy 127.0.0.1:3000
147
147
  it "should remove the periods from the string" do
148
148
  "xnot.org".sanitize.should == "xnotorg"
149
149
  end
150
+ it "should be able to turn a string into a dir safe name" do
151
+ "Rails app/".dir_safe.should == "rails_app/"
152
+ end
150
153
  end
151
154
  describe "nice_runnable" do
152
155
  before(:each) do
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ class TestClass
6
+ include PoolParty::Resources
7
+ end
8
+ describe "Remote Instance" do
9
+ before(:each) do
10
+ reset_resources!
11
+ end
12
+ describe "wrapped" do
13
+ before(:each) do
14
+ @tc = TestClass.new
15
+ @options = {:name => "deploydirectory", :from => ::File.dirname(__FILE__), :to => "/var/www/deploydirectory", :testing => false}
16
+ end
17
+ it "should be a string" do
18
+ @tc.has_deploydirectory(@options).to_string.should =~ /exec \{/
19
+ end
20
+ it "should included the flushed out options" do
21
+ @tc.has_deploydirectory(@options).to_string.should =~ /command/
22
+ end
23
+ describe "in resource" do
24
+ before(:each) do
25
+ @tc.instance_eval do
26
+ has_deploydirectory do
27
+ name "deploydirectory"
28
+ from ::File.dirname(__FILE__)
29
+ to "/var/www/deploydirectory"
30
+ end
31
+ end
32
+ end
33
+ it "should have the path set within the resource" do
34
+ @tc.resource(:deploydirectory).first.to_string.should =~ /exec \{/
35
+ end
36
+ it "should not have the from in the to_string" do
37
+ @tc.resource(:deploydirectory).first.to_string.should_not =~ /from /
38
+ end
39
+ it "should not have the to in the to_string" do
40
+ @tc.resource(:deploydirectory).first.to_string.should_not =~ /to /
41
+ end
42
+ end
43
+ end
44
+ end
@@ -284,7 +284,7 @@ describe "Cloud" do
284
284
  File.open("test_manifest.pp", "w+") {|f| f << @manifest}
285
285
  end
286
286
  it "should include the hosts for all the listed local instances" do
287
- @manifest.should =~ /host \{\n\t\t"master":/
287
+ @manifest.should =~ /host \{\n\t\t"gen_master":/
288
288
  end
289
289
  end
290
290
  describe "building with an existing manifest" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auser-poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.57
4
+ version: 0.2.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner
@@ -333,8 +333,10 @@ files:
333
333
  - lib/poolparty/net/remote_instance.rb
334
334
  - lib/poolparty/net/remoter.rb
335
335
  - lib/poolparty/net/remoter_base.rb
336
+ - lib/poolparty/plugins/deploydirectory.rb
336
337
  - lib/poolparty/plugins/git.rb
337
338
  - lib/poolparty/plugins/line.rb
339
+ - lib/poolparty/plugins/rsyncmirror.rb
338
340
  - lib/poolparty/plugins/runit.rb
339
341
  - lib/poolparty/plugins/svn.rb
340
342
  - lib/poolparty/pool/base.rb
@@ -421,6 +423,7 @@ files:
421
423
  - spec/poolparty/net/remote_spec.rb
422
424
  - spec/poolparty/net/remoter_base_spec.rb
423
425
  - spec/poolparty/net/remoter_spec.rb
426
+ - spec/poolparty/plugins/deploydirectory_spec.rb
424
427
  - spec/poolparty/plugins/git_spec.rb
425
428
  - spec/poolparty/plugins/line_spec.rb
426
429
  - spec/poolparty/plugins/svn_spec.rb