poolparty 0.0.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +25 -0
- data/License.txt +20 -0
- data/Manifest.txt +203 -0
- data/PostInstall.txt +18 -0
- data/README.txt +21 -82
- data/Rakefile +25 -18
- data/bin/cloud +31 -0
- data/bin/cloud-add-keypair +23 -0
- data/bin/cloud-configure +31 -0
- data/bin/cloud-contract +27 -0
- data/bin/cloud-expand +27 -0
- data/bin/cloud-list +32 -0
- data/bin/cloud-maintain +36 -0
- data/bin/cloud-osxcopy +22 -0
- data/bin/cloud-provision +31 -0
- data/bin/cloud-refresh +26 -0
- data/bin/cloud-ssh +18 -0
- data/bin/cloud-start +32 -0
- data/bin/cloud-terminate +23 -0
- data/bin/pool +25 -27
- data/bin/pool-console +12 -0
- data/bin/pool-describe +9 -0
- data/bin/pool-list +28 -0
- data/bin/pool-provision +34 -0
- data/bin/pool-spec +17 -0
- data/bin/pool-start +32 -0
- data/bin/pool-start-monitor +1 -0
- data/config/hoe.rb +115 -0
- data/config/requirements.rb +15 -0
- data/examples/basic.rb +20 -0
- data/examples/plugin_without_plugin_directory.rb +13 -0
- data/examples/poolparty.rb +12 -0
- data/examples/with_apache_plugin.rb +22 -0
- data/generators/poolspec/USAGE +5 -0
- data/generators/poolspec/poolspec_generator.rb +65 -0
- data/generators/poolspec/templates/pool_spec_template.erb +9 -0
- data/lib/erlang/eb_server.erl +27 -0
- data/lib/poolparty.rb +56 -0
- data/lib/poolparty/base_packages/haproxy.rb +42 -0
- data/lib/poolparty/base_packages/heartbeat.rb +45 -0
- data/lib/poolparty/base_packages/poolparty.rb +36 -0
- data/lib/poolparty/base_packages/ruby.rb +43 -0
- data/lib/poolparty/core/array.rb +24 -0
- data/lib/{core → poolparty/core}/exception.rb +0 -0
- data/lib/poolparty/core/float.rb +13 -0
- data/lib/poolparty/core/hash.rb +29 -0
- data/lib/poolparty/core/kernel.rb +37 -0
- data/lib/{core → poolparty/core}/module.rb +18 -0
- data/lib/poolparty/core/my_open_struct.rb +18 -0
- data/lib/poolparty/core/object.rb +54 -0
- data/lib/poolparty/core/proc.rb +7 -0
- data/lib/poolparty/core/string.rb +72 -0
- data/lib/poolparty/core/symbol.rb +8 -0
- data/lib/{core → poolparty/core}/time.rb +15 -0
- data/lib/poolparty/exceptions/RemoteException.rb +12 -0
- data/lib/poolparty/exceptions/ResourceException.rb +7 -0
- data/lib/poolparty/exceptions/RuntimeException.rb +7 -0
- data/lib/poolparty/exceptions/SpecException.rb +7 -0
- data/lib/poolparty/exceptions/TemplateNotFound.rb +7 -0
- data/lib/poolparty/helpers/binary.rb +31 -0
- data/lib/poolparty/helpers/console.rb +30 -0
- data/lib/poolparty/helpers/display.rb +34 -0
- data/lib/poolparty/helpers/optioner.rb +64 -0
- data/lib/poolparty/helpers/provisioner_base.rb +250 -0
- data/lib/poolparty/helpers/provisioners/master.rb +136 -0
- data/lib/poolparty/helpers/provisioners/slave.rb +44 -0
- data/lib/poolparty/modules/cloud_resourcer.rb +89 -0
- data/lib/poolparty/modules/configurable.rb +34 -0
- data/lib/poolparty/modules/definable_resource.rb +59 -0
- data/lib/poolparty/modules/file_writer.rb +55 -0
- data/lib/poolparty/modules/method_missing_sugar.rb +53 -0
- data/lib/poolparty/modules/output.rb +13 -0
- data/lib/poolparty/modules/pretty_printer.rb +39 -0
- data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -22
- data/lib/{modules → poolparty/modules}/safe_instance.rb +0 -0
- data/lib/poolparty/monitors/base_monitor.rb +16 -0
- data/lib/poolparty/net/remote.rb +35 -0
- data/lib/poolparty/net/remote_bases/ec2.rb +148 -0
- data/lib/poolparty/net/remote_instance.rb +69 -0
- data/lib/poolparty/net/remoter.rb +224 -0
- data/lib/poolparty/net/remoter_base.rb +117 -0
- data/lib/poolparty/plugins/gem_package.rb +17 -0
- data/lib/poolparty/plugins/git.rb +41 -0
- data/lib/poolparty/plugins/line.rb +76 -0
- data/lib/poolparty/plugins/svn.rb +48 -0
- data/lib/poolparty/pool/base.rb +75 -0
- data/lib/poolparty/pool/cloud.rb +164 -0
- data/lib/poolparty/pool/custom_resource.rb +61 -0
- data/lib/poolparty/pool/loggable.rb +29 -0
- data/lib/poolparty/pool/plugin.rb +41 -0
- data/lib/poolparty/pool/plugin_model.rb +48 -0
- data/lib/poolparty/pool/pool.rb +55 -0
- data/lib/poolparty/pool/resource.rb +248 -0
- data/lib/poolparty/pool/resources/class_package.rb +64 -0
- data/lib/poolparty/pool/resources/conditional.rb +41 -0
- data/lib/poolparty/pool/resources/cron.rb +14 -0
- data/lib/poolparty/pool/resources/directory.rb +23 -0
- data/lib/poolparty/pool/resources/exec.rb +26 -0
- data/lib/poolparty/pool/resources/file.rb +23 -0
- data/lib/poolparty/pool/resources/gem.rb +14 -0
- data/lib/poolparty/pool/resources/host.rb +14 -0
- data/lib/poolparty/pool/resources/package.rb +14 -0
- data/lib/poolparty/pool/resources/remote_file.rb +22 -0
- data/lib/poolparty/pool/resources/service.rb +21 -0
- data/lib/poolparty/pool/resources/sshkey.rb +19 -0
- data/lib/poolparty/pool/resources/variable.rb +27 -0
- data/lib/poolparty/pool/script.rb +44 -0
- data/lib/poolparty/templates/authkeys +2 -0
- data/{config/monit/nginx.monit.conf → lib/poolparty/templates/cib.xml} +0 -0
- data/lib/poolparty/templates/fileserver.conf +4 -0
- data/lib/poolparty/templates/gem +25 -0
- data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -2
- data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
- data/lib/poolparty/templates/namespaceauth.conf +19 -0
- data/lib/poolparty/templates/puppet.conf +17 -0
- data/lib/poolparty/version.rb +9 -0
- data/lib/poolpartycl.rb +3 -0
- data/poolparty.gemspec +56 -47
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
- data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
- data/spec/poolparty/bin/console_spec.rb +80 -0
- data/spec/poolparty/core/array_spec.rb +26 -0
- data/spec/poolparty/core/float.rb +13 -0
- data/spec/poolparty/core/hash_spec.rb +63 -0
- data/spec/poolparty/core/kernel_spec.rb +24 -0
- data/spec/poolparty/core/module_spec.rb +15 -0
- data/spec/poolparty/core/object_spec.rb +40 -0
- data/spec/poolparty/core/string_spec.rb +152 -0
- data/spec/poolparty/core/time_spec.rb +52 -0
- data/spec/poolparty/helpers/binary_spec.rb +26 -0
- data/spec/poolparty/helpers/display_spec.rb +13 -0
- data/spec/poolparty/helpers/optioner_spec.rb +39 -0
- data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
- data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
- data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
- data/spec/poolparty/modules/configurable_spec.rb +26 -0
- data/spec/poolparty/modules/definable_resource.rb +9 -0
- data/spec/poolparty/modules/file_writer_spec.rb +49 -0
- data/spec/poolparty/modules/s3_string_spec.rb +15 -0
- data/spec/poolparty/modules/tmp/willy/nilly.rb +1 -0
- data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
- data/spec/poolparty/net/remote_instance_spec.rb +70 -0
- data/spec/poolparty/net/remote_spec.rb +286 -0
- data/spec/poolparty/net/remoter_base_spec.rb +80 -0
- data/spec/poolparty/net/remoter_spec.rb +191 -0
- data/spec/poolparty/plugins/git_spec.rb +33 -0
- data/spec/poolparty/plugins/line_spec.rb +16 -0
- data/spec/poolparty/plugins/svn_spec.rb +16 -0
- data/spec/poolparty/pool/base_spec.rb +108 -0
- data/spec/poolparty/pool/cloud_spec.rb +299 -0
- data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
- data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
- data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
- data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
- data/spec/poolparty/pool/example_spec.rb +112 -0
- data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
- data/spec/poolparty/pool/plugin_spec.rb +85 -0
- data/spec/poolparty/pool/pool_spec.rb +83 -0
- data/spec/poolparty/pool/resource_spec.rb +224 -0
- data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
- data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
- data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
- data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
- data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
- data/spec/poolparty/pool/resources/file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
- data/spec/poolparty/pool/resources/host_spec.rb +28 -0
- data/spec/poolparty/pool/resources/package_spec.rb +44 -0
- data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/service_spec.rb +45 -0
- data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
- data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
- data/spec/poolparty/pool/script_spec.rb +51 -0
- data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
- data/{test/test_pool_party.rb → spec/poolparty/pool/test_plugins/virtual_host_template.erb} +0 -0
- data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
- data/spec/poolparty/poolparty_spec.rb +33 -0
- data/spec/poolparty/spec_helper.rb +120 -0
- data/tasks/cloud.rake +57 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/development.rake +78 -0
- data/tasks/ec2.rake +20 -0
- data/tasks/environment.rake +7 -0
- data/tasks/instance.rake +63 -0
- data/tasks/server.rake +42 -0
- data/tasks/spec.rake +17 -0
- data/tasks/website.rake +17 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/test/test_pool_spec_generator.rb +47 -0
- data/test/test_poolparty.rb +11 -0
- data/test_manifest.pp +538 -0
- data/website/index.html +107 -0
- data/website/index.txt +95 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/code.css +29 -0
- data/website/stylesheets/screen.css +147 -0
- data/website/template.html.erb +49 -0
- metadata +282 -101
- data/CHANGELOG +0 -4
- data/Manifest +0 -55
- data/bin/instance +0 -54
- data/config/config.yml +0 -23
- data/config/create_proxy_ami.sh +0 -582
- data/config/heartbeat_authkeys.conf +0 -2
- data/config/monit.conf +0 -8
- data/config/monit/haproxy.monit.conf +0 -7
- data/config/nginx.conf +0 -24
- data/lib/core/array.rb +0 -10
- data/lib/core/kernel.rb +0 -9
- data/lib/core/object.rb +0 -14
- data/lib/modules/callback.rb +0 -55
- data/lib/modules/ec2_wrapper.rb +0 -74
- data/lib/pool_party.rb +0 -69
- data/lib/pool_party/application.rb +0 -133
- data/lib/pool_party/init.rb +0 -4
- data/lib/pool_party/master.rb +0 -189
- data/lib/pool_party/monitors.rb +0 -13
- data/lib/pool_party/monitors/cpu.rb +0 -18
- data/lib/pool_party/monitors/memory.rb +0 -21
- data/lib/pool_party/monitors/web.rb +0 -18
- data/lib/pool_party/optioner.rb +0 -16
- data/lib/pool_party/os.rb +0 -11
- data/lib/pool_party/os/ubuntu.rb +0 -78
- data/lib/pool_party/remote_instance.rb +0 -180
- data/lib/pool_party/remoting.rb +0 -112
- data/lib/pool_party/scheduler.rb +0 -93
- data/lib/pool_party/tasks.rb +0 -220
- data/lib/s3/s3_object_store_folders.rb +0 -44
- data/spec/application_spec.rb +0 -32
- data/spec/callback_spec.rb +0 -65
- data/spec/helpers/ec2_mock.rb +0 -56
- data/spec/helpers/remote_instance_mock.rb +0 -11
- data/spec/kernel_spec.rb +0 -11
- data/spec/master_spec.rb +0 -147
- data/spec/monitor_spec.rb +0 -16
- data/spec/optioner_spec.rb +0 -22
- data/spec/poolparty_spec.rb +0 -8
- data/spec/remote_instance_spec.rb +0 -29
- data/spec/remoting_spec.rb +0 -75
- data/spec/spec_helper.rb +0 -38
- data/spec/string_spec.rb +0 -28
@@ -38,4 +38,19 @@ class Numeric
|
|
38
38
|
self * 7.days
|
39
39
|
end
|
40
40
|
alias :week :weeks
|
41
|
+
|
42
|
+
def months
|
43
|
+
self * 31.days
|
44
|
+
end
|
45
|
+
alias :month :months
|
46
|
+
|
47
|
+
def time_ago
|
48
|
+
out = %w(year month week day hour minute).detect {|unit| self > 1.send(unit) }
|
49
|
+
units_ago(out, self) rescue "Less than a minute ago"
|
50
|
+
end
|
51
|
+
|
52
|
+
def units_ago(unit,seconds)
|
53
|
+
in_units = (seconds / 1.send(unit))
|
54
|
+
"#{in_units.to_i} #{in_units != 1 ? unit.to_s.pluralize : unit} ago"
|
55
|
+
end
|
41
56
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class RemoteException < Exception
|
2
|
+
EXCEPTION_MESSAGES = {
|
3
|
+
:method_not_defined => "Method is not defined",
|
4
|
+
:invalid_formatting => "Invalid formatting",
|
5
|
+
:could_not_install => "Could not install"
|
6
|
+
}
|
7
|
+
attr_reader :message
|
8
|
+
|
9
|
+
def initialize(type=:method_not_defined, note="")
|
10
|
+
@message = "Remote Exception: #{EXCEPTION_MESSAGES[type]} #{note}"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "ftools"
|
2
|
+
module PoolParty
|
3
|
+
module Binary
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def list_binaries_for(ty="pool")
|
8
|
+
available_binaries_for(ty).join(", ")
|
9
|
+
end
|
10
|
+
def available_binaries_for(ty="pool")
|
11
|
+
Dir["#{binary_directory}/#{ty}-*"].map {|a| File.basename(a.gsub(/#{ty}-/, '')) }.sort
|
12
|
+
end
|
13
|
+
def binary_directory
|
14
|
+
"#{::File.dirname(__FILE__)}/../../../bin"
|
15
|
+
end
|
16
|
+
def get_existing_spec_location
|
17
|
+
[
|
18
|
+
"#{Base.base_config_directory}/#{Base.default_specfile_name}",
|
19
|
+
"#{Base.remote_storage_path}/#{Base.default_specfile_name}",
|
20
|
+
ENV["POOL_SPEC"],
|
21
|
+
"#{Base.default_specfile_name}",
|
22
|
+
"#{Base.storage_directory}/#{Base.default_specfile_name}",
|
23
|
+
].reject {|a| a.nil?}.reject do |f|
|
24
|
+
f unless ::File.file?(f)
|
25
|
+
end.first
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/display"
|
2
|
+
|
3
|
+
module PoolParty
|
4
|
+
module Console
|
5
|
+
|
6
|
+
include Display
|
7
|
+
|
8
|
+
# Load a file that contains a pool into memory
|
9
|
+
def load_pool(filename)
|
10
|
+
unless filename && ::File.file?(filename)
|
11
|
+
puts "Could not load pool"
|
12
|
+
exit
|
13
|
+
else
|
14
|
+
PoolParty::Script.inflate(open(filename).read, File.dirname(filename))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Clear all the pools and reload the console
|
19
|
+
# Call within console to reset and reload the entire poolparty base
|
20
|
+
# as well
|
21
|
+
def reload!
|
22
|
+
reset!
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Object
|
29
|
+
include PoolParty::Console
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module PoolParty
|
2
|
+
module Display
|
3
|
+
|
4
|
+
def pool_describe(options={})
|
5
|
+
if pools.size > 0
|
6
|
+
pools.each do |k,v|
|
7
|
+
print v.pretty_print
|
8
|
+
end
|
9
|
+
else
|
10
|
+
prev = "\t"
|
11
|
+
clouds.each do |name, cl|
|
12
|
+
puts cl.pretty_name(prev*2, cl)
|
13
|
+
puts cl.pretty_options(prev*2, cl) #cl.pretty_print("#{prev}\t")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
puts ""
|
18
|
+
pools.size
|
19
|
+
end
|
20
|
+
|
21
|
+
def available_bases
|
22
|
+
puts Remote.available_bases
|
23
|
+
end
|
24
|
+
|
25
|
+
def header(str="")
|
26
|
+
"*** #{str}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def subheader(str="")
|
30
|
+
"****** #{str}"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'rdoc/usage'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module PoolParty
|
7
|
+
class Optioner
|
8
|
+
include Configurable
|
9
|
+
include MethodMissingSugar
|
10
|
+
|
11
|
+
def initialize(args=[], opts={}, &block)
|
12
|
+
@arguments = args
|
13
|
+
@parse_options = opts[:parse_options] ? opts[:parse_options] : true
|
14
|
+
|
15
|
+
set_default_options
|
16
|
+
parse_options(&block) if @parse_options
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def parent
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_default_options
|
25
|
+
@options = {}
|
26
|
+
@options[:verbose] = false
|
27
|
+
@options[:quiet] = false
|
28
|
+
@options[:version] = PoolParty::VERSION::STRING
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_options(&blk)
|
32
|
+
opts = OptionParser.new
|
33
|
+
opts.banner = "Usage: pool [command] [options]"
|
34
|
+
|
35
|
+
opts.separator ""
|
36
|
+
opts.separator "Options:"
|
37
|
+
|
38
|
+
opts.on('-V', '--version', 'Display the version') { output_version ; exit 0 }
|
39
|
+
opts.on('-v', '--verbose', 'Be verbose') { @options[:verbose] = true }
|
40
|
+
opts.on('-s [file]', '--spec-file [file]', 'Set the spec file') { |file| self.spec file }
|
41
|
+
opts.on('-t', '--test', 'Testing mode') { self.testing "true" }
|
42
|
+
|
43
|
+
blk.call(opts, self) if blk
|
44
|
+
|
45
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
46
|
+
puts opts
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.parse!(@arguments)
|
51
|
+
|
52
|
+
process_options
|
53
|
+
output_options if verbose
|
54
|
+
end
|
55
|
+
def process_options
|
56
|
+
@options[:verbose] = false if @options[:quiet]
|
57
|
+
end
|
58
|
+
|
59
|
+
def output_version
|
60
|
+
puts version
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,250 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
The Provisioner is responsible for provisioning REMOTE servers
|
3
|
+
This class only comes in to play when calling the setup commands on
|
4
|
+
the development machine
|
5
|
+
=end
|
6
|
+
module PoolParty
|
7
|
+
module Provisioner
|
8
|
+
|
9
|
+
# Provision master
|
10
|
+
# Convenience method to clean
|
11
|
+
def self.provision_master(cloud, testing=false)
|
12
|
+
Provisioner::Master.new(cloud).process_install!(testing)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure_master(cloud, testing=false)
|
16
|
+
Provisioner::Master.new(cloud).process_configure!(testing)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.provision_slaves(cloud, testing=false)
|
20
|
+
cloud.nonmaster_nonterminated_instances.each do |sl|
|
21
|
+
provision_slave(sl, cloud, testing)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configure_slaves(cloud, testing=false)
|
26
|
+
cloud.nonmaster_nonterminated_instances.each do |sl|
|
27
|
+
configure_slave(sl, cloud, testing)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.provision_slave(instance, cloud, testing=false)
|
32
|
+
Provisioner::Slave.new(instance, cloud).process_install!(testing)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.configure_slave(instance, cloud, testing=false)
|
36
|
+
Provisioner::Slave.new(instance, cloud).process_configure!(testing)
|
37
|
+
end
|
38
|
+
|
39
|
+
class ProvisionerBase
|
40
|
+
|
41
|
+
include Configurable
|
42
|
+
include CloudResourcer
|
43
|
+
|
44
|
+
def initialize(instance,cloud=self, os=:ubuntu)
|
45
|
+
@instance = instance
|
46
|
+
@cloud = cloud
|
47
|
+
|
48
|
+
options(cloud.options) if cloud && cloud.respond_to?(:options)
|
49
|
+
set_vars_from_options(instance.options) unless instance.nil? || instance.options.empty?
|
50
|
+
options(instance.options) if instance.respond_to?(:options)
|
51
|
+
|
52
|
+
@os = os.to_s.downcase.to_sym
|
53
|
+
loaded
|
54
|
+
end
|
55
|
+
# Callback after initialized
|
56
|
+
def loaded
|
57
|
+
end
|
58
|
+
# This is the actual runner for the installation
|
59
|
+
def install
|
60
|
+
valid? ? install_string : error
|
61
|
+
end
|
62
|
+
def write_install_file
|
63
|
+
error unless valid?
|
64
|
+
::FileUtils.mkdir_p Base.storage_directory unless ::File.exists?(Base.storage_directory)
|
65
|
+
provisioner_file = ::File.join(Base.storage_directory, "install_#{name}.sh")
|
66
|
+
::File.open(provisioner_file, "w+") {|f| f << install }
|
67
|
+
end
|
68
|
+
def process_install!(testing=false)
|
69
|
+
error unless valid?
|
70
|
+
write_install_file
|
71
|
+
setup_runner(@cloud)
|
72
|
+
|
73
|
+
unless testing
|
74
|
+
puts "Logging on to #{@instance.ip}"
|
75
|
+
@cloud.rsync_storage_files_to(@instance)
|
76
|
+
|
77
|
+
cmd = "cd #{Base.remote_storage_path}/#{Base.tmp_path} && chmod +x install_#{name}.sh && /bin/sh install_#{name}.sh && rm -rf *"
|
78
|
+
hide_output do
|
79
|
+
@cloud.run_command_on(cmd, @instance)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
def configure
|
84
|
+
valid? ? configure_string : error
|
85
|
+
end
|
86
|
+
def write_configure_file
|
87
|
+
error unless valid?
|
88
|
+
provisioner_file = ::File.join(Base.storage_directory, "configure_#{name}.sh")
|
89
|
+
::File.open(provisioner_file, "w+") {|f| f << configure }
|
90
|
+
end
|
91
|
+
def process_configure!(testing=false)
|
92
|
+
error unless valid?
|
93
|
+
write_configure_file
|
94
|
+
setup_runner(@cloud)
|
95
|
+
|
96
|
+
unless testing
|
97
|
+
@cloud.rsync_storage_files_to(@instance)
|
98
|
+
|
99
|
+
cmd = "cd #{Base.remote_storage_path}/#{Base.tmp_path} && chmod +x configure_#{name}.sh && /bin/sh configure_#{name}.sh && rm -rf *"
|
100
|
+
@cloud.run_command_on(cmd, @instance)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
def setup_runner(cloud)
|
104
|
+
cloud.prepare_to_configuration
|
105
|
+
cloud.build_and_store_new_config_file
|
106
|
+
end
|
107
|
+
def valid?
|
108
|
+
true
|
109
|
+
end
|
110
|
+
def error
|
111
|
+
"Error in installation"
|
112
|
+
end
|
113
|
+
# Gather all the tasks into one string
|
114
|
+
def install_string
|
115
|
+
(default_install_tasks).each do |task|
|
116
|
+
case task.class
|
117
|
+
when String
|
118
|
+
task
|
119
|
+
when Method
|
120
|
+
self.send(task.to_sym)
|
121
|
+
end
|
122
|
+
end.nice_runnable
|
123
|
+
end
|
124
|
+
def configure_string
|
125
|
+
(default_configure_tasks).each do |task|
|
126
|
+
case task.class
|
127
|
+
when String
|
128
|
+
task
|
129
|
+
when Method
|
130
|
+
self.send(task.to_sym)
|
131
|
+
end
|
132
|
+
end.nice_runnable
|
133
|
+
end
|
134
|
+
# Tasks with default tasks
|
135
|
+
# These are run on all the provisioners, master or slave
|
136
|
+
def default_install_tasks
|
137
|
+
[
|
138
|
+
upgrade_system,
|
139
|
+
install_puppet_master,
|
140
|
+
custom_install_tasks
|
141
|
+
] << install_tasks
|
142
|
+
end
|
143
|
+
# Tasks with default configuration tasks
|
144
|
+
# This is run on the provisioner, regardless
|
145
|
+
def default_configure_tasks
|
146
|
+
[
|
147
|
+
custom_configure_tasks
|
148
|
+
] << configure_tasks
|
149
|
+
end
|
150
|
+
# Build a list of the tasks to run on the instance
|
151
|
+
def install_tasks(a=[])
|
152
|
+
@install_task ||= a
|
153
|
+
end
|
154
|
+
def configure_tasks(a=[])
|
155
|
+
@configure_tasks ||= a
|
156
|
+
end
|
157
|
+
# Custom installation tasks
|
158
|
+
# Allow the remoter bases to attach their own tasks on the
|
159
|
+
# installation process
|
160
|
+
def custom_install_tasks
|
161
|
+
@cloud.custom_install_tasks_for(@instance) || []
|
162
|
+
end
|
163
|
+
# Custom configure tasks
|
164
|
+
# Allows the remoter bases to attach their own
|
165
|
+
# custom configuration tasks to the configuration process
|
166
|
+
def custom_configure_tasks
|
167
|
+
@cloud.custom_configure_tasks_for(@instance) || []
|
168
|
+
end
|
169
|
+
|
170
|
+
# Get the packages associated with each os
|
171
|
+
def puppet_packages
|
172
|
+
case @os
|
173
|
+
when :fedora
|
174
|
+
"puppet-server puppet factor"
|
175
|
+
else
|
176
|
+
"puppet puppetmaster"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
# Package installers for general *nix operating systems
|
180
|
+
def self.installers
|
181
|
+
@installers ||= {
|
182
|
+
:ubuntu => "apt-get install -y",
|
183
|
+
:fedora => "yum install",
|
184
|
+
:gentoo => "emerge"
|
185
|
+
}
|
186
|
+
end
|
187
|
+
# Convenience method to grab the installer
|
188
|
+
def installer_for(names=[])
|
189
|
+
packages = names.is_a?(Array) ? names.join(" ") : names
|
190
|
+
"#{self.class.installers[@os]} #{packages}"
|
191
|
+
end
|
192
|
+
|
193
|
+
# Install from the class-level
|
194
|
+
def self.install(instance, cl=self)
|
195
|
+
new(instance, cl).install
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.configure(instance, cl=self)
|
199
|
+
new(instance, cl).configure
|
200
|
+
end
|
201
|
+
|
202
|
+
# Template directory from the provisioner base
|
203
|
+
def template_directory
|
204
|
+
File.join(File.dirname(__FILE__), "..", "templates")
|
205
|
+
end
|
206
|
+
|
207
|
+
def create_local_node
|
208
|
+
str = <<-EOS
|
209
|
+
node default {
|
210
|
+
include poolparty
|
211
|
+
}
|
212
|
+
EOS
|
213
|
+
@cloud.list_of_running_instances.each do |ri|
|
214
|
+
str << <<-EOS
|
215
|
+
node "#{ri.name}" {}
|
216
|
+
EOS
|
217
|
+
end
|
218
|
+
"echo '#{str}' > /etc/puppet/manifests/nodes/nodes.pp"
|
219
|
+
end
|
220
|
+
|
221
|
+
def upgrade_system
|
222
|
+
case @os
|
223
|
+
when :ubuntu
|
224
|
+
"
|
225
|
+
touch /etc/apt/sources.list
|
226
|
+
echo 'deb http://mirrors.kernel.org/ubuntu hardy main universe' >> /etc/apt/sources.list
|
227
|
+
apt-get update --fix-missing -y
|
228
|
+
apt-get upgrade -y
|
229
|
+
"
|
230
|
+
else
|
231
|
+
"# No system upgrade needed"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def install_puppet_master
|
236
|
+
"#{installer_for( puppet_packages )}"
|
237
|
+
end
|
238
|
+
|
239
|
+
def create_poolparty_manifest
|
240
|
+
<<-EOS
|
241
|
+
mv #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes
|
242
|
+
EOS
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
## Load the provisioners
|
248
|
+
Dir[File.dirname(__FILE__) + "/provisioners/*.rb"].each do |file|
|
249
|
+
require file
|
250
|
+
end
|