auser-poolparty 0.2.81 → 0.2.84
Sign up to get free protection for your applications and to get access to all the features.
- data/Capfile +1 -0
- data/Manifest.txt +13 -6
- data/PostInstall.txt +1 -1
- data/bin/cloud-configure +2 -1
- data/bin/cloud-handle-load +3 -3
- data/bin/cloud-maintain +2 -2
- data/bin/cloud-provision +4 -4
- data/bin/cloud-setup-dev +25 -0
- data/bin/cloud-start +1 -0
- data/bin/server-start-client +1 -1
- data/bin/server-start-master +1 -1
- data/bin/server-start-node +1 -1
- data/bin/server-write-new-nodes +26 -0
- data/lib/poolparty/capistrano.rb +18 -0
- data/lib/poolparty/exceptions/ProvisionerException.rb +5 -0
- data/lib/poolparty/helpers/optioner.rb +2 -1
- data/lib/poolparty/modules/cloud_resourcer.rb +17 -0
- data/lib/poolparty/modules/file_writer.rb +2 -2
- data/lib/poolparty/net/messenger.rb +1 -1
- data/lib/poolparty/net/remote_bases/ec2.rb +3 -2
- data/lib/poolparty/net/remoter.rb +12 -8
- data/lib/poolparty/plugins/git.rb +5 -1
- data/lib/poolparty/poolparty/cloud.rb +3 -1
- data/lib/poolparty/provisioners/capistrano/capistrano.rb +129 -0
- data/lib/poolparty/provisioners/capistrano/capistrano_configurer.rb +58 -0
- data/lib/poolparty/provisioners/capistrano/recipies/base.rb +100 -0
- data/lib/poolparty/provisioners/capistrano/recipies/master.rb +120 -0
- data/lib/poolparty/provisioners/capistrano/recipies/slave.rb +12 -0
- data/lib/poolparty/provisioners/provisioner_base.rb +98 -274
- data/lib/poolparty/templates/gem +12 -10
- data/lib/poolparty/version.rb +1 -1
- data/lib/poolparty.rb +5 -3
- data/poolparty.gemspec +18 -9
- data/spec/poolparty/helpers/optioner_spec.rb +1 -1
- data/spec/poolparty/net/remote_spec.rb +13 -14
- data/spec/poolparty/net/remoter_spec.rb +11 -11
- data/spec/poolparty/plugins/git_spec.rb +1 -1
- data/spec/poolparty/poolparty_spec.rb +1 -1
- data/spec/poolparty/provisioners/capistrano/capistrano_spec.rb +27 -0
- data/spec/poolparty/provisioners/provisioner_base_spec.rb +120 -0
- data/spec/poolparty/spec_helper.rb +15 -1
- data/website/index.html +1 -1
- metadata +18 -9
- data/lib/poolparty/provisioners/provisioners/become_master.rb +0 -166
- data/lib/poolparty/provisioners/provisioners/master.rb +0 -196
- data/lib/poolparty/provisioners/provisioners/slave.rb +0 -65
- data/spec/poolparty/helpers/provisioner_base_spec.rb +0 -137
- data/spec/poolparty/helpers/provisioners/master_spec.rb +0 -53
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +0 -27
data/Capfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir["#{::File.dirname(__FILE__)}/lib/poolparty/provisioners/capistrano/tasks/*.rb"].each { |plugin| load(plugin) }
|
data/Manifest.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
Capfile
|
1
2
|
History.txt
|
2
3
|
License.txt
|
3
4
|
Manifest.txt
|
@@ -18,6 +19,7 @@ bin/cloud-provision
|
|
18
19
|
bin/cloud-refresh
|
19
20
|
bin/cloud-rsync
|
20
21
|
bin/cloud-run
|
22
|
+
bin/cloud-setup-dev
|
21
23
|
bin/cloud-spec
|
22
24
|
bin/cloud-ssh
|
23
25
|
bin/cloud-start
|
@@ -47,6 +49,7 @@ bin/server-stop-client
|
|
47
49
|
bin/server-stop-master
|
48
50
|
bin/server-stop-node
|
49
51
|
bin/server-update-hosts
|
52
|
+
bin/server-write-new-nodes
|
50
53
|
config/hoe.rb
|
51
54
|
config/requirements.rb
|
52
55
|
examples/basic.rb
|
@@ -173,6 +176,7 @@ lib/poolparty/base_packages/heartbeat.rb
|
|
173
176
|
lib/poolparty/base_packages/poolparty.rb
|
174
177
|
lib/poolparty/base_packages/ruby.rb
|
175
178
|
lib/poolparty/base_packages/runit.rb
|
179
|
+
lib/poolparty/capistrano.rb
|
176
180
|
lib/poolparty/config/postlaunchmessage.txt
|
177
181
|
lib/poolparty/core/array.rb
|
178
182
|
lib/poolparty/core/class.rb
|
@@ -193,6 +197,7 @@ lib/poolparty/dependency_resolutions/puppet.rb
|
|
193
197
|
lib/poolparty/exceptions/CloudNotFoundException.rb
|
194
198
|
lib/poolparty/exceptions/LoadRulesException.rb
|
195
199
|
lib/poolparty/exceptions/MasterException.rb
|
200
|
+
lib/poolparty/exceptions/ProvisionerException.rb
|
196
201
|
lib/poolparty/exceptions/RemoteException.rb
|
197
202
|
lib/poolparty/exceptions/ResourceException.rb
|
198
203
|
lib/poolparty/exceptions/RuntimeException.rb
|
@@ -261,10 +266,12 @@ lib/poolparty/poolparty/resources/sshkey.rb
|
|
261
266
|
lib/poolparty/poolparty/resources/symlink.rb
|
262
267
|
lib/poolparty/poolparty/resources/variable.rb
|
263
268
|
lib/poolparty/poolparty/script.rb
|
269
|
+
lib/poolparty/provisioners/capistrano/capistrano.rb
|
270
|
+
lib/poolparty/provisioners/capistrano/capistrano_configurer.rb
|
271
|
+
lib/poolparty/provisioners/capistrano/recipies/base.rb
|
272
|
+
lib/poolparty/provisioners/capistrano/recipies/master.rb
|
273
|
+
lib/poolparty/provisioners/capistrano/recipies/slave.rb
|
264
274
|
lib/poolparty/provisioners/provisioner_base.rb
|
265
|
-
lib/poolparty/provisioners/provisioners/become_master.rb
|
266
|
-
lib/poolparty/provisioners/provisioners/master.rb
|
267
|
-
lib/poolparty/provisioners/provisioners/slave.rb
|
268
275
|
lib/poolparty/spec/core/string.rb
|
269
276
|
lib/poolparty/spec/matchers/a_spec_extensions_base.rb
|
270
277
|
lib/poolparty/spec/matchers/have_cron.rb
|
@@ -332,9 +339,6 @@ spec/poolparty/extra/deployments_spec.rb
|
|
332
339
|
spec/poolparty/helpers/binary_spec.rb
|
333
340
|
spec/poolparty/helpers/display_spec.rb
|
334
341
|
spec/poolparty/helpers/optioner_spec.rb
|
335
|
-
spec/poolparty/helpers/provisioner_base_spec.rb
|
336
|
-
spec/poolparty/helpers/provisioners/master_spec.rb
|
337
|
-
spec/poolparty/helpers/provisioners/slave_spec.rb
|
338
342
|
spec/poolparty/modules/cloud_resourcer_spec.rb
|
339
343
|
spec/poolparty/modules/configurable_spec.rb
|
340
344
|
spec/poolparty/modules/definable_resource.rb
|
@@ -343,6 +347,7 @@ spec/poolparty/modules/s3_string_spec.rb
|
|
343
347
|
spec/poolparty/monitors/base_monitor_spec.rb
|
344
348
|
spec/poolparty/monitors/monitors/cpu_monitor_spec.rb
|
345
349
|
spec/poolparty/monitors/monitors/memory_monitor_spec.rb
|
350
|
+
spec/poolparty/net/log/pool.log
|
346
351
|
spec/poolparty/net/messenger_spec.rb
|
347
352
|
spec/poolparty/net/remote_bases/ec2_spec.rb
|
348
353
|
spec/poolparty/net/remote_instance_spec.rb
|
@@ -384,6 +389,8 @@ spec/poolparty/poolparty/test_plugins/sshkey_test
|
|
384
389
|
spec/poolparty/poolparty/test_plugins/virtual_host_template.erb
|
385
390
|
spec/poolparty/poolparty/test_plugins/webserver.rb
|
386
391
|
spec/poolparty/poolparty_spec.rb
|
392
|
+
spec/poolparty/provisioners/capistrano/capistrano_spec.rb
|
393
|
+
spec/poolparty/provisioners/provisioner_base_spec.rb
|
387
394
|
spec/poolparty/spec/core/string_spec.rb
|
388
395
|
spec/poolparty/spec_helper.rb
|
389
396
|
tasks/cloud.rake
|
data/PostInstall.txt
CHANGED
data/bin/cloud-configure
CHANGED
@@ -15,7 +15,8 @@ o.loaded_clouds.each do |cloud|
|
|
15
15
|
# hide_output do
|
16
16
|
# if provision_class == "master" || provision_class == "all"
|
17
17
|
@cl = self
|
18
|
-
daemon ? daemonize {Provisioner.configure_master(@cl, testing)} : Provisioner.configure_master(self, testing)
|
18
|
+
# daemon ? daemonize {Provisioner.configure_master(@cl, testing)} : Provisioner.configure_master(self, testing)
|
19
|
+
verbose ? provisioner_for(master).configure(testing) : hide_output { provisioner_for(master).configure(testing) }
|
19
20
|
# end
|
20
21
|
# if provision_class == "slave" || provision_class == "all"
|
21
22
|
# Provisioner.configure_slaves(self, testing)
|
data/bin/cloud-handle-load
CHANGED
@@ -14,12 +14,12 @@ o.loaded_clouds.each do |cloud|
|
|
14
14
|
vputs "should_expand_cloud: #{should_contract_cloud?}"
|
15
15
|
if should_expand_cloud?
|
16
16
|
vputs "Expanding cloud based on load"
|
17
|
-
|
18
|
-
|
17
|
+
log.debug "Expanding cloud based on load"
|
18
|
+
log.debug rules_values
|
19
19
|
expand_cloud_if_necessary
|
20
20
|
elsif should_contract_cloud?
|
21
21
|
vputs "Contracting cloud based on load"
|
22
|
-
|
22
|
+
log.debug rules_values
|
23
23
|
contract_cloud_if_necessary
|
24
24
|
end
|
25
25
|
end
|
data/bin/cloud-maintain
CHANGED
@@ -13,8 +13,8 @@ o.loaded_clouds.each do |cloud|
|
|
13
13
|
|
14
14
|
with_cloud(cloud) do
|
15
15
|
vputs header("Maintaining cloud #{name}")
|
16
|
-
|
17
|
-
|
16
|
+
log.warn "Maintaining cloud"
|
17
|
+
log.warn rules_values
|
18
18
|
if !minimum_number_of_instances_are_running?
|
19
19
|
vputs "#{list_of_running_instances.size} running instances of between #{minimum_instances} and #{maximum_instances}"
|
20
20
|
vputs "Launching new instance"
|
data/bin/cloud-provision
CHANGED
@@ -12,20 +12,20 @@ end
|
|
12
12
|
o.loaded_clouds.each do |cloud|
|
13
13
|
|
14
14
|
with_cloud(cloud) do
|
15
|
-
|
15
|
+
setup_dev
|
16
16
|
instance_num = instance_number.to_i if instance_number
|
17
17
|
|
18
18
|
if instance_num
|
19
19
|
@instance = get_instance_by_number( instance_num )
|
20
|
-
instance_num == 0 ?
|
20
|
+
instance_num == 0 ? provisioner_for(master).install(testing) : provisioner_for(@instance).install(testing)
|
21
21
|
# Provisioner.process_clean_reconfigure_for!(@instance, self, testing)
|
22
22
|
else
|
23
23
|
if provision_slave
|
24
24
|
vputs "Provisioning slaves"
|
25
|
-
|
25
|
+
verbose ? provisioner_for(nil).install(testing) : hide_output { provisioner_for(nil).install(testing) }
|
26
26
|
else
|
27
27
|
vputs "Provisioning master"
|
28
|
-
|
28
|
+
verbose ? provisioner_for(master).install(testing) : hide_output { provisioner_for(master).install(testing) }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/bin/cloud-setup-dev
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
require "poolparty"
|
4
|
+
require "poolpartycl"
|
5
|
+
|
6
|
+
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
|
7
|
+
opts.on('-n name', '--name name', 'Setup development environment for cloud named') { |c| optioner.cloudname c }
|
8
|
+
end
|
9
|
+
|
10
|
+
o.loaded_clouds.each do |cloud|
|
11
|
+
with_cloud(cloud) do
|
12
|
+
|
13
|
+
setup_dev
|
14
|
+
|
15
|
+
str =<<-EOE
|
16
|
+
Host #{name}-master
|
17
|
+
User #{user}
|
18
|
+
Hostname #{master.ip}
|
19
|
+
IdentityFile #{full_keypair_path}
|
20
|
+
EOE
|
21
|
+
|
22
|
+
puts "Enter the following in your .ssh/config file"
|
23
|
+
puts str
|
24
|
+
end
|
25
|
+
end
|
data/bin/cloud-start
CHANGED
@@ -10,6 +10,7 @@ end
|
|
10
10
|
|
11
11
|
o.loaded_clouds.each do |cloud|
|
12
12
|
with_cloud(cloud) do
|
13
|
+
setup_dev
|
13
14
|
vputs header("Starting cloud #{name}")
|
14
15
|
vputs "#{list_of_running_instances.size} running instances (#{minimum_instances} - #{maximum_instances})"
|
15
16
|
# if list_of_running_instances.size <= 1
|
data/bin/server-start-client
CHANGED
@@ -18,7 +18,7 @@ o.loaded_clouds.each do |cloud|
|
|
18
18
|
boot_file = "#{Messenger.append_dir}/pm_client_rel-0.1"
|
19
19
|
|
20
20
|
Kernel.system "cd #{Messenger.append_dir} && rake build_boot_scripts" unless ::File.file?("#{boot_file}.boot") || testing
|
21
|
-
command = Messenger.erl_command("client", "-boot #{boot_file} #{noshell ? "" : "-detached -heart -noshell"}", 7049, 7050)
|
21
|
+
command = Messenger.erl_command("client", "-setcookie #{generate_unique_cookie_string} -boot #{boot_file} #{noshell ? "" : "-detached -heart -noshell"}", 7049, 7050)
|
22
22
|
vputs "Running #{command}"
|
23
23
|
|
24
24
|
Kernel.system "export HOME=/root && #{command}" unless testing
|
data/bin/server-start-master
CHANGED
@@ -16,7 +16,7 @@ o.loaded_clouds.each do |cloud|
|
|
16
16
|
|
17
17
|
boot_file = "#{Messenger.append_dir}/pm_master_rel-0.1"
|
18
18
|
Kernel.system ". /etc/profile && server-build-messenger" unless ::File.file?("#{boot_file}.boot") || testing
|
19
|
-
command = Messenger.erl_command("master", "-boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"}")
|
19
|
+
command = Messenger.erl_command("master", "-setcookie #{generate_unique_cookie_string} -boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"}")
|
20
20
|
vputs "Running #{command}"
|
21
21
|
|
22
22
|
Kernel.system "export HOME=/root && #{command}" unless testing
|
data/bin/server-start-node
CHANGED
@@ -22,7 +22,7 @@ o.loaded_clouds.each do |cloud|
|
|
22
22
|
boot_file = "#{Messenger.append_dir}/pm_node_rel-0.1"
|
23
23
|
|
24
24
|
Kernel.system ". /etc/profile && server-build-messenger" unless ::File.file?("#{boot_file}.boot") || testing
|
25
|
-
command = Messenger.erl_command(hostname, "-boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"} -- #{available_monitors.join(" ")}")
|
25
|
+
command = Messenger.erl_command(hostname, "-setcookie #{generate_unique_cookie_string} -boot #{boot_file} #{noshell ? "" : "-noshell -detached -heart"} -- #{available_monitors.join(" ")}")
|
26
26
|
vputs "Running #{command}"
|
27
27
|
|
28
28
|
Kernel.system "export HOME=/root && #{command}" unless testing
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
require "rubygems"
|
4
|
+
require "poolparty"
|
5
|
+
require "poolpartycl"
|
6
|
+
|
7
|
+
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
|
8
|
+
opts.on('-n name', '--name name', 'Update hosts for local pool named [name]') { |p| optioner.cloudname p }
|
9
|
+
end
|
10
|
+
|
11
|
+
o.loaded_clouds.each do |cloud|
|
12
|
+
with_cloud(cloud) do
|
13
|
+
|
14
|
+
new_nodes_file = "#{Base.manifest_path}/nodes/nodes.pp"
|
15
|
+
|
16
|
+
str = returning Array.new do |arr|
|
17
|
+
arr << "node default { include poolparty }"
|
18
|
+
list_of_running_instances.each do |ri|
|
19
|
+
arr << "node \"#{ri.name}\" inherits default {}"
|
20
|
+
end
|
21
|
+
end.join("\n")
|
22
|
+
|
23
|
+
testing ? puts(str) : ::File.open(new_nodes_file, "w+") {|f| f << str }
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PoolParty
|
2
|
+
module Capistrano
|
3
|
+
|
4
|
+
def set_cloud(cld=nil)
|
5
|
+
raise unless cld
|
6
|
+
@cloud = cld
|
7
|
+
end
|
8
|
+
|
9
|
+
def set_poolparty_roles
|
10
|
+
returning Array.new do |arr|
|
11
|
+
arr << "role 'master.#{@cloud.name}'.to_sym, '#{@cloud.master.ip}'"
|
12
|
+
arr << "role :master, '#{@cloud.master.ip}'"
|
13
|
+
arr << "role :slaves, '#{@cloud.nonmaster_nonterminated_instances.map{|a| a.ip}.join('", "')}'" if @cloud.nonmaster_nonterminated_instances.size > 0
|
14
|
+
end.join("\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -37,7 +37,7 @@ module PoolParty
|
|
37
37
|
@flagged_args ||= []
|
38
38
|
end
|
39
39
|
def boolean_args
|
40
|
-
@boolean_args ||= ['-V', '-h', '-t', '-v']
|
40
|
+
@boolean_args ||= ['-V', '-h', '-t', '-v', '--debug']
|
41
41
|
end
|
42
42
|
|
43
43
|
# Break ARGV into 2 arrays, one for flagged options one for unflagged
|
@@ -83,6 +83,7 @@ module PoolParty
|
|
83
83
|
@opts.separator "Options:"
|
84
84
|
|
85
85
|
@opts.on('-v', '--verbose', 'Be verbose') { self.verbose true }
|
86
|
+
@opts.on("--debug", "Debug setting") {self.debug true}
|
86
87
|
@opts.on('-s [file]', '--spec-file [file]', 'Set the spec file') { |file| self.spec file.chomp }
|
87
88
|
@opts.on('-t', '--test', 'Testing mode') { self.testing true }
|
88
89
|
|
@@ -36,6 +36,15 @@ module PoolParty
|
|
36
36
|
raise SpecException.new("Don't know how to handle instances cloud input #{arg}")
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
def setup_dev
|
41
|
+
unless ::File.exists?("#{full_keypair_basename_path}.pub")
|
42
|
+
cmd = "scp #{ssh_array.join(" ")} #{Base.user}@#{master.ip}:.ssh/authorized_keys #{full_keypair_basename_path}.pub"
|
43
|
+
vputs "Running #{cmd}"
|
44
|
+
Kernel.system(cmd)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
39
48
|
def full_keypair_path
|
40
49
|
unless keypair_path
|
41
50
|
raise RuntimeException.new("Keypair cannot be found")
|
@@ -43,6 +52,14 @@ module PoolParty
|
|
43
52
|
::File.expand_path(keypair_path)
|
44
53
|
end
|
45
54
|
end
|
55
|
+
def full_pub_keypair_path
|
56
|
+
@full_pub_keypair_path ||= ::File.expand_path("#{full_keypair_basename_path}.pub")
|
57
|
+
end
|
58
|
+
def full_keypair_basename_path
|
59
|
+
dir = ::File.dirname(full_keypair_path)
|
60
|
+
basename = ::File.basename(full_keypair_path, ::File.extname(full_keypair_path))
|
61
|
+
::File.join(dir, basename)
|
62
|
+
end
|
46
63
|
|
47
64
|
def keypair_path
|
48
65
|
keypair_paths.each do |path|
|
@@ -2,8 +2,8 @@ module PoolParty
|
|
2
2
|
module FileWriter
|
3
3
|
def copy_file_to_storage_directory(file, preceded="")
|
4
4
|
make_base_directory
|
5
|
-
path = ::File.join( Base.storage_directory, preceded, ::File.basename(file) )
|
6
|
-
FileUtils.cp file, path unless file == path || ::File.
|
5
|
+
path = ::File.join( Base.storage_directory, preceded, ::File.basename(file) )
|
6
|
+
::FileUtils.cp file, path unless file == path || ::File.file?(path)
|
7
7
|
end
|
8
8
|
def cleanup_storage_directory
|
9
9
|
Dir["#{Base.storage_directory}/**/*"].each do |f|
|
@@ -16,7 +16,7 @@ module PoolParty
|
|
16
16
|
end
|
17
17
|
# TODO: Fix cookie setting
|
18
18
|
def self.erl_command(hostname, extra="", min_ports=7000, max_ports=7050)
|
19
|
-
command_line_opts = "-pa #{append_dir}/ebin -kernel inet_dist_listen_min #{min_ports} inet_dist_listen_max #{max_ports} -sname #{hostname}
|
19
|
+
command_line_opts = "-pa #{append_dir}/ebin -kernel inet_dist_listen_min #{min_ports} inet_dist_listen_max #{max_ports} -sname #{hostname}"
|
20
20
|
|
21
21
|
"erl #{command_line_opts} #{extra}"
|
22
22
|
end
|
@@ -139,7 +139,8 @@ begin
|
|
139
139
|
[:ami, :availabilty_zone, :security_group]
|
140
140
|
end
|
141
141
|
|
142
|
-
#
|
142
|
+
# Hook
|
143
|
+
#TODO#: Change this so they match with the cap tasks
|
143
144
|
def custom_install_tasks_for(o)
|
144
145
|
arr = if has_cert_and_key?
|
145
146
|
[
|
@@ -159,11 +160,11 @@ begin
|
|
159
160
|
"cd /var/poolparty && wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-ec2.gem 2>&1",
|
160
161
|
"/usr/bin/gem install -y --no-ri --no-rdoc amazon-ec2.gem 2>&1",
|
161
162
|
]
|
163
|
+
[]
|
162
164
|
end
|
163
165
|
|
164
166
|
def custom_configure_tasks_for(o)
|
165
167
|
[
|
166
|
-
"# ec2 configuration"
|
167
168
|
]
|
168
169
|
end
|
169
170
|
|
@@ -28,11 +28,12 @@ module PoolParty
|
|
28
28
|
# Includes StrictHostKeyChecking to no
|
29
29
|
# Ssh with the user in Base
|
30
30
|
# And including the keypair_path
|
31
|
+
# "-l '#{Base.user}'",
|
31
32
|
def ssh_array
|
32
|
-
["-o StrictHostKeyChecking=no", "-l
|
33
|
+
["-o StrictHostKeyChecking=no", "-l #{Base.user}", '-i "'+full_keypair_path+'"']
|
33
34
|
end
|
34
35
|
def rsync_command
|
35
|
-
"rsync -azP --exclude cache -e '#{ssh_string}'"
|
36
|
+
"rsync -azP --exclude cache -e '#{ssh_string} -l #{Base.user}'"
|
36
37
|
end
|
37
38
|
def remote_ssh_array
|
38
39
|
["-o StrictHostKeyChecking=no", "-l '#{Base.user}'", '-i "'+remote_keypair_path+'"']
|
@@ -188,12 +189,13 @@ module PoolParty
|
|
188
189
|
last_instances.each do |inst|
|
189
190
|
vputs "Provision slave: #{inst}"
|
190
191
|
# hide_output {PoolParty::Provisioner.process_clean_reconfigure_for!(inst, self)}
|
191
|
-
PoolParty::Provisioner.provision_slave(inst, self, false) unless inst.master? rescue vputs "Error"
|
192
|
+
# PoolParty::Provisioner.provision_slave(inst, self, false) unless inst.master? rescue vputs "Error"
|
193
|
+
verbose ? provisioner_for(inst).install(testing) : hide_output { provisioner_for(inst).install(testing) }
|
192
194
|
# hide_output {PoolParty::Provisioner.process_clean_reconfigure_for!(inst, self)}
|
193
195
|
# cmd = ". /etc/profile && cloud-provision -i #{inst.name.gsub(/node/, '')} &"
|
194
196
|
# vputs "Provision slave with command #{cmd}"
|
195
197
|
end
|
196
|
-
PoolParty::Provisioner.reconfigure_master(self)
|
198
|
+
# PoolParty::Provisioner.reconfigure_master(self)
|
197
199
|
end
|
198
200
|
end
|
199
201
|
# Launch the master and let the master handle the starting of the cloud
|
@@ -203,7 +205,7 @@ module PoolParty
|
|
203
205
|
# Then wait for the master to launch
|
204
206
|
def launch_and_configure_master!(testing=false)
|
205
207
|
vputs "Requesting to launch new instance"
|
206
|
-
|
208
|
+
log.debug "Launching master"
|
207
209
|
request_launch_master_instance if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running? && !testing
|
208
210
|
reset!
|
209
211
|
unless testing
|
@@ -214,8 +216,8 @@ module PoolParty
|
|
214
216
|
vputs ""
|
215
217
|
vputs "Provisioning master..."
|
216
218
|
# cleanup_storage_directory
|
217
|
-
|
218
|
-
verbose ?
|
219
|
+
@provisioner = PoolParty::Provisioner::Capistrano.new(master, self, :ubuntu)
|
220
|
+
verbose ? @provisioner.install(testing) : hide_output { @provisioner.install(testing) }
|
219
221
|
|
220
222
|
after_launched
|
221
223
|
end
|
@@ -306,7 +308,9 @@ module PoolParty
|
|
306
308
|
|
307
309
|
# Ssh into the instance given
|
308
310
|
def ssh_into(instance=nil)
|
309
|
-
|
311
|
+
cmd = "#{ssh_command(instance)}"
|
312
|
+
vputs "Running #{cmd}"
|
313
|
+
Kernel.system cmd if instance
|
310
314
|
end
|
311
315
|
# Find the instance by the number given
|
312
316
|
# and then ssh into the instance
|
@@ -10,7 +10,7 @@ module PoolParty
|
|
10
10
|
def has_git_repos
|
11
11
|
has_package(:name => "git-core")
|
12
12
|
has_exec({:name => key, :requires => [get_directory("#{working_dir}"), get_package("git-core")] }) do
|
13
|
-
command
|
13
|
+
command requires_user ? "git clone #{requires_user}@#{source} #{working_dir}" : "cd #{working_dir} && git clone #{source}"
|
14
14
|
cwd "#{working_dir if working_dir}"
|
15
15
|
creates creates_dir
|
16
16
|
end
|
@@ -25,6 +25,10 @@ module PoolParty
|
|
25
25
|
has_directory(:name => "#{dir}", :requires => get_directory("#{::File.dirname(dir)}"))
|
26
26
|
end
|
27
27
|
|
28
|
+
def to(dir)
|
29
|
+
at(dir)
|
30
|
+
end
|
31
|
+
|
28
32
|
def creates_dir
|
29
33
|
"#{::File.join( working_dir, ::File.basename(source, ::File.extname(source)) )}/.git"
|
30
34
|
end
|
@@ -24,6 +24,7 @@ module PoolParty
|
|
24
24
|
include PrettyPrinter
|
25
25
|
include Configurable
|
26
26
|
include CloudResourcer
|
27
|
+
include Provisioner
|
27
28
|
# extend CloudResourcer
|
28
29
|
# Net methods
|
29
30
|
include Remote
|
@@ -39,6 +40,7 @@ module PoolParty
|
|
39
40
|
:ec2_dir => ENV["EC2_HOME"],
|
40
41
|
:keypair => (ENV["KEYPAIR_NAME"].nil? || ENV["KEYPAIR_NAME"].empty?) ? nil : ENV["KEYPAIR_NAME"],
|
41
42
|
:minimum_runtime => Base.minimum_runtime,
|
43
|
+
:user => Base.user,
|
42
44
|
:ami => 'ami-44bd592d'
|
43
45
|
})
|
44
46
|
|
@@ -145,7 +147,7 @@ module PoolParty
|
|
145
147
|
end
|
146
148
|
|
147
149
|
def copy_misc_templates
|
148
|
-
["namespaceauth.conf", "puppet.conf"].each do |f|
|
150
|
+
["namespaceauth.conf", "puppet.conf", "gem"].each do |f|
|
149
151
|
copy_file_to_storage_directory(::File.join(::File.dirname(__FILE__), "..", "templates", f))
|
150
152
|
end
|
151
153
|
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require "poolparty/capistrano"
|
2
|
+
|
3
|
+
module PoolParty
|
4
|
+
module Provisioner
|
5
|
+
class Capistrano < ProvisionerBase
|
6
|
+
|
7
|
+
include PoolParty::Capistrano
|
8
|
+
include ::Capistrano::Configuration::Actions::Invocation
|
9
|
+
|
10
|
+
def process_install!(testing=false)
|
11
|
+
unless testing
|
12
|
+
@cloud.rsync_storage_files_to(@instance)
|
13
|
+
roles = provision_master? ? [:master] : [:slaves]
|
14
|
+
run_capistrano(roles,:install)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def process_configure!(testing=false)
|
18
|
+
unless testing
|
19
|
+
@cloud.rsync_storage_files_to(@instance)
|
20
|
+
roles = provision_master? ? [:master] : [:slaves]
|
21
|
+
run_capistrano(roles, :configure)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def install_tasks
|
26
|
+
provision_master? ? master_install_tasks : slave_install_tasks
|
27
|
+
end
|
28
|
+
def configure_tasks
|
29
|
+
provision_master? ? master_configure_tasks : slave_configure_tasks
|
30
|
+
end
|
31
|
+
|
32
|
+
def master_install_tasks
|
33
|
+
[
|
34
|
+
"master:provision_master"
|
35
|
+
].push([custom_install_tasks, master_configure_tasks]).flatten#.map {|a| a.to_sym }
|
36
|
+
end
|
37
|
+
def master_configure_tasks
|
38
|
+
[
|
39
|
+
"master:create_local_node_entry_for_puppet", "master:move_template_files", "master:setup_poolparty_base_structure",
|
40
|
+
"master:move_provisioner_manifest", "run_provisioner"
|
41
|
+
].push(custom_configure_tasks).flatten#.map {|a| a.to_sym }
|
42
|
+
end
|
43
|
+
|
44
|
+
def slave_install_tasks
|
45
|
+
[
|
46
|
+
"slave:add_master_to_hosts_file", "slave:add_provisioner_configs", "setup_provisioner_config",
|
47
|
+
"create_puppetrunner_command", "create_puppetrerun_command", "install_rubygems",
|
48
|
+
"install_provisioner", "slave:stop_provisioner_daemon"
|
49
|
+
].push([custom_install_tasks, slave_configure_tasks]).flatten#.map {|a| a.to_sym }
|
50
|
+
end
|
51
|
+
def slave_configure_tasks
|
52
|
+
[
|
53
|
+
"run_provisioner"
|
54
|
+
].push(custom_configure_tasks).flatten#.map {|a| a.to_sym }
|
55
|
+
end
|
56
|
+
# Run tasks after the initialized
|
57
|
+
def loaded
|
58
|
+
create_config
|
59
|
+
end
|
60
|
+
|
61
|
+
# Create the config for capistrano
|
62
|
+
# This is a dynamic capistrano configuration file
|
63
|
+
def create_config
|
64
|
+
@config = ::Capistrano::Configuration.new
|
65
|
+
if @cloud.debug || @cloud.verbose
|
66
|
+
@config.logger.level = @cloud.debug ? ::Capistrano::Logger::MAX_LEVEL : ::Capistrano::Logger::INFO
|
67
|
+
else
|
68
|
+
@config.logger.level = ::Capistrano::Logger::IMPORTANT
|
69
|
+
end
|
70
|
+
|
71
|
+
capfile = returning Array.new do |arr|
|
72
|
+
Dir["#{::File.dirname(__FILE__)}/recipies/*.rb"].each {|a| arr << "require '#{a}'" }
|
73
|
+
arr << "ssh_options[:keys] = '#{@cloud.full_keypair_basename_path}'"
|
74
|
+
|
75
|
+
arr << set_poolparty_roles
|
76
|
+
end.join("\n")
|
77
|
+
|
78
|
+
@config.provisioner = self
|
79
|
+
@config.cloud = @cloud
|
80
|
+
|
81
|
+
@config.load(:string => capfile)
|
82
|
+
|
83
|
+
@cloud.deploy_file ? @config.load(@cloud.deploy_file) : @config.set(:user, @cloud.user)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Prerun
|
87
|
+
def prerun_setup
|
88
|
+
end
|
89
|
+
|
90
|
+
def run_capistrano(roles=[:master], meth=:install)
|
91
|
+
prerun_setup
|
92
|
+
|
93
|
+
commands = meth == :install ? install_tasks : configure_tasks
|
94
|
+
name = "provisioner_#{meth}"
|
95
|
+
|
96
|
+
__define_task(name, roles) do
|
97
|
+
commands.map {|command|
|
98
|
+
task = find_task(command)
|
99
|
+
task.options.merge!(:roles => roles)
|
100
|
+
execute_task task
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
# @config.task_list(:all).each {|t| puts "t: #{t.fully_qualified_name}"}
|
105
|
+
|
106
|
+
begin
|
107
|
+
__run(name)
|
108
|
+
return true
|
109
|
+
rescue ::Capistrano::CommandError => e
|
110
|
+
return false unless verbose
|
111
|
+
raise ProvisionerException.new("Error: #{e}")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def __define_task(name, roles, &block)
|
116
|
+
@config.task __task_sym(name), :roles => roles, &block
|
117
|
+
end
|
118
|
+
|
119
|
+
def __run(task)
|
120
|
+
@config.send __task_sym(task)
|
121
|
+
end
|
122
|
+
|
123
|
+
def __task_sym(name)
|
124
|
+
"#{name.to_s.downcase.underscore}".to_sym
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|