auser-poolparty 0.1.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +22 -0
- data/License.txt +20 -0
- data/README.txt +52 -0
- data/Rakefile +4 -109
- data/bin/cloud +31 -0
- data/bin/cloud-add-keypair +23 -0
- data/bin/cloud-configure +35 -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-provision +30 -0
- data/bin/cloud-reconfigure +24 -0
- data/bin/cloud-ssh +18 -0
- data/bin/cloud-start +29 -0
- data/bin/pool +23 -75
- 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/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 +40 -116
- data/lib/poolparty/base_packages/haproxy.rb +41 -0
- data/lib/poolparty/base_packages/heartbeat.rb +43 -0
- data/lib/poolparty/base_packages/poolparty.rb +18 -0
- data/lib/poolparty/base_packages/ruby.rb +27 -0
- data/lib/poolparty/core/array.rb +24 -0
- data/lib/{core → poolparty/core}/exception.rb +0 -0
- data/lib/{core → poolparty/core}/float.rb +0 -0
- data/lib/poolparty/core/hash.rb +29 -0
- data/lib/poolparty/core/kernel.rb +34 -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 +2 -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 +30 -0
- data/lib/poolparty/helpers/console.rb +30 -0
- data/lib/poolparty/helpers/display.rb +25 -0
- data/lib/poolparty/helpers/optioner.rb +61 -0
- data/lib/poolparty/helpers/provisioner_base.rb +226 -0
- data/lib/poolparty/helpers/provisioners/master.rb +120 -0
- data/lib/poolparty/helpers/provisioners/slave.rb +52 -0
- data/lib/poolparty/modules/cloud_resourcer.rb +72 -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 +17 -0
- data/lib/poolparty/modules/output.rb +13 -0
- data/lib/poolparty/modules/pretty_printer.rb +38 -0
- data/lib/{core/string.rb → poolparty/modules/s3_string.rb} +5 -29
- 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 +145 -0
- data/lib/poolparty/net/remote_instance.rb +68 -0
- data/lib/poolparty/net/remoter.rb +209 -0
- data/lib/poolparty/net/remoter_base.rb +117 -0
- data/lib/poolparty/plugins/gem_package.rb +39 -0
- data/lib/poolparty/plugins/line.rb +76 -0
- data/lib/poolparty/plugins/svn.rb +48 -0
- data/lib/poolparty/pool/base.rb +74 -0
- data/lib/poolparty/pool/cloud.rb +132 -0
- data/lib/poolparty/pool/custom_resource.rb +61 -0
- data/lib/poolparty/pool/loggable.rb +29 -0
- data/lib/poolparty/pool/plugin.rb +42 -0
- data/lib/poolparty/pool/plugin_model.rb +48 -0
- data/lib/poolparty/pool/pool.rb +55 -0
- data/lib/poolparty/pool/resource.rb +235 -0
- data/lib/poolparty/pool/resources/class_package.rb +60 -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 +20 -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 +21 -0
- data/{config/heartbeat_authkeys.conf → lib/poolparty/templates/authkeys} +0 -0
- data/lib/poolparty/templates/cib.xml +1 -0
- data/lib/poolparty/templates/fileserver.conf +4 -0
- data/{config/heartbeat.conf → lib/poolparty/templates/ha.cf} +3 -1
- data/{config → lib/poolparty/templates}/haproxy.conf +13 -6
- data/lib/poolparty/templates/namespaceauth.conf +19 -0
- data/lib/poolparty/templates/puppet.conf +13 -0
- data/lib/poolparty/version.rb +9 -0
- data/lib/poolpartycl.rb +3 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/{lib/poolparty/tasks → tasks}/cloud.rake +1 -1
- data/tasks/deployment.rake +34 -0
- data/tasks/development.rake +78 -0
- data/{lib/poolparty/tasks → tasks}/ec2.rake +1 -1
- data/tasks/environment.rake +7 -0
- data/{lib/poolparty/tasks → tasks}/instance.rake +0 -0
- data/{lib/poolparty/tasks → tasks}/server.rake +0 -0
- data/tasks/spec.rake +17 -0
- data/tasks/website.rake +17 -0
- metadata +154 -249
- data/CHANGELOG +0 -23
- data/LICENSE +0 -22
- data/README +0 -139
- data/assets/clouds.png +0 -0
- data/bin/instance +0 -68
- data/bin/poolnotify +0 -34
- data/config/cloud_master_takeover +0 -17
- data/config/create_proxy_ami.sh +0 -582
- data/config/installers/ubuntu_install.sh +0 -77
- data/config/monit.conf +0 -9
- data/config/monit/haproxy.monit.conf +0 -8
- data/config/monit/nginx.monit.conf +0 -0
- data/config/nginx.conf +0 -24
- data/config/reconfigure_instances_script.sh +0 -37
- data/config/sample-config.yml +0 -23
- data/config/scp_instances_script.sh +0 -12
- data/lib/core/array.rb +0 -16
- data/lib/core/hash.rb +0 -11
- data/lib/core/kernel.rb +0 -12
- data/lib/core/object.rb +0 -21
- data/lib/core/proc.rb +0 -15
- data/lib/helpers/plugin_spec_helper.rb +0 -58
- data/lib/modules/callback.rb +0 -133
- data/lib/modules/ec2_wrapper.rb +0 -108
- data/lib/modules/file_writer.rb +0 -38
- data/lib/modules/sprinkle_overrides.rb +0 -27
- data/lib/modules/vlad_override.rb +0 -83
- data/lib/poolparty/application.rb +0 -199
- data/lib/poolparty/init.rb +0 -6
- data/lib/poolparty/master.rb +0 -492
- data/lib/poolparty/monitors.rb +0 -11
- data/lib/poolparty/monitors/cpu.rb +0 -23
- data/lib/poolparty/monitors/memory.rb +0 -33
- data/lib/poolparty/monitors/web.rb +0 -29
- data/lib/poolparty/optioner.rb +0 -20
- data/lib/poolparty/plugin.rb +0 -78
- data/lib/poolparty/provider.rb +0 -104
- data/lib/poolparty/provider/essential.rb +0 -6
- data/lib/poolparty/provider/git.rb +0 -8
- data/lib/poolparty/provider/haproxy.rb +0 -9
- data/lib/poolparty/provider/heartbeat.rb +0 -6
- data/lib/poolparty/provider/rsync.rb +0 -8
- data/lib/poolparty/provider/ruby.rb +0 -65
- data/lib/poolparty/provider/s3fuse.rb +0 -22
- data/lib/poolparty/remote_instance.rb +0 -250
- data/lib/poolparty/remoter.rb +0 -171
- data/lib/poolparty/remoting.rb +0 -137
- data/lib/poolparty/scheduler.rb +0 -93
- data/lib/poolparty/tasks.rb +0 -47
- data/lib/poolparty/tasks/development.rake +0 -78
- data/lib/poolparty/tasks/plugins.rake +0 -30
- data/lib/poolparty/thread_pool.rb +0 -94
- data/lib/s3/s3_object_store_folders.rb +0 -44
- data/poolparty.gemspec +0 -71
- data/spec/files/describe_response +0 -37
- data/spec/files/multi_describe_response +0 -69
- data/spec/files/remote_desc_response +0 -37
- data/spec/helpers/ec2_mock.rb +0 -57
- data/spec/lib/core/core_spec.rb +0 -26
- data/spec/lib/core/kernel_spec.rb +0 -24
- data/spec/lib/core/string_spec.rb +0 -28
- data/spec/lib/modules/callback_spec.rb +0 -213
- data/spec/lib/modules/file_writer_spec.rb +0 -74
- data/spec/lib/poolparty/application_spec.rb +0 -135
- data/spec/lib/poolparty/ec2_wrapper_spec.rb +0 -110
- data/spec/lib/poolparty/master_spec.rb +0 -479
- data/spec/lib/poolparty/optioner_spec.rb +0 -34
- data/spec/lib/poolparty/plugin_spec.rb +0 -115
- data/spec/lib/poolparty/poolparty_spec.rb +0 -60
- data/spec/lib/poolparty/provider_spec.rb +0 -74
- data/spec/lib/poolparty/remote_instance_spec.rb +0 -178
- data/spec/lib/poolparty/remoter_spec.rb +0 -72
- data/spec/lib/poolparty/remoting_spec.rb +0 -148
- data/spec/lib/poolparty/scheduler_spec.rb +0 -70
- data/spec/monitors/cpu_monitor_spec.rb +0 -39
- data/spec/monitors/memory_spec.rb +0 -51
- data/spec/monitors/misc_monitor_spec.rb +0 -51
- data/spec/monitors/web_spec.rb +0 -40
- data/spec/spec_helper.rb +0 -53
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
module PoolParty
|
|
2
|
+
|
|
3
|
+
def register_remote_base(*args)
|
|
4
|
+
args.each do |arg|
|
|
5
|
+
(remote_bases << "#{arg}".downcase.to_sym)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def remote_bases
|
|
10
|
+
$remote_bases ||= []
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module Remote
|
|
14
|
+
# This class is the base class for all remote types
|
|
15
|
+
# Everything remoting-wise is derived from this class
|
|
16
|
+
module RemoterBaseMethods
|
|
17
|
+
# Required methods
|
|
18
|
+
# The next methods are required on all RemoteInstance types
|
|
19
|
+
# If your RemoteInstance type does not overwrite the following methods
|
|
20
|
+
# An exception will be raised and poolparty will explode into tiny little
|
|
21
|
+
# pieces. Don't forget to overwrite these methods
|
|
22
|
+
# Launch a new instance
|
|
23
|
+
def launch_new_instance!
|
|
24
|
+
raise RemoteException.new(:method_not_defined, "launch_new_instance!")
|
|
25
|
+
end
|
|
26
|
+
# Terminate an instance by id
|
|
27
|
+
def terminate_instance!(id=nil)
|
|
28
|
+
raise RemoteException.new(:method_not_defined, "terminate_instance!")
|
|
29
|
+
end
|
|
30
|
+
# Describe an instance's status
|
|
31
|
+
def describe_instance(id=nil)
|
|
32
|
+
raise RemoteException.new(:method_not_defined, "describe_instance")
|
|
33
|
+
end
|
|
34
|
+
# Get instances
|
|
35
|
+
# The instances must have a status associated with them on the hash
|
|
36
|
+
def describe_instances
|
|
37
|
+
raise RemoteException.new(:method_not_defined, "describe_instances")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
module RemoterBase
|
|
42
|
+
# The following methods are inherent on the RemoterBase
|
|
43
|
+
# If you need to overwrite these methods, do so with caution
|
|
44
|
+
# Listing methods
|
|
45
|
+
def list_of_running_instances(list = list_of_nonterminated_instances)
|
|
46
|
+
list.select {|a| a.running? }
|
|
47
|
+
end
|
|
48
|
+
# Get a list of the pending instances
|
|
49
|
+
def list_of_pending_instances(list = list_of_nonterminated_instances)
|
|
50
|
+
list.select {|a| a.pending? }
|
|
51
|
+
end
|
|
52
|
+
# list of shutting down instances
|
|
53
|
+
def list_of_terminating_instances(list = remote_instances_list)
|
|
54
|
+
list.reject {|i| true if !i.terminating? }
|
|
55
|
+
end
|
|
56
|
+
# Get the instances that are non-master instances
|
|
57
|
+
def nonmaster_nonterminated_instances(list = remote_instances_list)
|
|
58
|
+
list_of_nonterminated_instances.reject {|i| i.master? }
|
|
59
|
+
end
|
|
60
|
+
# list all the nonterminated instances
|
|
61
|
+
def list_of_nonterminated_instances(list = remote_instances_list)
|
|
62
|
+
list.reject {|i| i.terminating? || i.terminated? }
|
|
63
|
+
end
|
|
64
|
+
# Get instance by number
|
|
65
|
+
def get_instance_by_number(i=0, list = remote_instances_list)
|
|
66
|
+
name = (i.zero? ? "master" : "node#{i}")
|
|
67
|
+
list.select {|i| i.name == name }.first
|
|
68
|
+
end
|
|
69
|
+
def remote_instances_list
|
|
70
|
+
list_of_instances.map {|i| PoolParty::Remote::RemoteInstance.new(i, self) }
|
|
71
|
+
end
|
|
72
|
+
# List the instances for the current key pair, regardless of their states
|
|
73
|
+
# If no keypair is passed, select them all
|
|
74
|
+
def list_of_instances(keyp=nil)
|
|
75
|
+
key = keyp ? keyp : keypair
|
|
76
|
+
describe_instances.select {|a| key ? a[:keypair] == key : true }
|
|
77
|
+
end
|
|
78
|
+
# Instances
|
|
79
|
+
# Get the master from the cloud
|
|
80
|
+
def master
|
|
81
|
+
# remote_instances_list.select {|a| a.master }.first
|
|
82
|
+
@list = list_from_remote
|
|
83
|
+
@list.reject {|a| a unless a.name =~ /master/ }.first if @list.class != String
|
|
84
|
+
end
|
|
85
|
+
# Helpers
|
|
86
|
+
def create_keypair
|
|
87
|
+
end
|
|
88
|
+
# Reset the cache of descriptions
|
|
89
|
+
def reset!
|
|
90
|
+
end
|
|
91
|
+
def self.included(other)
|
|
92
|
+
PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Callback after loaded
|
|
96
|
+
def loaded_remoter_base
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Custom installation tasks
|
|
100
|
+
# Allow the remoter bases to attach their own tasks on the
|
|
101
|
+
# installation process
|
|
102
|
+
def custom_install_tasks_for(a=nil)
|
|
103
|
+
[]
|
|
104
|
+
end
|
|
105
|
+
# Custom configure tasks
|
|
106
|
+
# Allows the remoter bases to attach their own
|
|
107
|
+
# custom configuration tasks to the configuration process
|
|
108
|
+
def custom_configure_tasks_for(a=nil)
|
|
109
|
+
[]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
Dir["#{File.dirname(__FILE__)}/remote_bases/*.rb"].each {|base| require base }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module PoolParty
|
|
2
|
+
class Gem
|
|
3
|
+
|
|
4
|
+
define_resource(:gem_package) do
|
|
5
|
+
|
|
6
|
+
def has_gem_package(opts={})
|
|
7
|
+
call_function <<-EOE
|
|
8
|
+
gem_package { "#{opts[:package] || opts[:name]}":
|
|
9
|
+
source => "#{opts[:source] || "http://gems.github.com" }",
|
|
10
|
+
package => "#{opts[:package] || opts[:name]}"
|
|
11
|
+
}
|
|
12
|
+
EOE
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
custom_function <<-EOF
|
|
16
|
+
define gem_package ($source = "http://gems", $version, $package=false) {
|
|
17
|
+
include ruby
|
|
18
|
+
|
|
19
|
+
if $version {
|
|
20
|
+
exec { "gem-package-$package":
|
|
21
|
+
path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin",
|
|
22
|
+
cwd => "/tmp",
|
|
23
|
+
command => "gem install --source $source --version \"$version\" $package",
|
|
24
|
+
unless => "gem list --local $package | grep \"$package\" | grep \"$version\""
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
exec { "gem-package-$package":
|
|
28
|
+
path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin",
|
|
29
|
+
cwd => "/tmp",
|
|
30
|
+
command => "gem install --source $source $package",
|
|
31
|
+
unless => "gem list --local $package | grep \"$package\"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
EOF
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module PoolParty
|
|
2
|
+
class Line
|
|
3
|
+
|
|
4
|
+
define_resource(:line_in_file) do
|
|
5
|
+
# Should refactor
|
|
6
|
+
def has_line_in_file(line="line_in_file", file="file", opts={})
|
|
7
|
+
call_function <<-EOE
|
|
8
|
+
line {
|
|
9
|
+
'#{file}_line' :
|
|
10
|
+
file => '#{file}',
|
|
11
|
+
line => '#{line}',
|
|
12
|
+
#{opts.flush_out("\t", ",")}
|
|
13
|
+
ensure => 'present'
|
|
14
|
+
}
|
|
15
|
+
EOE
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def append_if_no_such_line(line="line", file="", refreshonly='false')
|
|
19
|
+
call_function <<-EOE
|
|
20
|
+
append_if_no_such_line {
|
|
21
|
+
'#{file}' :
|
|
22
|
+
file => '#{file}',
|
|
23
|
+
line => '#{line}',
|
|
24
|
+
refreshonly => #{refreshonly}
|
|
25
|
+
}
|
|
26
|
+
EOE
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def delete_lines_from(file="", pattern=//)
|
|
30
|
+
call_function <<-EOE
|
|
31
|
+
delete_lines {
|
|
32
|
+
'#{file}' :
|
|
33
|
+
file => '#{file}',
|
|
34
|
+
pattern => '#{pattern}'
|
|
35
|
+
}
|
|
36
|
+
EOE
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
custom_function <<-EOF
|
|
41
|
+
define line($file, $line, $ensure = 'present', $notify=[]) {
|
|
42
|
+
case $ensure {
|
|
43
|
+
default: { err ( "unknown ensure value ${ensure}" ) }
|
|
44
|
+
present: {
|
|
45
|
+
exec {
|
|
46
|
+
"/usr/bin/env echo '${line}' >> '${file}'": unless => "/usr/bin/env grep -qFx '${line}' '${file}'",
|
|
47
|
+
notify => $notify
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
absent: {
|
|
51
|
+
exec {
|
|
52
|
+
"/usr/bin/env sed -i '' -e '/^${line}\$/d' '${file}'": onlyif => "/usr/bin/env grep -qFx '${line}' '${file}'",
|
|
53
|
+
notify => $notify
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
define append_if_no_such_line($file, $line, $refreshonly = 'false') {
|
|
59
|
+
exec { "/bin/echo '$line' >> '$file'":
|
|
60
|
+
unless => "/bin/grep -Fxqe '$line' '$file'",
|
|
61
|
+
path => "/bin",
|
|
62
|
+
refreshonly => $refreshonly,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
define delete_lines($file, $pattern) {
|
|
67
|
+
exec { "sed -i -r -e '/$pattern/d' $file":
|
|
68
|
+
path => "/bin",
|
|
69
|
+
onlyif => "/bin/grep -E '$pattern' '$file'",
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
EOF
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module PoolParty
|
|
2
|
+
class Svn
|
|
3
|
+
|
|
4
|
+
define_resource(:svn) do
|
|
5
|
+
|
|
6
|
+
def has_svnpath(opts={})
|
|
7
|
+
call_function <<-EOE
|
|
8
|
+
svnserve { #{opts[:name]}:
|
|
9
|
+
source => "#{opts[:source]}",
|
|
10
|
+
path => "#{opts[:path]}",
|
|
11
|
+
user => "#{opts[:user] || false}",
|
|
12
|
+
password => "#{opts[:password] || ""}"
|
|
13
|
+
}
|
|
14
|
+
EOE
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
custom_function <<-EOF
|
|
18
|
+
# Serve subversion-based code from a local location. The job of this
|
|
19
|
+
# module is to check the data out from subversion and keep it up to
|
|
20
|
+
# date, especially useful for providing data to your Puppet server.
|
|
21
|
+
define svnserve($source, $path, $user = false, $password = false) {
|
|
22
|
+
file { $path:
|
|
23
|
+
ensure => directory,
|
|
24
|
+
owner => root,
|
|
25
|
+
group => root
|
|
26
|
+
}
|
|
27
|
+
$svncmd = $user ? {
|
|
28
|
+
false => "/usr/bin/svn co --non-interactive $source/$name .",
|
|
29
|
+
default => "/usr/bin/svn co --non-interactive --username $user --password '$password' $source/$name ."
|
|
30
|
+
}
|
|
31
|
+
exec { "svnco-$name":
|
|
32
|
+
command => $svncmd,
|
|
33
|
+
cwd => $path,
|
|
34
|
+
require => File[$path],
|
|
35
|
+
creates => "$path/.svn"
|
|
36
|
+
}
|
|
37
|
+
exec { "svnupdate-$name":
|
|
38
|
+
command => "/usr/bin/svn update",
|
|
39
|
+
require => Exec["svnco-$name"],
|
|
40
|
+
onlyif => '/usr/bin/svn status -u --non-interactive | /bin/grep "\*"',
|
|
41
|
+
cwd => $path
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
EOF
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
=begin rdoc
|
|
2
|
+
Base
|
|
3
|
+
This handles user interaction, loading the parameters, etc.
|
|
4
|
+
=end
|
|
5
|
+
require "open-uri"
|
|
6
|
+
require "ftools"
|
|
7
|
+
module PoolParty
|
|
8
|
+
class Base
|
|
9
|
+
include Configurable
|
|
10
|
+
extend MethodMissingSugar
|
|
11
|
+
|
|
12
|
+
default_options({
|
|
13
|
+
:environment => "production",
|
|
14
|
+
:user => "root", # This should change here
|
|
15
|
+
:base_keypair_path => "~/.ec2",
|
|
16
|
+
:tmp_path => "tmp",
|
|
17
|
+
:remote_storage_path => "/var/poolparty",
|
|
18
|
+
:storage_directory => File.join(Dir.pwd, "tmp"),
|
|
19
|
+
:fileserver_base => "puppet:///files",
|
|
20
|
+
:base_config_directory => "/etc/poolparty",
|
|
21
|
+
:template_directory => "tmp/templates",
|
|
22
|
+
:template_path => "/var/lib/puppet/templates",
|
|
23
|
+
:port => "80",
|
|
24
|
+
:forwarding_port => "8080",
|
|
25
|
+
:proxy_mode => "http",
|
|
26
|
+
:pool_logger_location => File.join(Dir.pwd, "logs"),
|
|
27
|
+
# EC2 Options
|
|
28
|
+
:ami => "ami-4bb05422"
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
# Class methods
|
|
32
|
+
class << self
|
|
33
|
+
def actionable_default_options
|
|
34
|
+
default_options.merge!({:access_key => self.access_key,:secret_access_key => secret_access_key})
|
|
35
|
+
end
|
|
36
|
+
def options(h={})
|
|
37
|
+
@options ||= actionable_default_options.merge(h)
|
|
38
|
+
end
|
|
39
|
+
# Get the access_key
|
|
40
|
+
def access_key
|
|
41
|
+
ENV["AWS_ACCESS_KEY_ID"] ? ENV["AWS_ACCESS_KEY_ID"] : load_keys_from_file[:access_key]
|
|
42
|
+
end
|
|
43
|
+
def secret_access_key
|
|
44
|
+
ENV["AWS_SECRET_ACCESS_ID"] ? ENV["AWS_SECRET_ACCESS_ID"] : load_keys_from_file[:secret_access_key]
|
|
45
|
+
end
|
|
46
|
+
def load_keys_from_file
|
|
47
|
+
@keys ||= get_working_key_file_locations ? YAML::load( open(get_working_key_file_locations).read ) : {}
|
|
48
|
+
end
|
|
49
|
+
def store_keys_in_file
|
|
50
|
+
unless access_key.nil? || secret_access_key.nil?
|
|
51
|
+
write_to_file( key_file_locations.first, YAML::dump({:access_key => access_key, :secret_access_key => secret_access_key}))
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
def reset!
|
|
55
|
+
@keys = nil
|
|
56
|
+
end
|
|
57
|
+
# Get the instance first instance file that exists on the system from the expected places
|
|
58
|
+
# denoted in the local_instances_list_file_locations
|
|
59
|
+
def get_working_key_file_locations
|
|
60
|
+
key_file_locations.reject {|f| f unless ::File.file?(f) }.first
|
|
61
|
+
end
|
|
62
|
+
# Expected places for the instances.list to be located at on the machine
|
|
63
|
+
def key_file_locations
|
|
64
|
+
[
|
|
65
|
+
"#{Base.storage_directory}/.ppkeys",
|
|
66
|
+
"#{Base.base_config_directory}/.ppkeys",
|
|
67
|
+
"~/.ppkeys",
|
|
68
|
+
"ppkeys"
|
|
69
|
+
]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/plugin_model"
|
|
2
|
+
require File.dirname(__FILE__) + "/resource"
|
|
3
|
+
|
|
4
|
+
module PoolParty
|
|
5
|
+
module Cloud
|
|
6
|
+
def cloud(name=:main, &block)
|
|
7
|
+
clouds.has_key?(name) ? clouds[name] : (clouds[name] = Cloud.new(name, self, &block))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def clouds
|
|
11
|
+
$clouds ||= {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def with_cloud(cl, opts={}, &block)
|
|
15
|
+
cl.options.merge!(opts)
|
|
16
|
+
cl.instance_eval &block if block
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Cloud
|
|
20
|
+
attr_reader :name, :templates
|
|
21
|
+
include PoolParty::PluginModel
|
|
22
|
+
include PoolParty::Resources
|
|
23
|
+
include PrettyPrinter
|
|
24
|
+
include Configurable
|
|
25
|
+
include CloudResourcer
|
|
26
|
+
extend CloudResourcer
|
|
27
|
+
# Net methods
|
|
28
|
+
include PoolParty::Remote::RemoterBase
|
|
29
|
+
include Remote
|
|
30
|
+
|
|
31
|
+
default_options({
|
|
32
|
+
:minimum_instances => 2,
|
|
33
|
+
:maximum_instances => 4,
|
|
34
|
+
:access_key => Base.access_key,
|
|
35
|
+
:secret_access_key => Base.secret_access_key,
|
|
36
|
+
:ec2_dir => ENV["EC2_HOME"],
|
|
37
|
+
:keypair => (ENV["KEYPAIR_NAME"].nil? || ENV["KEYPAIR_NAME"].empty?) ? nil : ENV["KEYPAIR_NAME"],
|
|
38
|
+
:ami => 'ami-44bd592d',
|
|
39
|
+
:polling_time => "30.seconds"
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
def initialize(name, parent, &block)
|
|
43
|
+
@name = name
|
|
44
|
+
set_parent(parent) if parent
|
|
45
|
+
self.instance_eval &block if block_given?
|
|
46
|
+
# this can be overridden in the spec, but ec2 is the default
|
|
47
|
+
using :ec2
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Keypairs
|
|
51
|
+
# If the parent (pool) doesn't have a keypair defined on it, then generate one based on the
|
|
52
|
+
# pool_name and the cloud_name
|
|
53
|
+
def keypair(*args)
|
|
54
|
+
has_keypair? ? options[:keypair] : generate_keypair(*args)
|
|
55
|
+
end
|
|
56
|
+
def has_keypair?
|
|
57
|
+
options.has_key?(:keypair) && options[:keypair]
|
|
58
|
+
end
|
|
59
|
+
def generate_keypair(*args)
|
|
60
|
+
options[:keypair] = args.length > 0 ? args[0] : "#{@parent.respond_to?(:name) ? @parent.name : ""}_#{@name}"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def prepare_to_configuration
|
|
64
|
+
# clear_base_directory
|
|
65
|
+
make_base_directory
|
|
66
|
+
copy_misc_templates
|
|
67
|
+
Base.store_keys_in_file
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def build_and_store_new_config_file
|
|
71
|
+
@manifest = build_manifest
|
|
72
|
+
config_file = ::File.join(Base.storage_directory, "poolparty.pp")
|
|
73
|
+
::File.open(config_file, "w+") do |file|
|
|
74
|
+
file << "class poolparty {"
|
|
75
|
+
file << @manifest
|
|
76
|
+
file << "}"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def copy_misc_templates
|
|
81
|
+
["fileserver.conf", "namespaceauth.conf"].each do |f|
|
|
82
|
+
copy_file_to_storage_directory(::File.join(::File.dirname(__FILE__), "..", "templates", f))
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Configuration files
|
|
87
|
+
def build_manifest
|
|
88
|
+
reset_resources!
|
|
89
|
+
add_poolparty_base_requirements
|
|
90
|
+
|
|
91
|
+
returning Array.new do |str|
|
|
92
|
+
|
|
93
|
+
str << resources_string_from_resources(resources)
|
|
94
|
+
|
|
95
|
+
# Refactor this into the resources method
|
|
96
|
+
# TODO
|
|
97
|
+
services.each do |service|
|
|
98
|
+
@cp = classpackage_with_self(service)
|
|
99
|
+
str << @cp.to_string
|
|
100
|
+
str << @cp.include_string
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
str << "# Custom functions"
|
|
104
|
+
str << Resources::CustomResource.custom_functions_to_string
|
|
105
|
+
end.join("\n")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Add all the poolparty requirements here
|
|
109
|
+
# NOTE: These are written as plugins in the lib/poolparty/base_packages directory
|
|
110
|
+
# for examples.
|
|
111
|
+
# Also note that there is no block associated. This is because we have written
|
|
112
|
+
# all that is necessary in a method called enable
|
|
113
|
+
# which is called when there is no block
|
|
114
|
+
def add_poolparty_base_requirements
|
|
115
|
+
heartbeat
|
|
116
|
+
haproxy
|
|
117
|
+
ruby
|
|
118
|
+
poolparty
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Add to the services pool for the manifest listing
|
|
122
|
+
def add_service(serv)
|
|
123
|
+
services << serv
|
|
124
|
+
end
|
|
125
|
+
# Container for the services
|
|
126
|
+
def services
|
|
127
|
+
@services ||= []
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|