auser-poolparty 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/cloud-bootstrap +1 -0
  3. data/bin/cloud-configure +1 -0
  4. data/bin/cloud-contract +1 -0
  5. data/bin/poolparty-setup +36 -0
  6. data/examples/vmware.rb +18 -0
  7. data/lib/cloud_providers/cloud_provider_instance.rb +1 -1
  8. data/lib/core/object.rb +2 -2
  9. data/lib/dependency_resolvers/chef.rb +2 -2
  10. data/lib/mixins/askable.rb +16 -7
  11. data/lib/poolparty/base.rb +9 -7
  12. data/lib/poolparty/cloud.rb +57 -2
  13. data/lib/poolparty/installer.rb +8 -4
  14. data/lib/poolparty/installers/ec2.rb +75 -5
  15. data/lib/poolparty/installers/vmware.rb +17 -5
  16. data/lib/poolparty/plugins/apache.rb +3 -2
  17. data/lib/poolparty/plugins/apache2/base.conf.erb +2 -2
  18. data/lib/poolparty/plugins/apache2/browser_fixes.conf.erb +1 -1
  19. data/lib/poolparty/plugins/apache2/passenger_site.rb +2 -2
  20. data/lib/poolparty/pool.rb +9 -2
  21. data/lib/poolparty/resource.rb +20 -7
  22. data/lib/poolparty/resources/directory.rb +5 -1
  23. data/lib/poolparty/resources/exec.rb +2 -2
  24. data/lib/poolparty/resources/file.rb +8 -2
  25. data/lib/poolparty/resources/gem_package.rb +2 -2
  26. data/lib/poolparty/resources/line.rb +23 -6
  27. data/lib/poolparty/resources/mount.rb +2 -2
  28. data/lib/poolparty/resources/package.rb +2 -2
  29. data/lib/poolparty/resources/service.rb +2 -2
  30. data/lib/poolparty/resources/user.rb +2 -2
  31. data/lib/poolparty.rb +2 -2
  32. data/test/lib/poolparty/base_test.rb +13 -0
  33. data/test/lib/poolparty/resources/line_test.rb +3 -3
  34. data/test/lib/poolparty/resources/service_test.rb +1 -1
  35. data/vendor/gems/net-ssh/CHANGELOG.rdoc +127 -0
  36. data/vendor/gems/net-ssh/Manifest +104 -0
  37. data/vendor/gems/net-ssh/README.rdoc +110 -0
  38. data/vendor/gems/net-ssh/Rakefile +26 -0
  39. data/vendor/gems/net-ssh/THANKS.rdoc +16 -0
  40. data/vendor/gems/net-ssh/lib/net/ssh/authentication/agent.rb +176 -0
  41. data/vendor/gems/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  42. data/vendor/gems/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  43. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  44. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  45. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  46. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  47. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  48. data/vendor/gems/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  49. data/vendor/gems/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  50. data/vendor/gems/net-ssh/lib/net/ssh/buffer.rb +340 -0
  51. data/vendor/gems/net-ssh/lib/net/ssh/buffered_io.rb +149 -0
  52. data/vendor/gems/net-ssh/lib/net/ssh/config.rb +181 -0
  53. data/vendor/gems/net-ssh/lib/net/ssh/connection/channel.rb +625 -0
  54. data/vendor/gems/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  55. data/vendor/gems/net-ssh/lib/net/ssh/connection/session.rb +596 -0
  56. data/vendor/gems/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  57. data/vendor/gems/net-ssh/lib/net/ssh/errors.rb +85 -0
  58. data/vendor/gems/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  59. data/vendor/gems/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  60. data/vendor/gems/net-ssh/lib/net/ssh/loggable.rb +61 -0
  61. data/vendor/gems/net-ssh/lib/net/ssh/packet.rb +102 -0
  62. data/vendor/gems/net-ssh/lib/net/ssh/prompt.rb +93 -0
  63. data/vendor/gems/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  64. data/vendor/gems/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  65. data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  66. data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks5.rb +129 -0
  67. data/vendor/gems/net-ssh/lib/net/ssh/ruby_compat.rb +7 -0
  68. data/vendor/gems/net-ssh/lib/net/ssh/service/forward.rb +267 -0
  69. data/vendor/gems/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  70. data/vendor/gems/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  71. data/vendor/gems/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  72. data/vendor/gems/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  73. data/vendor/gems/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  74. data/vendor/gems/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  75. data/vendor/gems/net-ssh/lib/net/ssh/test/script.rb +157 -0
  76. data/vendor/gems/net-ssh/lib/net/ssh/test/socket.rb +59 -0
  77. data/vendor/gems/net-ssh/lib/net/ssh/test.rb +89 -0
  78. data/vendor/gems/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  79. data/vendor/gems/net-ssh/lib/net/ssh/transport/cipher_factory.rb +80 -0
  80. data/vendor/gems/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  81. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +78 -0
  82. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  83. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  84. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  85. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  86. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  87. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  88. data/vendor/gems/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  89. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  90. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  91. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  92. data/vendor/gems/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  93. data/vendor/gems/net-ssh/lib/net/ssh/transport/packet_stream.rb +230 -0
  94. data/vendor/gems/net-ssh/lib/net/ssh/transport/server_version.rb +60 -0
  95. data/vendor/gems/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  96. data/vendor/gems/net-ssh/lib/net/ssh/transport/state.rb +201 -0
  97. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  98. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  99. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  100. data/vendor/gems/net-ssh/lib/net/ssh/version.rb +62 -0
  101. data/vendor/gems/net-ssh/lib/net/ssh.rb +215 -0
  102. data/vendor/gems/net-ssh/net-ssh.gemspec +33 -0
  103. data/vendor/gems/net-ssh/setup.rb +1585 -0
  104. data/vendor/gems/net-ssh/test/authentication/methods/common.rb +28 -0
  105. data/vendor/gems/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  106. data/vendor/gems/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  107. data/vendor/gems/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  108. data/vendor/gems/net-ssh/test/authentication/methods/test_password.rb +50 -0
  109. data/vendor/gems/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  110. data/vendor/gems/net-ssh/test/authentication/test_agent.rb +205 -0
  111. data/vendor/gems/net-ssh/test/authentication/test_key_manager.rb +105 -0
  112. data/vendor/gems/net-ssh/test/authentication/test_session.rb +93 -0
  113. data/vendor/gems/net-ssh/test/common.rb +106 -0
  114. data/vendor/gems/net-ssh/test/configs/eqsign +3 -0
  115. data/vendor/gems/net-ssh/test/configs/exact_match +8 -0
  116. data/vendor/gems/net-ssh/test/configs/wild_cards +14 -0
  117. data/vendor/gems/net-ssh/test/connection/test_channel.rb +452 -0
  118. data/vendor/gems/net-ssh/test/connection/test_session.rb +488 -0
  119. data/vendor/gems/net-ssh/test/test_all.rb +6 -0
  120. data/vendor/gems/net-ssh/test/test_buffer.rb +336 -0
  121. data/vendor/gems/net-ssh/test/test_buffered_io.rb +63 -0
  122. data/vendor/gems/net-ssh/test/test_config.rb +84 -0
  123. data/vendor/gems/net-ssh/test/test_key_factory.rb +67 -0
  124. data/vendor/gems/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  125. data/vendor/gems/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  126. data/vendor/gems/net-ssh/test/transport/hmac/test_none.rb +34 -0
  127. data/vendor/gems/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  128. data/vendor/gems/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  129. data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  130. data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  131. data/vendor/gems/net-ssh/test/transport/test_algorithms.rb +302 -0
  132. data/vendor/gems/net-ssh/test/transport/test_cipher_factory.rb +171 -0
  133. data/vendor/gems/net-ssh/test/transport/test_hmac.rb +34 -0
  134. data/vendor/gems/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  135. data/vendor/gems/net-ssh/test/transport/test_packet_stream.rb +435 -0
  136. data/vendor/gems/net-ssh/test/transport/test_server_version.rb +57 -0
  137. data/vendor/gems/net-ssh/test/transport/test_session.rb +315 -0
  138. data/vendor/gems/net-ssh/test/transport/test_state.rb +173 -0
  139. metadata +109 -4
  140. data/bin/install-poolparty +0 -20
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 3
3
- :patch: 4
3
+ :patch: 5
4
4
  :major: 1
