auser-poolparty 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/Manifest.txt +201 -0
  2. data/PostInstall.txt +17 -0
  3. data/Rakefile +22 -1
  4. data/bin/cloud-add-keypair +0 -0
  5. data/bin/cloud-osxcopy +22 -0
  6. data/bin/cloud-provision +1 -0
  7. data/bin/cloud-start +17 -15
  8. data/bin/cloud-terminate +23 -0
  9. data/bin/pool-start +14 -14
  10. data/bin/pool-start-monitor +1 -0
  11. data/config/hoe.rb +114 -0
  12. data/config/requirements.rb +15 -0
  13. data/lib/poolparty.rb +1 -0
  14. data/lib/poolparty/base_packages/haproxy.rb +32 -31
  15. data/lib/poolparty/base_packages/heartbeat.rb +2 -2
  16. data/lib/poolparty/base_packages/poolparty.rb +9 -3
  17. data/lib/poolparty/base_packages/ruby.rb +10 -0
  18. data/lib/poolparty/core/proc.rb +5 -0
  19. data/lib/poolparty/core/string.rb +1 -1
  20. data/lib/poolparty/helpers/binary.rb +6 -5
  21. data/lib/poolparty/helpers/display.rb +11 -2
  22. data/lib/poolparty/helpers/optioner.rb +6 -3
  23. data/lib/poolparty/helpers/provisioner_base.rb +9 -7
  24. data/lib/poolparty/helpers/provisioners/master.rb +38 -4
  25. data/lib/poolparty/helpers/provisioners/slave.rb +2 -2
  26. data/lib/poolparty/modules/cloud_resourcer.rb +20 -3
  27. data/lib/poolparty/modules/definable_resource.rb +1 -1
  28. data/lib/poolparty/modules/method_missing_sugar.rb +12 -4
  29. data/lib/poolparty/modules/pretty_printer.rb +2 -1
  30. data/lib/poolparty/net/remote.rb +1 -1
  31. data/lib/poolparty/net/remote_bases/ec2.rb +13 -10
  32. data/lib/poolparty/net/remote_instance.rb +3 -2
  33. data/lib/poolparty/net/remoter.rb +33 -18
  34. data/lib/poolparty/net/remoter_base.rb +3 -3
  35. data/lib/poolparty/plugins/gem_package.rb +6 -29
  36. data/lib/poolparty/plugins/git.rb +22 -0
  37. data/lib/poolparty/pool/base.rb +7 -6
  38. data/lib/poolparty/pool/cloud.rb +34 -5
  39. data/lib/poolparty/pool/custom_resource.rb +4 -4
  40. data/lib/poolparty/pool/plugin.rb +13 -14
  41. data/lib/poolparty/pool/resource.rb +19 -10
  42. data/lib/poolparty/pool/resources/class_package.rb +10 -6
  43. data/lib/poolparty/pool/resources/conditional.rb +41 -0
  44. data/lib/poolparty/pool/resources/gem.rb +2 -2
  45. data/lib/poolparty/pool/script.rb +25 -2
  46. data/lib/poolparty/templates/haproxy.conf +1 -1
  47. data/lib/poolparty/templates/puppet.conf +4 -2
  48. data/lib/poolparty/version.rb +1 -1
  49. data/poolparty.gemspec +60 -0
  50. data/setup.rb +1585 -0
  51. data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
  52. data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
  53. data/spec/poolparty/bin/console_spec.rb +80 -0
  54. data/spec/poolparty/core/array_spec.rb +26 -0
  55. data/spec/poolparty/core/float.rb +13 -0
  56. data/spec/poolparty/core/hash_spec.rb +63 -0
  57. data/spec/poolparty/core/kernel_spec.rb +24 -0
  58. data/spec/poolparty/core/module_spec.rb +15 -0
  59. data/spec/poolparty/core/object_spec.rb +40 -0
  60. data/spec/poolparty/core/string_spec.rb +152 -0
  61. data/spec/poolparty/core/time_spec.rb +52 -0
  62. data/spec/poolparty/helpers/binary_spec.rb +26 -0
  63. data/spec/poolparty/helpers/display_spec.rb +13 -0
  64. data/spec/poolparty/helpers/optioner_spec.rb +39 -0
  65. data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
  66. data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
  67. data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
  68. data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
  69. data/spec/poolparty/modules/configurable_spec.rb +26 -0
  70. data/spec/poolparty/modules/definable_resource.rb +9 -0
  71. data/spec/poolparty/modules/file_writer_spec.rb +49 -0
  72. data/spec/poolparty/modules/s3_string_spec.rb +15 -0
  73. data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
  74. data/spec/poolparty/net/remote_instance_spec.rb +70 -0
  75. data/spec/poolparty/net/remote_spec.rb +286 -0
  76. data/spec/poolparty/net/remoter_base_spec.rb +80 -0
  77. data/spec/poolparty/net/remoter_spec.rb +191 -0
  78. data/spec/poolparty/plugins/git_spec.rb +19 -0
  79. data/spec/poolparty/plugins/line_spec.rb +16 -0
  80. data/spec/poolparty/plugins/svn_spec.rb +16 -0
  81. data/spec/poolparty/pool/base_spec.rb +108 -0
  82. data/spec/poolparty/pool/cloud_spec.rb +299 -0
  83. data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
  84. data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
  85. data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
  86. data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
  87. data/spec/poolparty/pool/example_spec.rb +112 -0
  88. data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
  89. data/spec/poolparty/pool/plugin_spec.rb +85 -0
  90. data/spec/poolparty/pool/pool_spec.rb +83 -0
  91. data/spec/poolparty/pool/resource_spec.rb +224 -0
  92. data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
  93. data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
  94. data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
  95. data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
  96. data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
  97. data/spec/poolparty/pool/resources/file_spec.rb +40 -0
  98. data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
  99. data/spec/poolparty/pool/resources/host_spec.rb +28 -0
  100. data/spec/poolparty/pool/resources/package_spec.rb +44 -0
  101. data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
  102. data/spec/poolparty/pool/resources/service_spec.rb +45 -0
  103. data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
  104. data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
  105. data/spec/poolparty/pool/script_spec.rb +51 -0
  106. data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
  107. data/spec/poolparty/pool/test_plugins/virtual_host_template.erb +0 -0
  108. data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
  109. data/spec/poolparty/poolparty_spec.rb +33 -0
  110. data/spec/poolparty/spec_helper.rb +120 -0
  111. data/test/test_generator_helper.rb +29 -0
  112. data/test/test_helper.rb +2 -0
  113. data/test/test_pool_spec_generator.rb +47 -0
  114. data/test/test_poolparty.rb +11 -0
  115. data/website/index.html +81 -0
  116. data/website/index.txt +72 -0
  117. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  118. data/website/stylesheets/screen.css +138 -0
  119. data/website/template.html.erb +48 -0
  120. metadata +178 -60
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "directory" do
6
+ describe "instances" do
7
+ before(:each) do
8
+ @directory = directory({:name => "/etc/apache2/puppetmaster.conf"})
9
+ end
10
+ it "should turn the one hash instance into a string" do
11
+ @directory.to_string.should =~ /"\/etc\/apache2\/puppetmaster\.conf":/
12
+ end
13
+ it "should turn the two hash instance into a string" do
14
+ @directory = directory do
15
+ name "/etc/init.d/puppetmaster"
16
+ owner "redsmith"
17
+ end
18
+ @directory.to_string.should =~ /"\/etc\/init\.d\/puppetmaster":/
19
+ end
20
+ describe "as included" do
21
+ before(:each) do
22
+ @directory = directory({:rent => "low"}) do
23
+ name "/www/conf/httpd.conf"
24
+ end
25
+ end
26
+ it "should use default values" do
27
+ @directory.name.should == "/www/conf/httpd.conf"
28
+ end
29
+ it "should keep the default values for the directory" do
30
+ @directory.mode.should == 644
31
+ end
32
+ it "should also set options through a hash" do
33
+ @directory.rent.should == "low"
34
+ end
35
+ it "should have ensure set to directory" do
36
+ @directory.ensure.should == "directory"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Exec" do
6
+ before(:each) do
7
+ @exec = exec({:name => "/usr/bin/ifconfig"})
8
+ end
9
+ describe "instances" do
10
+ it "should turn the one hash instance into a string" do
11
+ @exec.to_string.should =~ /exec \{\n"\/usr\/bin\/ifconfig"/
12
+ end
13
+ it "should turn the two hash instance into a string" do
14
+ @exec = exec({:name => "/usr/bin/ping 127.0.0.1"})
15
+ @exec.to_string.should =~ /"\/usr\/bin\/ping 127\.0\.0\.1":/
16
+ end
17
+ describe "as included" do
18
+ before(:each) do
19
+ @exec = exec({:rent => "low", :ensures => "running"}) do
20
+ name "/www/conf/httpd.conf"
21
+ end
22
+ end
23
+ it "should use default values" do
24
+ @exec.name.should == "/www/conf/httpd.conf"
25
+ end
26
+ it "should keep the default values for the exec" do
27
+ @exec.path.should =~ /\/usr\/bin:\/bin:\/usr\/local\/bin/
28
+ end
29
+ it "should also set options through a hash" do
30
+ @exec.rent.should == "low"
31
+ end
32
+ it "should ensure running, not the default 'present'" do
33
+ @exec.ensure.should == "running"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "File" do
6
+ describe "instances" do
7
+ before(:each) do
8
+ @file = file({:name => "/etc/apache2/puppetmaster.conf"})
9
+ end
10
+ it "should turn the one hash instance into a string" do
11
+ @file.to_string.should =~ /"\/etc\/apache2\/puppetmaster\.conf":/
12
+ end
13
+ it "should turn the two hash instance into a string" do
14
+ @file = file do
15
+ name "/etc/init.d/puppetmaster"
16
+ owner "redsmith"
17
+ end
18
+ @file.to_string.should =~ /"\/etc\/init\.d\/puppetmaster":/
19
+ end
20
+ describe "as included" do
21
+ before(:each) do
22
+ @file = file({:rent => "low"}) do
23
+ name "/www/conf/httpd.conf"
24
+ end
25
+ end
26
+ it "should use default values" do
27
+ @file.name.should == "/www/conf/httpd.conf"
28
+ end
29
+ it "should keep the default values for the file" do
30
+ @file.mode.should == 644
31
+ end
32
+ it "should also set options through a hash" do
33
+ @file.rent.should == "low"
34
+ end
35
+ it "should have ensure set to file" do
36
+ @file.ensure.should == "file"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Gem" do
6
+ before(:each) do
7
+ reset!
8
+ @gem = gem(:name => "rails")
9
+ end
10
+ it "should have a package" do
11
+ resource(:package).should_not be_empty
12
+ end
13
+ it "should have the 'rails' gem in the packages" do
14
+ @gem.to_string.should =~ /Package\[rubygems\]/
15
+ end
16
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Host" do
6
+ describe "instances" do
7
+ before(:each) do
8
+ @host = host({:name => "node1"})
9
+ end
10
+ it "should turn the one hash instance into a string" do
11
+ @host.to_string.should =~ /node1/
12
+ end
13
+ describe "as included" do
14
+ before(:each) do
15
+ @host = host do
16
+ name "master"
17
+ ip "192.168.0.1"
18
+ end
19
+ end
20
+ it "should use default values" do
21
+ @host.name.should == "master"
22
+ end
23
+ it "should also set options through a hash" do
24
+ @host.ip.should == "192.168.0.1"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Package" do
6
+ before(:each) do
7
+ @cloud = cloud :app do;end
8
+ @package = PoolParty::Resources::Package.new({}, @cloud)
9
+ end
10
+ describe "instances" do
11
+ before(:each) do
12
+ @package = package({:name => "/etc/apache2/puppetmaster.conf"})
13
+ end
14
+ it "should turn the one hash instance into a string" do
15
+ @package.to_string.should =~ /"\/etc\/apache2\/puppetmaster\.conf":/
16
+ end
17
+ it "should turn the two hash instance into a string" do
18
+ @package = package({:name => "/etc/init.d/puppetmaster"})
19
+ @package.to_string.should =~ /"\/etc\/init\.d\/puppetmaster":/
20
+ end
21
+ describe "as included" do
22
+ before(:each) do
23
+ @cloud = cloud :included_package do
24
+ package({:rent => "low"}) do
25
+ name "/www/conf/httpd.conf"
26
+ end
27
+ end
28
+ @package = @cloud.resource(:package).first
29
+ end
30
+ it "should use default values" do
31
+ @package.name.should == "/www/conf/httpd.conf"
32
+ end
33
+ it "should have the cloud as the parent" do
34
+ @package.parent.should == @cloud
35
+ end
36
+ it "should keep the default values for the Package" do
37
+ @package.alias.should == nil
38
+ end
39
+ it "should also set options through a hash" do
40
+ @package.rent.should == "low"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Remote file" do
6
+ describe "instances" do
7
+ before(:each) do
8
+ @file = remotefile({:name => "/etc/apache2/puppetmaster.conf"})
9
+ end
10
+ it "should turn the one hash instance into a string" do
11
+ @file.to_string.should =~ /"\/etc\/apache2\/puppetmaster\.conf":/
12
+ end
13
+ it "should turn the two hash instance into a string" do
14
+ @file = file do
15
+ name "/etc/init.d/puppetmaster"
16
+ owner "redsmith"
17
+ end
18
+ @file.to_string.should =~ /"\/etc\/init\.d\/puppetmaster":/
19
+ end
20
+ describe "as included" do
21
+ before(:each) do
22
+ @file = remotefile({:rent => "low"}) do
23
+ name "/www/conf/httpd.conf"
24
+ end
25
+ end
26
+ it "should have the source set to puppet" do
27
+ @file.source.should == "puppet:///files/httpd.conf"
28
+ end
29
+ it "should use default values" do
30
+ @file.name.should == "/www/conf/httpd.conf"
31
+ end
32
+ it "should keep the default values for the file" do
33
+ @file.mode.should == 644
34
+ end
35
+ it "should also set options through a hash" do
36
+ @file.rent.should == "low"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Service" do
6
+ before(:each) do
7
+ reset_resources!
8
+ @service = PoolParty::Resources::Service.new
9
+ end
10
+ describe "instances" do
11
+ before(:each) do
12
+ @service = service({:name => "/etc/apache2/puppetmaster.conf"})
13
+ end
14
+ it "should turn the one hash instance into a string" do
15
+ @service.to_string.should =~ /"\/etc\/apache2\/puppetmaster\.conf":/
16
+ end
17
+ it "should turn the two hash instance into a string" do
18
+ @service = service({:name => "/etc/init.d/puppetmaster"})
19
+ @service.to_string.should =~ /"\/etc\/init\.d\/puppetmaster":/
20
+ end
21
+ describe "as included" do
22
+ before(:each) do
23
+ reset_resources!
24
+ @service = service({:rent => "low", :ensure => "stopped"}) do
25
+ name "mdmdp"
26
+ end
27
+ end
28
+ it "should use default values" do
29
+ @service.name.should == "mdmdp"
30
+ end
31
+ it "should keep the default values for the Service" do
32
+ @service.enable.should == true
33
+ end
34
+ it "should also set options through a hash" do
35
+ @service.rent.should == "low"
36
+ end
37
+ it "should also set options through a hash" do
38
+ @service.ensure.should == "stopped"
39
+ end
40
+ it "should set ensure as a default if it's not passed" do
41
+ service(:name => "romp").ensure.should == "running"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "SshKey" do
6
+ describe "instances" do
7
+ before(:each) do
8
+ reset_resources!
9
+ end
10
+ it "should turn the one hash instance into a string" do
11
+ @key = sshkey({:name => "rock"})
12
+ @key.to_string.should =~ /"rock":\n/
13
+ end
14
+ it "should turn the two hash instance into a string" do
15
+ @key = sshkey do
16
+ name "poolparty_key"
17
+ end
18
+ @key.to_string.should =~ /"poolparty_key":/
19
+ end
20
+ describe "sizes" do
21
+ before(:each) do
22
+ sshkey({:name => "rock"})
23
+ sshkey({:name => "dos"})
24
+ sshkey({:name => "equis"})
25
+ end
26
+ it "should contain two keyfiles if two are specified" do
27
+ resource(:sshkey).size.should == 3
28
+ end
29
+ end
30
+ describe "file" do
31
+ before(:each) do
32
+ reset_resources!
33
+ @sshkey = PoolParty::Resources::Sshkey.new
34
+ @string = "ALONGSTRINGOFDIGITS"
35
+ @file = File.join(File.dirname(__FILE__), "..", "test_plugins", "sshkey_test")
36
+ @string.stub!(:read).and_return @string
37
+ end
38
+ it "should read the file when sent keyfile=" do
39
+ @sshkey.should_receive(:open).and_return @string
40
+ @sshkey.keyfile = @file
41
+ end
42
+ it "should set the keyfile as the contents of the file" do
43
+ @sshkey.keyfile = @file
44
+ @sshkey.keyfile.should =~ /THIS IS A TEST/
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ include PoolParty::Resources
4
+
5
+ describe "Variable" do
6
+ before(:each) do
7
+ reset!
8
+ @variable = variable(:name => "name", :value => "ari Lerner")
9
+ end
10
+ it "should have a package" do
11
+ resource(:variable).should_not be_empty
12
+ end
13
+ it "should have the 'name' variable set as a variable" do
14
+ @variable.to_string.should =~ /\$name = 'ari Lerner'/
15
+ end
16
+ it "should be able to set the variable as an array if passed an array" do
17
+ v = variable(:name => "girlfriends", :value => %w(Rachel Erica Michelle))
18
+ v.to_string.should == "$girlfriends = [ 'Rachel', 'Erica', 'Michelle' ]"
19
+ end
20
+ end
@@ -0,0 +1,51 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Script" do
4
+ it "should have inflate as a class method" do
5
+ Script.respond_to?(:inflate).should == true
6
+ end
7
+ it "should have inflate_file as an instance method" do
8
+ Script.respond_to?(:inflate_file).should == true
9
+ end
10
+ it "should have inflate as an instance method" do
11
+ Script.new.respond_to?(:inflate).should == true
12
+ end
13
+
14
+ describe "with a script" do
15
+ before(:each) do
16
+ @script = 'script'
17
+ @filename = 'filename'
18
+
19
+ @pool = Script.new
20
+ Script.stub!(:new).and_return(@pool)
21
+ @pool.stub!(:inflate).and_return true
22
+ end
23
+
24
+ it "should create a new Script when calling on the class method" do
25
+ Script.should_receive(:new).and_return @pool
26
+ end
27
+ it "should instance eval the script" do
28
+ @pool.should_receive(:instance_eval).with(@script, @filename).and_return true
29
+ end
30
+ it "should call inflate on itself" do
31
+ @pool.should_receive(:inflate).and_return true
32
+ end
33
+ after do
34
+ Script.inflate(@script, @filename)
35
+ end
36
+ describe "save!" do
37
+ before(:each) do
38
+ pool :appdotcom do
39
+ keypair "snoodle"
40
+ cloud :app do
41
+ has_file :name => "/etc/httpd/httpd.conf"
42
+ end
43
+ end
44
+ @saved = Script.save!(false)
45
+ end
46
+ it "should save the keypair" do
47
+ @saved.should =~ /keypair "snoodle"/
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,2 @@
1
+ -- THIS IS A TEST SSH KEY FILE --
2
+
@@ -0,0 +1,46 @@
1
+ class WebServers
2
+ plugin :apache do
3
+
4
+ attr_accessor :php
5
+
6
+ def enable
7
+ end
8
+
9
+ def enable_php
10
+ @php = true
11
+ php
12
+ end
13
+
14
+ def php
15
+ @php
16
+ end
17
+
18
+ def site(name=:domain1, opts={})
19
+ virtual_host name, opts
20
+ end
21
+
22
+ def virtual_host(name, opts={})
23
+ opts = {
24
+ :document_root => opts[:document_root] || "/www/#{name}/"
25
+ }
26
+ call_function "virtual_host()"
27
+ end
28
+
29
+ custom_function <<-EOE
30
+ define virtual_host($docroot, $ip, $order = 500, $ensure = "enabled") {
31
+ $file = "/etc/sites-available/$name.conf"
32
+ file { $file:
33
+ content => template("virtual_host.erb"),
34
+ notify => Service[apache]
35
+ }
36
+ file { "/etc/sites-enabled/$order-$name.conf":
37
+ ensure => $ensure ? {
38
+ enabled => $file,
39
+ disabled => absent
40
+ }
41
+ }
42
+ }
43
+ EOE
44
+
45
+ end
46
+ end