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
data/tasks/ec2.rake
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
namespace(:ec2) do
|
2
|
+
task :init do
|
3
|
+
%x[ec2-authorize default -P icmp -t -1:-1 -s 0.0.0.0/0]
|
4
|
+
end
|
5
|
+
# Start a new instance in the cloud
|
6
|
+
desc "Add and start an instance to the pool"
|
7
|
+
task :start_new_instance => [:init] do
|
8
|
+
puts PoolParty::Remoting.new.launch_new_instance!
|
9
|
+
end
|
10
|
+
# Stop all the instances via command-line
|
11
|
+
desc "Stop all running instances"
|
12
|
+
task :stop_running_instances => [:init] do
|
13
|
+
Thread.new {`ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2}' | xargs ec2-terminate-instances`}
|
14
|
+
end
|
15
|
+
# Reboot the instances via commandline
|
16
|
+
desc "Restart all running instances"
|
17
|
+
task :restart_running_instances => [:init] do
|
18
|
+
Thread.new {`ec2-describe-instances | grep INSTANCE | grep running | awk '{print $2}' | xargs ec2-reboot-instances`}
|
19
|
+
end
|
20
|
+
end
|
data/tasks/instance.rake
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
namespace(:instance) do
|
2
|
+
# Find the instance we want to deal with
|
3
|
+
# interface can be: num=0, i=0, inst=0, 0
|
4
|
+
# defaults to the master instance (0)
|
5
|
+
task :init do
|
6
|
+
num = (ENV['num'] || ENV["i"] || ENV["inst"] || ARGV.shift || 0).to_i
|
7
|
+
raise Exception.new("Please set the number of the instance (i.e. num=1, i=1, or as an argument)") unless num
|
8
|
+
@node = PoolParty::Master.new.get_node(num)
|
9
|
+
end
|
10
|
+
# Ssh into the node
|
11
|
+
desc "Remotely login to the remote instance"
|
12
|
+
task :ssh => [:init] do
|
13
|
+
@node.ssh
|
14
|
+
end
|
15
|
+
desc "Send a file to the remote instance"
|
16
|
+
task :exec => :init do
|
17
|
+
@node.ssh ENV['cmd']
|
18
|
+
end
|
19
|
+
# Send a file to the remote instance
|
20
|
+
# as designated by src='' and dest=''
|
21
|
+
desc "Send a file to the remote instance"
|
22
|
+
task :scp => :init do
|
23
|
+
@node.scp ENV['src'], ENV['dest']
|
24
|
+
end
|
25
|
+
# Execute a command on the remote instance as designated
|
26
|
+
# by cmd=''
|
27
|
+
desc "Execute cmd on a remote instance"
|
28
|
+
task :exec => [:init] do
|
29
|
+
cmd = ENV['cmd'] || "ls -l"
|
30
|
+
puts @node.ssh(cmd.runnable)
|
31
|
+
end
|
32
|
+
# Restart all the services monitored by monit
|
33
|
+
desc "Restart all the services"
|
34
|
+
task :reload => [:init] do
|
35
|
+
@node.restart_with_monit
|
36
|
+
end
|
37
|
+
# Start all the services monitored by monit
|
38
|
+
desc "Start all services"
|
39
|
+
task :load => [:init] do
|
40
|
+
@node.start_with_monit
|
41
|
+
end
|
42
|
+
# Stop the services monitored by monit
|
43
|
+
desc "Stop all services"
|
44
|
+
task :stop => [:init] do
|
45
|
+
@node.stop_with_monit
|
46
|
+
end
|
47
|
+
# Install the required services on this node
|
48
|
+
desc "Install stack on this node"
|
49
|
+
task :install => :init do
|
50
|
+
@node.install
|
51
|
+
end
|
52
|
+
# Turnoff this instance
|
53
|
+
desc "Teardown instance"
|
54
|
+
task :shutdown => :init do
|
55
|
+
`ec2-terminate-instances #{@node.instance_id}`
|
56
|
+
end
|
57
|
+
# Configure this node and start the services
|
58
|
+
desc "Configure the stack on this node"
|
59
|
+
task :configure => :init do
|
60
|
+
@node.configure
|
61
|
+
@node.restart_with_monit
|
62
|
+
end
|
63
|
+
end
|
data/tasks/server.rake
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Tasks to be run on the server
|
2
|
+
namespace(:server) do
|
3
|
+
task :init do
|
4
|
+
PoolParty::Coordinator.init(false)
|
5
|
+
end
|
6
|
+
# bundle, upload and register your bundle on the server
|
7
|
+
desc "Bundle, upload and register your ami"
|
8
|
+
task :all => [:bundle, :upload, :register] do
|
9
|
+
puts "== your ami is ready"
|
10
|
+
end
|
11
|
+
# Cleanup the /mnt directory
|
12
|
+
desc "Clean the /mnt directory"
|
13
|
+
task :clean_mnt do
|
14
|
+
`rm -rf /mnt/image* img*`
|
15
|
+
end
|
16
|
+
# Before we can bundle, we have to make sure we have the cert and pk files
|
17
|
+
desc "Ensure the required bundle files are present in /mnt"
|
18
|
+
task :check_bundle_files do
|
19
|
+
raise Exception.new("You must have a private key in your /mnt directory") unless File.exists?("/mnt/pk-*.pem")
|
20
|
+
raise Exception.new("You must have your access key in your /mnt directory") unless File.exists?("/mnt/cert-*.pem")
|
21
|
+
end
|
22
|
+
# Bundle the image
|
23
|
+
desc "Bundle this image into the /mnt directory"
|
24
|
+
task :bundle => [:clean_mnt, :check_bundle_files] do
|
25
|
+
puts `ec2-bundle-vol -k /mnt/pk-*.pem -u '#{Planner.user_id}' -d /mnt -c /mnt/cert-*.pem -r i386`
|
26
|
+
end
|
27
|
+
# Upload the bundle into the app_name bucket
|
28
|
+
desc "Upload the bundle to your bucket with a unique name: deletes old ami"
|
29
|
+
task :upload => [:init, :delete_bucket] do
|
30
|
+
puts `ec2-upload-bundle -b #{Planner.app_name} -m /mnt/image.manifest.xml -a #{Planner.access_key} -s #{Planner.secret_access_key}`
|
31
|
+
end
|
32
|
+
# Register the bucket with amazon and get back an ami
|
33
|
+
desc "Register the bundle with amazon"
|
34
|
+
task :register do
|
35
|
+
puts `ec2-register -K /mnt/pk-*.pem -C /mnt/cert-*.pem #{Planner.app_name}/image.manifest.xml`
|
36
|
+
end
|
37
|
+
# Delete the bucket
|
38
|
+
desc "Delete the bucket with the bundle under tha app name"
|
39
|
+
task :delete_bucket do
|
40
|
+
Planner.app_name.delete_bucket
|
41
|
+
end
|
42
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
7
|
+
t.warning =
|
8
|
+
t.rcov = false
|
9
|
+
t.spec_files = Dir["spec/**/*_spec.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
Spec::Rake::SpecTask.new(:spec_v) do |t|
|
13
|
+
t.rcov = true
|
14
|
+
t.rcov_opts = ['--exclude', 'gems*,spec*']
|
15
|
+
t.ruby_opts = []
|
16
|
+
t.spec_files = Dir["spec/**/*_spec.rb"]
|
17
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
@@ -0,0 +1,29 @@
|
|
1
|
+
begin
|
2
|
+
require File.dirname(__FILE__) + '/test_helper'
|
3
|
+
rescue LoadError
|
4
|
+
require 'test/unit'
|
5
|
+
end
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
# Must set before requiring generator libs.
|
9
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
10
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
11
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
12
|
+
if defined?(APP_ROOT)
|
13
|
+
APP_ROOT.replace(app_root)
|
14
|
+
else
|
15
|
+
APP_ROOT = app_root
|
16
|
+
end
|
17
|
+
if defined?(RAILS_ROOT)
|
18
|
+
RAILS_ROOT.replace(app_root)
|
19
|
+
else
|
20
|
+
RAILS_ROOT = app_root
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'rubigen'
|
25
|
+
rescue LoadError
|
26
|
+
require 'rubygems'
|
27
|
+
require 'rubigen'
|
28
|
+
end
|
29
|
+
require 'rubigen/helpers/generator_test_helper'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
class TestPoolspecGenerator < Test::Unit::TestCase
|
4
|
+
include RubiGen::GeneratorTestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
bare_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
bare_teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
# Some generator-related assertions:
|
15
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
16
|
+
# assert_directory_exists(name)
|
17
|
+
# assert_generated_class(name, &block)
|
18
|
+
# assert_generated_module(name, &block)
|
19
|
+
# assert_generated_test_for(name, &block)
|
20
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
21
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
22
|
+
#
|
23
|
+
# Other helper methods are:
|
24
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
25
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
26
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
27
|
+
|
28
|
+
def test_generator_without_options
|
29
|
+
run_generator('poolspec', [APP_ROOT], sources)
|
30
|
+
assert_directory_exists "config"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_generated_templated_file
|
34
|
+
run_generator('poolspec', [APP_ROOT], sources)
|
35
|
+
assert_generated_file "poolspec.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def sources
|
40
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
def generator_path
|
45
|
+
"generators"
|
46
|
+
end
|
47
|
+
end
|
data/test_manifest.pp
ADDED
@@ -0,0 +1,538 @@
|
|
1
|
+
|
2
|
+
# conditional
|
3
|
+
|
4
|
+
# $hostname == master
|
5
|
+
case $hostname {
|
6
|
+
master : {
|
7
|
+
# Variables
|
8
|
+
|
9
|
+
$ha_nodenames = [ 'master', 'node1' ]
|
10
|
+
$ha_node_ips = [ '192.168.0.1', '192.168.0.1' ]
|
11
|
+
$ha_port = '80'
|
12
|
+
|
13
|
+
# remotefile
|
14
|
+
|
15
|
+
|
16
|
+
file {
|
17
|
+
"/etc/ha.d/ha.cf":
|
18
|
+
content => template("ha.cf"),
|
19
|
+
require => Package["heartbeat-2"],
|
20
|
+
mode => 444,
|
21
|
+
ensure => 'present',
|
22
|
+
owner => 'root',
|
23
|
+
notify => Service["heartbeat"]
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
file {
|
28
|
+
"/etc/ha.d/authkeys":
|
29
|
+
content => template("authkeys"),
|
30
|
+
require => Package["heartbeat-2"],
|
31
|
+
mode => 400,
|
32
|
+
ensure => 'present',
|
33
|
+
owner => 'root',
|
34
|
+
notify => Service["heartbeat"]
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
file {
|
39
|
+
"/etc/ha.d/cib.xml":
|
40
|
+
content => template("cib.xml"),
|
41
|
+
require => Package["heartbeat-2"],
|
42
|
+
mode => 444,
|
43
|
+
ensure => 'present',
|
44
|
+
owner => 'root',
|
45
|
+
notify => Exec["heartbeat-update-cib"]
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
# service
|
50
|
+
|
51
|
+
|
52
|
+
service {
|
53
|
+
"heartbeat":
|
54
|
+
hasstatus => true,
|
55
|
+
enable => true,
|
56
|
+
ensure => 'running',
|
57
|
+
name => 'heartbeat'
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
# exec
|
62
|
+
|
63
|
+
|
64
|
+
exec {
|
65
|
+
"heartbeat-update-cib":
|
66
|
+
refreshonly => true,
|
67
|
+
path => '/usr/bin:/bin:/usr/local/bin:$PATH',
|
68
|
+
command => '/usr/sbin/cibadmin -R -x /etc/ha.d/cib.xml'
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
# package
|
73
|
+
|
74
|
+
|
75
|
+
package {
|
76
|
+
"heartbeat-2":
|
77
|
+
ensure => 'installed',
|
78
|
+
name => 'heartbeat-2'
|
79
|
+
}
|
80
|
+
}
|
81
|
+
default : {}
|
82
|
+
}
|
83
|
+
# $hostname == master
|
84
|
+
case $hostname {
|
85
|
+
master : {
|
86
|
+
# Variables
|
87
|
+
|
88
|
+
$name_haproxy = 'test'
|
89
|
+
$nodenames_haproxy = [ 'master', 'node1' ]
|
90
|
+
$node_ips_haproxy = [ '192.168.0.1', '192.168.0.1' ]
|
91
|
+
$ports_haproxy = [ '80' ]
|
92
|
+
$forwarding_port = '8080'
|
93
|
+
$proxy_mode = 'http'
|
94
|
+
|
95
|
+
# remotefile
|
96
|
+
|
97
|
+
|
98
|
+
file {
|
99
|
+
"/etc/haproxy.cfg":
|
100
|
+
content => template("haproxy.conf"),
|
101
|
+
require => Package["haproxy"],
|
102
|
+
mode => 644,
|
103
|
+
ensure => 'present',
|
104
|
+
owner => 'root',
|
105
|
+
notify => Service["haproxy"]
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
# service
|
110
|
+
|
111
|
+
|
112
|
+
service {
|
113
|
+
"sysklogd":
|
114
|
+
enable => true,
|
115
|
+
ensure => 'running',
|
116
|
+
name => 'sysklogd'
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
service {
|
121
|
+
"haproxy":
|
122
|
+
enable => true,
|
123
|
+
ensure => 'running',
|
124
|
+
name => 'haproxy'
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
# package
|
129
|
+
|
130
|
+
|
131
|
+
package {
|
132
|
+
"haproxy":
|
133
|
+
ensure => 'installed',
|
134
|
+
name => 'haproxy'
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
# call_function
|
139
|
+
|
140
|
+
line {
|
141
|
+
'/etc/default/haproxy_line' :
|
142
|
+
file => '/etc/default/haproxy',
|
143
|
+
line => 'ENABLED=1',
|
144
|
+
|
145
|
+
ensure => 'present'
|
146
|
+
}
|
147
|
+
|
148
|
+
line {
|
149
|
+
'/etc/default/syslogd_line' :
|
150
|
+
file => '/etc/default/syslogd',
|
151
|
+
line => 'SYSLOGD="-r"',
|
152
|
+
|
153
|
+
ensure => 'present'
|
154
|
+
}
|
155
|
+
|
156
|
+
line {
|
157
|
+
'/etc/syslog.conf_line' :
|
158
|
+
file => '/etc/syslog.conf',
|
159
|
+
line => 'local0.* /var/log/haproxy.log',
|
160
|
+
notify => Service["sysklogd"],
|
161
|
+
ensure => 'present'
|
162
|
+
}
|
163
|
+
}
|
164
|
+
default : {}
|
165
|
+
}
|
166
|
+
# heartbeat
|
167
|
+
class heartbeat {
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
include heartbeat
|
172
|
+
# haproxy
|
173
|
+
class haproxy {
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
include haproxy
|
178
|
+
# ruby
|
179
|
+
class ruby {
|
180
|
+
|
181
|
+
# package
|
182
|
+
|
183
|
+
|
184
|
+
package {
|
185
|
+
"libreadline-ruby1.8":
|
186
|
+
ensure => 'present',
|
187
|
+
name => 'libreadline-ruby1.8'
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
package {
|
192
|
+
"libruby1.8":
|
193
|
+
ensure => 'present',
|
194
|
+
name => 'libruby1.8'
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
package {
|
199
|
+
"ruby1.8-dev":
|
200
|
+
ensure => 'present',
|
201
|
+
name => 'ruby1.8-dev'
|
202
|
+
}
|
203
|
+
|
204
|
+
|
205
|
+
package {
|
206
|
+
"ruby1.8":
|
207
|
+
ensure => 'present',
|
208
|
+
name => 'ruby1.8'
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
package {
|
213
|
+
"rubygems":
|
214
|
+
ensure => 'present',
|
215
|
+
name => 'rubygems'
|
216
|
+
}
|
217
|
+
|
218
|
+
|
219
|
+
# call_function
|
220
|
+
|
221
|
+
line {
|
222
|
+
'/etc/profile_line' :
|
223
|
+
file => '/etc/profile',
|
224
|
+
line => 'export PATH=$PATH:/var/lib/gems/1.8/bin/',
|
225
|
+
|
226
|
+
ensure => 'present'
|
227
|
+
}
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
include ruby
|
232
|
+
# poolparty
|
233
|
+
class poolparty {
|
234
|
+
|
235
|
+
# host
|
236
|
+
|
237
|
+
|
238
|
+
host {
|
239
|
+
"master":
|
240
|
+
ip => '192.168.0.1',
|
241
|
+
ensure => 'present',
|
242
|
+
name => 'master'
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
host {
|
247
|
+
"node1":
|
248
|
+
ip => '192.168.0.1',
|
249
|
+
ensure => 'present',
|
250
|
+
name => 'node1'
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
# cron
|
255
|
+
|
256
|
+
|
257
|
+
cron {
|
258
|
+
"poolparty":
|
259
|
+
minute => '*/5',
|
260
|
+
command => 'cloud-maintain',
|
261
|
+
user => 'puppet'
|
262
|
+
}
|
263
|
+
|
264
|
+
|
265
|
+
# package
|
266
|
+
|
267
|
+
|
268
|
+
package {
|
269
|
+
"erlang":
|
270
|
+
ensure => 'present',
|
271
|
+
name => 'erlang'
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
# gempackage
|
276
|
+
|
277
|
+
|
278
|
+
# open4
|
279
|
+
class open4 {
|
280
|
+
|
281
|
+
# exec
|
282
|
+
|
283
|
+
|
284
|
+
exec {
|
285
|
+
"gem-package-open4":
|
286
|
+
unless => 'gem list --local open4 | grep open4 ',
|
287
|
+
require => Package['rubygems'],
|
288
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
289
|
+
command => 'gem install -y --no-ri --no-rdoc open4',
|
290
|
+
cwd => '/tmp'
|
291
|
+
}
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
include open4
|
296
|
+
|
297
|
+
|
298
|
+
# parsetree
|
299
|
+
class parsetree {
|
300
|
+
|
301
|
+
# exec
|
302
|
+
|
303
|
+
|
304
|
+
exec {
|
305
|
+
"gem-package-parsetree":
|
306
|
+
unless => 'gem list --local parsetree | grep parsetree ',
|
307
|
+
require => Package['rubygems'],
|
308
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
309
|
+
command => 'gem install -y --no-ri --no-rdoc parsetree',
|
310
|
+
cwd => '/tmp'
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
include parsetree
|
316
|
+
|
317
|
+
|
318
|
+
# rubyinline
|
319
|
+
class rubyinline {
|
320
|
+
|
321
|
+
# exec
|
322
|
+
|
323
|
+
|
324
|
+
exec {
|
325
|
+
"gem-package-rubyinline":
|
326
|
+
unless => 'gem list --local rubyinline | grep rubyinline ',
|
327
|
+
require => Package['rubygems'],
|
328
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
329
|
+
command => 'gem install -y --no-ri --no-rdoc rubyinline',
|
330
|
+
cwd => '/tmp'
|
331
|
+
}
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
include rubyinline
|
336
|
+
|
337
|
+
|
338
|
+
# activesupport
|
339
|
+
class activesupport {
|
340
|
+
|
341
|
+
# exec
|
342
|
+
|
343
|
+
|
344
|
+
exec {
|
345
|
+
"gem-package-activesupport":
|
346
|
+
unless => 'gem list --local activesupport | grep activesupport ',
|
347
|
+
require => Package['rubygems'],
|
348
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
349
|
+
command => 'gem install -y --no-ri --no-rdoc activesupport',
|
350
|
+
cwd => '/tmp'
|
351
|
+
}
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
include activesupport
|
356
|
+
|
357
|
+
|
358
|
+
# logging
|
359
|
+
class logging {
|
360
|
+
|
361
|
+
# exec
|
362
|
+
|
363
|
+
|
364
|
+
exec {
|
365
|
+
"gem-package-logging":
|
366
|
+
unless => 'gem list --local logging | grep logging ',
|
367
|
+
require => Package['rubygems'],
|
368
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
369
|
+
command => 'gem install -y --no-ri --no-rdoc logging',
|
370
|
+
cwd => '/tmp'
|
371
|
+
}
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
include logging
|
376
|
+
|
377
|
+
|
378
|
+
# hoe
|
379
|
+
class hoe {
|
380
|
+
|
381
|
+
# exec
|
382
|
+
|
383
|
+
|
384
|
+
exec {
|
385
|
+
"gem-package-hoe":
|
386
|
+
unless => 'gem list --local hoe | grep hoe ',
|
387
|
+
require => Package['rubygems'],
|
388
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
389
|
+
command => 'gem install -y --no-ri --no-rdoc hoe',
|
390
|
+
cwd => '/tmp'
|
391
|
+
}
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
include hoe
|
396
|
+
|
397
|
+
|
398
|
+
# xml-simple
|
399
|
+
class xml-simple {
|
400
|
+
|
401
|
+
# exec
|
402
|
+
|
403
|
+
|
404
|
+
exec {
|
405
|
+
"gem-package-xml-simple":
|
406
|
+
unless => 'gem list --local xml-simple | grep xml-simple ',
|
407
|
+
require => Package['rubygems'],
|
408
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
409
|
+
command => 'gem install -y --no-ri --no-rdoc xml-simple',
|
410
|
+
cwd => '/tmp'
|
411
|
+
}
|
412
|
+
|
413
|
+
}
|
414
|
+
|
415
|
+
include xml-simple
|
416
|
+
|
417
|
+
|
418
|
+
# ruby2ruby
|
419
|
+
class ruby2ruby {
|
420
|
+
|
421
|
+
# exec
|
422
|
+
|
423
|
+
|
424
|
+
exec {
|
425
|
+
"gem-package-ruby2ruby":
|
426
|
+
unless => 'gem list --local ruby2ruby | grep ruby2ruby ',
|
427
|
+
require => Package['rubygems'],
|
428
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
429
|
+
command => 'gem install -y --no-ri --no-rdoc ruby2ruby',
|
430
|
+
cwd => '/tmp'
|
431
|
+
}
|
432
|
+
|
433
|
+
}
|
434
|
+
|
435
|
+
include ruby2ruby
|
436
|
+
|
437
|
+
|
438
|
+
# grempe-amazon-ec2
|
439
|
+
class grempe-amazon-ec2 {
|
440
|
+
|
441
|
+
# exec
|
442
|
+
|
443
|
+
|
444
|
+
exec {
|
445
|
+
"gem-package-grempe-amazon-ec2":
|
446
|
+
unless => 'gem list --local grempe-amazon-ec2 | grep grempe-amazon-ec2 ',
|
447
|
+
require => Package['rubygems'],
|
448
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
449
|
+
command => 'gem install -y --no-ri --no-rdoc --source http://gems.github.com grempe-amazon-ec2',
|
450
|
+
cwd => '/tmp'
|
451
|
+
}
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
include grempe-amazon-ec2
|
456
|
+
|
457
|
+
|
458
|
+
# auser-poolparty
|
459
|
+
class auser-poolparty {
|
460
|
+
|
461
|
+
# exec
|
462
|
+
|
463
|
+
|
464
|
+
exec {
|
465
|
+
"gem-package-auser-poolparty":
|
466
|
+
unless => 'gem list --local auser-poolparty | grep auser-poolparty ',
|
467
|
+
require => Package['rubygems'],
|
468
|
+
path => '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin',
|
469
|
+
command => 'gem install -y --no-ri --no-rdoc --source http://gems.github.com auser-poolparty',
|
470
|
+
cwd => '/tmp'
|
471
|
+
}
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
include auser-poolparty
|
476
|
+
|
477
|
+
}
|
478
|
+
|
479
|
+
include poolparty
|
480
|
+
# Custom functions
|
481
|
+
define line($file, $line, $ensure = 'present', $notify=[]) {
|
482
|
+
case $ensure {
|
483
|
+
default: { err ( "unknown ensure value ${ensure}" ) }
|
484
|
+
present: {
|
485
|
+
exec {
|
486
|
+
"/usr/bin/env echo '${line}' >> '${file}'": unless => "/usr/bin/env grep -qFx '${line}' '${file}'",
|
487
|
+
notify => $notify
|
488
|
+
}
|
489
|
+
}
|
490
|
+
absent: {
|
491
|
+
exec {
|
492
|
+
"/usr/bin/env sed -i '' -e '/^${line}$/d' '${file}'": onlyif => "/usr/bin/env grep -qFx '${line}' '${file}'",
|
493
|
+
notify => $notify
|
494
|
+
}
|
495
|
+
}
|
496
|
+
}
|
497
|
+
}
|
498
|
+
define append_if_no_such_line($file, $line, $refreshonly = 'false') {
|
499
|
+
exec { "/bin/echo '$line' >> '$file'":
|
500
|
+
unless => "/bin/grep -Fxqe '$line' '$file'",
|
501
|
+
path => "/bin",
|
502
|
+
refreshonly => $refreshonly,
|
503
|
+
}
|
504
|
+
}
|
505
|
+
|
506
|
+
define delete_lines($file, $pattern) {
|
507
|
+
exec { "sed -i -r -e '/$pattern/d' $file":
|
508
|
+
path => "/bin",
|
509
|
+
onlyif => "/bin/grep -E '$pattern' '$file'",
|
510
|
+
}
|
511
|
+
}
|
512
|
+
|
513
|
+
# Serve subversion-based code from a local location. The job of this
|
514
|
+
# module is to check the data out from subversion and keep it up to
|
515
|
+
# date, especially useful for providing data to your Puppet server.
|
516
|
+
define svnserve($source, $path, $user = false, $password = false) {
|
517
|
+
file { $path:
|
518
|
+
ensure => directory,
|
519
|
+
owner => root,
|
520
|
+
group => root
|
521
|
+
}
|
522
|
+
$svncmd = $user ? {
|
523
|
+
false => "/usr/bin/svn co --non-interactive $source/$name .",
|
524
|
+
default => "/usr/bin/svn co --non-interactive --username $user --password '$password' $source/$name ."
|
525
|
+
}
|
526
|
+
exec { "svnco-$name":
|
527
|
+
command => $svncmd,
|
528
|
+
cwd => $path,
|
529
|
+
require => File[$path],
|
530
|
+
creates => "$path/.svn"
|
531
|
+
}
|
532
|
+
exec { "svnupdate-$name":
|
533
|
+
command => "/usr/bin/svn update",
|
534
|
+
require => Exec["svnco-$name"],
|
535
|
+
onlyif => '/usr/bin/svn status -u --non-interactive | /bin/grep "*"',
|
536
|
+
cwd => $path
|
537
|
+
}
|
538
|
+
}
|