data/bin/cloud-bootstrap CHANGED
@@ -21,6 +21,7 @@ EOS
21
21
  @loaded_clouds.each do |cld|
22
22
 
23
23
  cld.nodes.each do |node|
24
+ node.cloud = cld # needed for bootstrap
24
25
  node.bootstrap!(:force=>command[:force])
25
26
  end
26
27
 
data/bin/cloud-configure CHANGED
@@ -26,6 +26,7 @@ EOS
26
26
  end
27
27
 
28
28
  cld.nodes.each do |node|
29
+ node.cloud = cld # ?
29
30
  node.configure!(:cloud => cld)
30
31
  end
31
32
 
data/bin/cloud-contract CHANGED
@@ -17,6 +17,7 @@ EOS
17
17
  @loaded_clouds.each do |cld|
18
18
 
19
19
  node_to_terminate = cld.nodes.last
20
+ node_to_terminate.cloud = cld
20
21
 
21
22
  msg = [
22
23
  "Contracting cloud #{cld.name} (#{cld.keypair}) by 1",
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolparty/installer"
5
+
6
+ require 'git-style-binary/command'
7
+
8
+ GitStyleBinary.command do
9
+ banner <<-EOS
10
+ Usage: #{$0} #{all_options_string}
11
+
12
+ Sets up a basic clouds.rb file and carries through the steps to bootstrap a new cloud
13
+ EOS
14
+
15
+ short_desc "Setup a new clouds.rb file"
16
+
17
+ providers = {}
18
+ PoolParty::Installer.all.each_with_index do |installer,idx|
19
+ providers.merge!(idx+1 => installer)
20
+ end
21
+
22
+ str = ["The cloud_provider you'd like to set your clouds.rb for. The available clouds include:"]
23
+ PoolParty::Installer.all.each do |provider|
24
+ str << "\t\t\t\t\t\t\t\t#{provider.name} - #{provider.description}"
25
+ end
26
+ opt :type, str.join("\n"), :type => :string, :default => "ec2"
27
+
28
+ run do |command|
29
+
30
+ klass = PoolParty::Installer.find_by_name(command[:type])
31
+ puts "Great, we'll be using #{klass}"
32
+ inst = klass.send :new
33
+ inst.run
34
+
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ require "poolparty"
2
+ require 'poolparty-extensions'
3
+
4
+ pool "poolparty" do
5
+ instances 1
6
+
7
+ cloud "vmware" do
8
+ keypair "id_rsa"
9
+ using :vmware do
10
+ image_id "/Users/nmurray/Documents/VMware/Ubuntu-jaunty.vmwarevm/Ubuntu-jaunty.vmx"
11
+ public_ip "192.168.133.128"
12
+ end
13
+ has_file "/etc/motd", :content => "welcome to your instance"
14
+
15
+ has_convenience_helpers
16
+ end
17
+
18
+ end
@@ -222,7 +222,7 @@ module CloudProviders
222
222
  end
223
223
 
224
224
  def on_all_callbacks(call_time, *args, &block)
225
- cloud.callback call_time
225
+ cloud.callback call_time if cloud
226
226
  super
227
227
  end
228
228
 
data/lib/core/object.rb CHANGED
@@ -71,10 +71,10 @@ class Object
71
71
  puts "[INFO] -- #{m}" if verbose?
72
72
  end
73
73
  def dputs(m="")
74
- puts "[DEBUG] -- #{m.inspect}" if debugging?
74
+ puts "[DEBUG] -- #{m.is_a?(String) ? m : m.inspect}" if debugging?
75
75
  end
76
76
  def ddputs(m="")
77
- puts "[VERY DEBUG] -- #{m.inspect}" if very_debugging?
77
+ puts "[VERY DEBUG] -- #{m.is_a?(String) ? m : m.inspect}" if very_debugging?
78
78
  end
79
79
  def verbose?
80
80
  $TESTING ||= false
@@ -26,7 +26,7 @@ module DependencyResolvers
26
26
  end
27
27
 
28
28
  def compile_command
29
- "/usr/bin/chef-solo -c /etc/chef/solo.rb -j /etc/chef/dna.json"
29
+ "/usr/bin/chef-solo -c /etc/chef/solo.rb -j /etc/chef/dna.json#{ " -l debug" if very_debugging?}"
30
30
  end
31
31
 
32
32
  # compile the resources
@@ -57,7 +57,7 @@ module DependencyResolvers
57
57
  super
58
58
  end
59
59
 
60
- apply_meta_functions(res, o) if res.is_a?(PoolParty::Resource)
60
+ apply_meta_functions(res, o) if res.is_a?(PoolParty::Resource) && res.print_to_chef != :no_print
61
61
  end
62
62
 
63
63
  default_attr_reader :variables, []
@@ -15,6 +15,7 @@ module Askable
15
15
  colored_say e.inspect
16
16
  exit 0
17
17
  end
18
+ answer
18
19
  end
19
20
 
20
21
  def ask_with_help(opts={}, &block)
@@ -56,13 +57,9 @@ module Askable
56
57
 
57
58
  def choose(str, choices={}, opts={}, &block)
58
59
  colored_say(str)
59
- choices.each do |k,v|
60
- colored_say("#{k}) #{v}")
61
- end
62
- colored_print((opts[:prompt] || "> "))
63
- pick = gets.chomp.to_i
64
- yield choices[pick] if block
65
- choices[pick]
60
+ answer = ask(choices)
61
+ yield answer if block
62
+ answer
66
63
  end
67
64
 
68
65
  def wait
@@ -130,6 +127,8 @@ module Askable
130
127
  case @question
131
128
  when String
132
129
  ask_string
130
+ when Hash
131
+ ask_hash
133
132
  when Array
134
133
  ask_array
135
134
  end
@@ -150,5 +149,15 @@ module Askable
150
149
  num = (@input.gets).to_i rescue colored_say("<red>Invalid input, must be a number between 1 and #{@question.size + 1}")
151
150
  @answer = @question[num-1]
152
151
  end
152
+
153
+ def ask_hash
154
+ @question.sort.each do |k,v|
155
+ colored_say("#{k}) #{v}")
156
+ end
157
+ colored_print((@opts[:prompt] || "> "))
158
+ pick = @input.gets.to_i
159
+ @answer = @question[pick]
160
+ end
161
+
153
162
  end
154
163
  end
@@ -37,6 +37,8 @@ module PoolParty
37
37
  # - stack
38
38
  def run_in_context(o={}, &block)
39
39
  proc = Proc.new do
40
+ # Name MUST be set first
41
+ set_vars_from_options(:name => o[:name]) if o.has_key?(:name)
40
42
  set_vars_from_options(o)
41
43
  instance_eval &block if block
42
44
  end
@@ -127,12 +129,12 @@ module PoolParty
127
129
  # to create edges on the graph
128
130
  def resources_graph(force=false)
129
131
  return @resources_graph if @resources_graph && !force
130
- result = Digraph.new
131
-
132
- add_ordered_resources_to_result(resources, result)
132
+ result = Digraph.new
133
133
 
134
134
  create_graph(resources, nil, result)
135
135
 
136
+ add_ordered_resources_to_result(resources, result)
137
+
136
138
  @resources_graph = result
137
139
  end
138
140
 
@@ -141,7 +143,7 @@ module PoolParty
141
143
  arr_of_resources = resources.zip_offset(1)
142
144
 
143
145
  arr_of_resources.each do |first, second|
144
- result.add_edge!(first, second)
146
+ result.add_edge!(first, second) unless result.edge?(first, second) or result.edge?(second, first)
145
147
  add_ordered_resources_to_result(first.resources, result)
146
148
  end
147
149
  end
@@ -200,9 +202,9 @@ module PoolParty
200
202
 
201
203
  # The clouds.rb file
202
204
  def clouds_dot_rb_file(n=nil); self.class.clouds_dot_rb_file(n); end
203
- def self.clouds_dot_rb_file(n=nil)
204
- Pool.clouds_dot_rb_file(n)
205
- end
205
+ def self.clouds_dot_rb_file(n=nil);Pool.clouds_dot_rb_file(n);end
206
+ def clouds_dot_rb_dir(n=nil); self.class.clouds_dot_rb_dir(n);end
207
+ def self.clouds_dot_rb_dir(n=nil); Pool.clouds_dot_rb_dir(n);end
206
208
 
207
209
  # If the method is missing from ourself, check the Default
208
210
  # class for the corresponding method.
@@ -26,6 +26,10 @@ module PoolParty
26
26
  callback_block do |cld, callback|
27
27
  end
28
28
 
29
+ def before_compile
30
+ validate_all_resources
31
+ end
32
+
29
33
  # Freeze the cloud_name so we can't modify it at all, set the plugin_directory
30
34
  # call and run instance_eval on the block and then call the after_create callback
31
35
  def initialize(n, o={}, &block)
@@ -176,9 +180,15 @@ module PoolParty
176
180
  # Take the cloud's resources and compile them down using
177
181
  # the defined (or the default dependency_resolver, chef)
178
182
  def compile(caller=nil)
183
+ callback :before_compile
179
184
  FileUtils.mkdir_p tmp_path unless File.directory?(tmp_path)
180
- ddputs("Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}")
181
- dependency_resolver.compile_to(ordered_resources, tmp_path/"etc"/"#{dependency_resolver_name}", caller)
185
+ ddputs <<-EOE
186
+ Compiling cloud #{self.name} to #{tmp_path/"etc"/"#{dependency_resolver_name}"}
187
+ number of resources: #{ordered_resources.size}
188
+ EOE
189
+ out = dependency_resolver.compile_to(ordered_resources, tmp_path/"etc"/"#{dependency_resolver_name}", caller)
190
+ callback :after_compile
191
+ out
182
192
  end
183
193
 
184
194
  # Get the os of the first node if it was not explicity defined, we'll assume they are
@@ -242,5 +252,50 @@ module PoolParty
242
252
  end
243
253
  end
244
254
 
255
+ def validate_all_resources
256
+ ddputs("Validating all the resources")
257
+ [:ensure_not_cyclic, :ensure_meta_fun_are_resources].each do |meth|
258
+ self.send meth
259
+ end
260
+ end
261
+
262
+ def ensure_not_cyclic
263
+ if resources_graph.cyclic?
264
+ cycles = []
265
+
266
+ resources_graph.edges.each do |edge|
267
+ if resources_graph.adjacent?(edge.source, edge.target) && resources_graph.adjacent?(edge.target, edge.source) && !cycles.include?(edge.source)
268
+ cycles << "#{edge.source.class}(#{edge.source.name}) depends on #{edge.target.class}(#{edge.target.name})"
269
+ end
270
+ end
271
+ msg =<<-EOE
272
+
273
+ Your resource graph is cyclic. Two resources depend on each other, Cannot decide which resource
274
+ to go first. Dying instead. Correct this and then try again.
275
+
276
+ #{cycles.join("\n ")}
277
+
278
+ Hint: You can see the resource graph by generating it with:
279
+ cloud compile -g name
280
+
281
+ EOE
282
+ raise PoolPartyError.create("CyclicResourceGraphError", msg)
283
+ end
284
+ end
285
+
286
+ def ensure_meta_fun_are_resources
287
+ resources.each do |res|
288
+
289
+ if res.meta_notifies
290
+ res.meta_notifies.each do |ty, arr|
291
+ arr.each do |nm, action|
292
+ raise PoolPartyError.create("ResourceNotFound", "A resource required for #{ty}(#{nm}) was not found: #{ty}(#{nm}). Please make sure you've specified this in your configuration.") unless get_resource(ty, nm)
293
+ end
294
+ end
295
+ end
296
+
297
+ end
298
+ end
299
+
245
300
  end
246
301
  end
@@ -15,7 +15,7 @@ module PoolParty
15
15
  steps.each {|c| self.__send__ c.to_sym }
16
16
  self.__send__ :closing_message
17
17
  rescue Exception => e
18
- # colored_say e.inspect
18
+ colored_say e.inspect
19
19
  colored_say exit_msg
20
20
  ensure
21
21
  Colors.reset!
@@ -35,7 +35,7 @@ First, we'll setup your environment so using PoolParty will be a <blue>breeze</b
35
35
  <yellow>Cancelled PoolParty installation</yellow>
36
36
 
37
37
  You can always restart this by typing:
38
- <blue>install-poolparty</blue>
38
+ <blue>cloud setup</blue>
39
39
 
40
40
  <line>
41
41
  EOE
@@ -97,8 +97,12 @@ irc.freenode.net / #poolpartyrb
97
97
  def self.all
98
98
  @all ||= []
99
99
  end
100
-
101
-
100
+
101
+ def self.find_by_name(nm)
102
+ all.detect do |i|
103
+ i.name =~ /#{nm}/i
104
+ end
105
+ end
102
106
  end
103
107
  end
104
108
 
@@ -4,7 +4,8 @@ module PoolParty
4
4
 
5
5
  def steps
6
6
  [
7
- :todo
7
+ :find_ec2_directory, :ask_for_access_key, :ask_for_private_access_key,
8
+ :show_env_setup
8
9
  ]
9
10
  end
10
11
 
@@ -16,15 +17,84 @@ module PoolParty
16
17
  "Ec2 installer"
17
18
  end
18
19
 
19
- def todo
20
+ def find_ec2_directory
21
+ msg = "We found the following vmware files in the default vmware directory.\nChoose one of these to use as your vmrun file or select other\n<line>"
22
+
23
+ directories = {}
24
+ default_ec2_directories.each_with_index do |file,idx|
25
+ directories.merge!(idx+1 => file)
26
+ end
27
+
28
+ base = choose(msg, directories)
29
+ @ec2_directory = base == :other ? ask_for_ec2_directory : base
30
+ end
31
+
32
+ def ask_for_access_key
33
+ access_key_help =<<-EOV
34
+ EC2 uses an access key to identify you and allows you to start and stop instances.
35
+ EOV
36
+
37
+ access_key = <<-EOE
38
+ What is your access key?
39
+ EOE
40
+ ask_with_help :message => access_key, :help => access_key_help do |k|
41
+ @access_key = k
42
+ end
43
+ end
44
+
45
+ def ask_for_private_access_key
46
+ private_access_key_help =<<-EOV
47
+ EC2 uses a private access key to identify you and allows you to start and stop instances.
48
+ EOV
49
+
50
+ private_access_key = <<-EOE
51
+ What is your private access key?
52
+ EOE
53
+ ask_with_help :message => private_access_key, :help => private_access_key_help do |k|
54
+ @secret_access_key = k
55
+ end
56
+ end
57
+
58
+
59
+ def ask_for_ec2_directory
60
+ ec2_directory_help =<<-EOV
61
+ Ec2 needs to know where you store your certificates and private keys. Amazon expects these to be in the ~/.ec2 directory. We suggest a subdirectory of the ~/.ec2 directory so you can separate ec2 accounts.
62
+ EOV
63
+
64
+ ec2_directory_msg = <<-EOE
65
+ What's path to your ec2 directory with your cert and pk files?
66
+ EOE
67
+ ask_with_help :message => ec2_directory_msg, :help => ec2_directory_help
68
+ end
69
+
70
+
71
+ def show_env_setup
20
72
  colored_say <<-EOE
21
- <line>
22
- <red>Not implemented yet</red>
23
- <line>
73
+ <line>
74
+
75
+ Setup your environment:
76
+
77
+ export EC2_ACCESS_KEY=#{@access_key}
78
+ export EC2_SECRET_KEY=#{@secret_access_key}
79
+
80
+ export EC2_PRIVATE_KEY=$(ls #{@ec2_directory}/pk-*.pem)
81
+ export EC2_CERT=$(ls #{@ec2_directory}/cert-*.pem)
82
+
83
+ <line>
24
84
  EOE
25
85
  exit 0
26
86
  end
27
87
 
88
+ private
89
+
90
+ def default_ec2_directories
91
+ @default_ec2_directories ||= find_default_ec2_directories rescue nil
92
+ end
93
+
94
+ def find_default_ec2_directories
95
+ Dir["#{::File.expand_path("~")}/.ec2/*"].reject {|f| File.file?(f) }
96
+ end
97
+
28
98
  end
29
99
  end
30
100
  end
@@ -59,9 +59,14 @@ Awesome. What's the path to your vmwarevm file?
59
59
  ip_help =<<-EOV
60
60
  Right now, vmrun, the remoter base needs an explicitly set ip. Log into your vm and type ifconfig. Copy and paste that here.
61
61
  EOV
62
- @ip = ask_with_help :message => "Now, what's the ip of your vm?", :help => ip_help
62
+ @ip = ask_with_help :message => "what's the ip of your vm?", :help => ip_help
63
63
 
64
- puts @ip
64
+ if @ip =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
65
+ @ip
66
+ else
67
+ colored_say "<red>You must enter a valid ip</red>"
68
+ get_vm_ip
69
+ end
65
70
  end
66
71
 
67
72
  def get_key
@@ -70,9 +75,16 @@ Finally, we'll set somethings up here shortly, but first we'll need to know wher
70
75
  at ~/.ssh/id_rsa.pub. If this is true, then just press enter. Otherwise, enter the path of your public key.
71
76
  EOV
72
77
 
73
- ask_with_help :message => "What keypair would you like to use? (default: ~/.ssh/id_rsa.pub)",
74
- :help => key_help do |k|
75
- @key = k.empty? ? ::File.expand_path("~/.ssh/id_rsa.pub") : k
78
+ ask_with_help :message => "What keypair would you like to use? (default: ~/.ssh/id_rsa.pub)", :help => key_help do |responded_key|
79
+ responded_key = "~/.ssh/id_rsa.pub" if responded_key.empty?
80
+
81
+ @key = File.expand_path(responded_key)
82
+ if File.file?(@key)
83
+ @key
84
+ else
85
+ colored_say "<red>You must enter a valid path to a keyfile</red>"
86
+ get_key
87
+ end
76
88
  end
77
89
  end
78
90
 
@@ -1,4 +1,5 @@
1
1
  module PoolParty
2
+
2
3
  module Resources
3
4
 
4
5
  class Apache < Resource
@@ -49,12 +50,12 @@ module PoolParty
49
50
  passenger_configs
50
51
 
51
52
  has_exec "install_passenger_script" do
52
- command 'echo -en \"\\\\n\\\\n\\\\n\\\\n\" | passenger-install-apache2-module'
53
+ command "passenger-install-apache2-module -auto"
53
54
  notifies get_exec("restart-apache2"), :run
54
55
  requires get_exec("restart-apache2")
55
56
  requires get_package("apache2")
56
57
  requires get_gem_package("passenger")
57
- not_if "test -f /etc/apache2/mods-available/passenger.conf && test -s /etc/apache2/mods-available/passenger.conf"
58
+ not_if "test -f /etc/apache2/mods-available/passenger.conf && test -s /etc/apache2/mods-available/passenger.conf "
58
59
  creates lambda { "@node[:apache][:passenger_module_path]" }
59
60
  end
60
61
 
@@ -162,10 +162,10 @@ LogFormat "%h %l %u %t \"%r\" %>s %b" common
162
162
  LogFormat "%{Referer}i -> %U" referer
163
163
  LogFormat "%{User-agent}i" agent
164
164
 
165
- DocumentRoot /var/www
165
+ #DocumentRoot /var/www
166
166
 
167
167
  # Listen <%= @node[:apache][:port] %>
168
- NameVirtualHost *:<%= @node[:apache][:port] %>
168
+ #NameVirtualHost *:<%= @node[:apache][:port] %>
169
169
 
170
170
 
171
171
  # NEW CONFIG FILE
@@ -23,4 +23,4 @@
23
23
  BrowserMatch "^gnome-vfs/1.0" redirect-carefully
24
24
  BrowserMatch "^XML Spy" redirect-carefully
25
25
  BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
26
- </IfModule>
26
+ </IfModule>
@@ -32,9 +32,9 @@ module PoolParty
32
32
  if !File.exists?("#{dir}/#{name}/current")
33
33
 
34
34
  # setup an initial symlink so apache will start even if there have not been any deploys yet
35
- has_site_directory "releases/initial/public"
35
+ #has_site_directory "releases/initial/public"
36
36
  #FIXME the following line is chef specific. It will fail with puppet
37
- # has_symlink(:target_file => "#{dir}/#{name}/current", :to => "#{dir}/#{name}/releases/initial")
37
+ has_link(:target_file => "#{dir}/#{name}/current", :to => "#{dir}/#{name}/releases/initial")
38
38
  end
39
39
  log_dir = "#{site_directory}/shared/log"
40
40
  appended_path "current"
@@ -78,7 +78,7 @@ module PoolParty
78
78
  end
79
79
  end
80
80
 
81
- def self.clouds_dot_rb_dir
81
+ def self.clouds_dot_rb_dir(n=nil)
82
82
  File.dirname(self.clouds_dot_rb_file) if self.clouds_dot_rb_file
83
83
  end
84
84
 
@@ -133,7 +133,14 @@ module PoolParty
133
133
  # + sets up the log
134
134
  def self.before_file_load(filepath)
135
135
  $:.unshift(::File.dirname(filepath))
136
- Dir["#{::File.dirname(filepath)}/plugins/*"].each { |plugin_path| $:.unshift(plugin_path) }
136
+ Dir["#{ ::File.dirname(filepath)}/plugins/*"].each do |plugin_path|
137
+ if File.directory?(plugin_path)
138
+ $:.unshift(plugin_path)
139
+ require "#{plugin_path}/#{File.basename(plugin_path)}"
140
+ elsif File.file?(plugin_path) && plugin_path.match(/.rb$/)
141
+ require plugin_path
142
+ end
143
+ end
137
144
  end
138
145
 
139
146
  # Call init to the resource methods and init the log
@@ -2,7 +2,7 @@ module PoolParty
2
2
  class Resource < Base
3
3
 
4
4
  attr_reader :exists
5
- attr_reader :meta_notifies, :meta_not_if, :meta_only_if, :meta_subscribes
5
+ attr_accessor :meta_notifies, :meta_not_if, :meta_only_if, :meta_subscribes
6
6
  attr_accessor :graph_index
7
7
 
8
8
  default_options(
@@ -44,7 +44,9 @@ module PoolParty
44
44
  other_resources_hash.each do |k,v|
45
45
  notifies_array = (@meta_notifies[k] ||= [])
46
46
  notifies_array << [v, action_to_take] unless notifies_array.include?([v, action_to_take])
47
- end
47
+ # Implicitly add a require
48
+ # requires(k => v)
49
+ end
48
50
  end
49
51
 
50
52
  def subscribes(other_resources_hash, action_to_take=:reload, at_time=:delayed)
@@ -56,12 +58,19 @@ module PoolParty
56
58
  end
57
59
 
58
60
  # Requires
59
- def requires(other_resources_hsh)
60
- other_resources_hsh.each do |k,v|
61
- current_deps = (dependencies[k] ||= [])
62
- current_deps << v unless current_deps.include?(v)
61
+ def requires(other_resources_obj)
62
+ case other_resources_obj
63
+ when Hash
64
+ other_resources_obj.each do |k,v|
65
+ dependencies[k] ||= []
66
+ dependencies[k] << v unless dependencies[k].include?(v)
67
+ end
68
+ when Array
69
+ other_resources_obj.each do |obj|
70
+ requires(obj)
71
+ end
63
72
  end
64
- end
73
+ end
65
74
 
66
75
  # Not if
67
76
  # If a block is given with the not_if, we assume it is
@@ -102,6 +111,10 @@ module PoolParty
102
111
  def after_compile
103
112
  end
104
113
 
114
+ def after_loaded
115
+ requires parent if parent && !parent.is_a?(PoolParty::Cloud) && !parent.is_a?(PoolParty::Pool)
116
+ end
117
+
105
118
  # Singleton methods
106
119
  # has_name
107
120
  # The has_ and does_not_have methods names
@@ -31,6 +31,10 @@ module PoolParty
31
31
  :group => "root",
32
32
  :recursive => true
33
33
  )
34
+
35
+ def after_loaded
36
+ requires get_user(owner) if owner && owner != "root"
37
+ end
34
38
 
35
39
  def print_to_chef
36
40
  <<-EOE
@@ -47,4 +51,4 @@ end
47
51
  end
48
52
 
49
53
  end
50
- end
54
+ end
@@ -43,7 +43,7 @@ module PoolParty
43
43
  str = 'execute "<%= name %>" do
44
44
  command <%= print_variable(command || name) %>
45
45
  path <%= print_variable(path) %>
46
- action :<%= action ? action : (exists ? :run : :nothing) %>
46
+ action <%= print_variable(action ? action : (exists ? :run : :nothing)) %>
47
47
  '
48
48
  str << " creates <%= print_variable(creates) %>\n" if creates
49
49
  str << " cwd <%= print_variable(cwd) %>\n" if cwd
@@ -58,4 +58,4 @@ str = 'execute "<%= name %>" do
58
58
  end
59
59
 
60
60
  end
61
- end
61
+ end
@@ -38,7 +38,11 @@ module PoolParty
38
38
  :backup => 5,
39
39
  :owner => "root"
40
40
  )
41
-
41
+
42
+ def after_loaded
43
+ requires get_user(owner) if owner && owner != "root"
44
+ end
45
+
42
46
  def self.has_method_name
43
47
  "file"
44
48
  end
@@ -62,6 +66,8 @@ end
62
66
  file = arg.first
63
67
  @template = if File.file?(b = File.expand_path(file))
64
68
  b
69
+ elsif File.file?(c = File.expand_path(File.join(clouds_dot_rb_dir, file)))
70
+ c
65
71
  elsif f = search_in_known_locations(file)
66
72
  f
67
73
  else
@@ -78,4 +84,4 @@ end
78
84
  end
79
85
 
80
86
  end
81
- end
87
+ end