auser-poolparty 1.1.4 → 1.1.5
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/VERSION.yml +1 -1
- data/bin/cloud-configure +2 -0
- data/bin/cloud-start +2 -2
- data/bin/server-cloud-elections +26 -18
- data/bin/server-ensure-provisioning +24 -29
- data/bin/server-list-active +1 -0
- data/lib/poolparty/base_packages/haproxy.rb +6 -2
- data/lib/poolparty/base_packages/poolparty.rb +1 -1
- data/lib/poolparty/core/string.rb +14 -0
- data/lib/poolparty/dependency_resolver/chef_resolver.rb +38 -7
- data/lib/poolparty/lite.rb +4 -2
- data/lib/poolparty/modules/cloud_resourcer.rb +12 -3
- data/lib/poolparty/modules/definable_resource.rb +1 -4
- data/lib/poolparty/net/remoter/cloud_control.rb +0 -30
- data/lib/poolparty/net/remoter/connections.rb +7 -6
- data/lib/poolparty/net/remoter_base.rb +45 -1
- data/lib/poolparty/plugins/chef.rb +55 -66
- data/lib/poolparty/plugins/{deploydirectory.rb → deploy_directory.rb} +8 -1
- data/lib/poolparty/plugins/gem_package.rb +31 -0
- data/lib/poolparty/poolparty/key.rb +11 -8
- data/lib/poolparty/poolparty/plugin.rb +1 -1
- data/lib/poolparty/poolparty/plugin_model.rb +5 -5
- data/lib/poolparty/poolparty/service.rb +1 -1
- data/lib/poolparty/provision/boot_strapper.rb +16 -2
- data/lib/poolparty/provision/configurations/chef.rb +7 -4
- data/lib/poolparty/provision/dr_configure.rb +20 -6
- data/lib/poolparty/schema.rb +17 -0
- data/lib/poolparty/templates/haproxy.conf +1 -1
- data/vendor/gems/suitcase/VERSION.yml +1 -1
- data/vendor/gems/suitcase/lib/suitcase/zipper.rb +4 -4
- data/vendor/gems/suitcase/suitcase.gemspec +2 -2
- metadata +4 -4
- data/lib/poolparty/services/gem_package.rb +0 -52
data/VERSION.yml
CHANGED
data/bin/cloud-configure
CHANGED
@@ -9,6 +9,8 @@ end
|
|
9
9
|
|
10
10
|
o.loaded_clouds.each do |cld|
|
11
11
|
# If an IP or DNS name is given, bootstrap that node, otherwise, bootstrap all running nodes.
|
12
|
+
# ::FileUtils.rm_rf "#{Default.tmp_path}/" unless o.testing?
|
13
|
+
|
12
14
|
nodes = !o.unflagged_args.empty? ? o.unflagged_args : cld.remote_instances_list.collect {|inst| inst.ip if inst.running? }.compact
|
13
15
|
if nodes.empty?
|
14
16
|
puts "No nodes to configure"
|
data/bin/cloud-start
CHANGED
@@ -12,8 +12,8 @@ o.loaded_clouds.each do |cld|
|
|
12
12
|
puts "#{cld.list_of_running_instances.size} running instances (#{cld.minimum_instances} - #{cld.maximum_instances})"
|
13
13
|
|
14
14
|
cld.launch_instance! do |node|
|
15
|
-
::PoolParty::Provision::BootStrapper.new(node.ip, :
|
16
|
-
::PoolParty::Provision::DrConfigure.new(node.ip, :
|
15
|
+
::PoolParty::Provision::BootStrapper.new(node.ip, :cloud => cld)
|
16
|
+
::PoolParty::Provision::DrConfigure.new(node.ip, :cloud => cld)
|
17
17
|
|
18
18
|
puts <<-EOM
|
19
19
|
Your cloud has started. Your ip is #{node.ip}
|
data/bin/server-cloud-elections
CHANGED
@@ -1,26 +1,34 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require
|
4
|
-
require 'json'
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
require "poolparty"
|
5
4
|
require "poolparty/lite"
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
|
7
|
+
opts.on('-n cloudname', '--name name', 'Start cloud by this name') { |c| optioner.cloudname c }
|
8
|
+
opts.on('-i num', '--num i', 'Instance number') { |i| optioner.inst_num i.to_i }
|
9
|
+
end
|
10
|
+
|
11
|
+
vote_for = o.unflagged_args.shift || "none"
|
12
|
+
|
13
|
+
schema = ::PoolParty.load_cloud_from_json(o.unflagged_args.shift) #TODO: smarter option parser
|
9
14
|
remote_base_name = schema.options.remote_base.split('::')[-1].camelcase
|
10
15
|
remoter_base = PoolParty::Remote.module_eval(remote_base_name)
|
11
|
-
require 'rubygems'; require 'ruby-debug'; debugger
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
o.loaded_clouds.each do |cld|
|
18
|
+
cld.update_from_schema(schema)
|
19
|
+
|
20
|
+
case vote_for
|
21
|
+
when "expand"
|
22
|
+
# PoolParty.log << "Launching new instance"
|
23
|
+
cld.send :launch_instance!, schema.options do |node|
|
24
|
+
::PoolParty::Provision::BootStrapper.new( node[:ip], :cloud => cld )
|
25
|
+
::PoolParty::Provision::DrConfigure.new( node[:ip], :cloud => cld )
|
26
|
+
end
|
27
|
+
when "contract"
|
28
|
+
last_instance_id = %x[/usr/bin/server-list-active instance_id].split("\t").last
|
29
|
+
remoter_base.terminate_instance! schema.options.merge(:instance_id => last_instance_id)
|
30
|
+
else
|
31
|
+
puts "Unknown action: #{vote_for}"
|
19
32
|
end
|
20
|
-
|
21
|
-
last_instance_id = %x[/usr/bin/server-list-active instance_id].split("\t").last
|
22
|
-
remoter_base.terminate_instance! schema.options.merge(:instance_id => last_instance_id)
|
23
|
-
else
|
24
|
-
puts "Unknown action: #{vote_for}"
|
33
|
+
|
25
34
|
end
|
26
|
-
|
@@ -1,38 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
3
|
require "poolparty"
|
4
|
-
require "
|
4
|
+
require "poolparty/lite"
|
5
5
|
|
6
|
-
available_monitors = PoolParty::Monitors.available_monitors
|
7
6
|
o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
|
8
|
-
opts.on('-n
|
9
|
-
opts.on('-
|
7
|
+
opts.on('-n cloudname', '--name name', 'Start cloud by this name') { |c| optioner.cloudname c }
|
8
|
+
opts.on('-i num', '--num i', 'Instance number') { |i| optioner.inst_num i.to_i }
|
10
9
|
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
schema = ::PoolParty.load_cloud_from_json
|
12
|
+
|
13
|
+
o.loaded_clouds.each do |cld|
|
14
|
+
cld.update_from_schema(schema)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
vputs "Executing #{cmd}"
|
32
|
-
running = %x[#{running_cmd}]
|
33
|
-
`#{cmd}` if running.chomp.empty?
|
16
|
+
# If an IP or DNS name is given, bootstrap that node, otherwise, bootstrap all running nodes.
|
17
|
+
nodes = !o.unflagged_args.empty? ? o.unflagged_args : cld.remote_instances_list.collect {|inst| inst.ip if inst.running? }.compact
|
18
|
+
if nodes.empty?
|
19
|
+
puts "No nodes to bootstrap"
|
20
|
+
else
|
21
|
+
if o.inst_num?
|
22
|
+
::PoolParty::Provision::BootStrapper.new( nodes[o.inst_num], :cloud => cld )
|
23
|
+
::PoolParty::Provision::DrConfigure.new( nodes[o.inst_num], :cloud => cld )
|
24
|
+
else
|
25
|
+
nodes.each do |address|
|
26
|
+
puts "bootstrapping: #{address}"
|
27
|
+
::PoolParty::Provision::BootStrapper.new( address, :cloud => cld )
|
28
|
+
::PoolParty::Provision::DrConfigure.new( address, :cloud => cld )
|
29
|
+
end
|
34
30
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
data/bin/server-list-active
CHANGED
@@ -10,6 +10,7 @@ schema = PoolParty::Schema.new( ::File.read(json_file) )
|
|
10
10
|
|
11
11
|
remoter_base = schema.options.remote_base
|
12
12
|
|
13
|
+
# TODO: WTF? Change this
|
13
14
|
instances = PoolParty::Remote::Ec2.describe_instances(schema.options)
|
14
15
|
inst_array = instances.map {|inst| inst.send list_type.to_sym }
|
15
16
|
|
@@ -2,9 +2,13 @@ module PoolParty
|
|
2
2
|
class Base
|
3
3
|
plugin :poolparty_base_haproxy do
|
4
4
|
|
5
|
-
def
|
5
|
+
def before_configure
|
6
6
|
# We need the haproxy package
|
7
|
-
::Suitcase::Zipper.add("#{::File.dirname(__FILE__)}/../../../vendor/chef/apache2", "chef/
|
7
|
+
::Suitcase::Zipper.add("#{::File.dirname(__FILE__)}/../../../vendor/chef/apache2", "chef/cookbooks")
|
8
|
+
end
|
9
|
+
|
10
|
+
def enable
|
11
|
+
has_chef_recipe 'apache2'
|
8
12
|
has_service "apache2"
|
9
13
|
|
10
14
|
has_package({:name => "haproxy"}) do
|
@@ -67,6 +67,20 @@ class String
|
|
67
67
|
klass
|
68
68
|
end
|
69
69
|
|
70
|
+
def new_resource_class(superclass=nil, opts={}, &block)
|
71
|
+
symc = "::PoolParty::Resources::#{self.camelcase}"
|
72
|
+
kla=<<-EOE
|
73
|
+
class #{symc} < ::PoolParty::Resources::Resource
|
74
|
+
end
|
75
|
+
EOE
|
76
|
+
|
77
|
+
Kernel.module_eval kla
|
78
|
+
klass = symc.constantize
|
79
|
+
klass.module_eval &block if block
|
80
|
+
|
81
|
+
klass
|
82
|
+
end
|
83
|
+
|
70
84
|
def camelcase
|
71
85
|
gsub(/(^|_|-)(.)/) { $2.upcase }
|
72
86
|
end
|
@@ -1,8 +1,33 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
ChefResolver
|
3
|
+
|
4
|
+
This takes the internal structure
|
5
|
+
{
|
6
|
+
:options => {},
|
7
|
+
:services => [{}],
|
8
|
+
:resources => {}
|
9
|
+
}
|
10
|
+
|
11
|
+
and creates a chef recipe to reflect.
|
12
|
+
|
13
|
+
/cookbooks/
|
14
|
+
namespace/
|
15
|
+
recipes/
|
16
|
+
templates/
|
17
|
+
attributes/
|
18
|
+
=end
|
1
19
|
module PoolParty
|
2
20
|
|
3
21
|
class ChefResolver< DependencyResolver
|
4
22
|
|
5
|
-
|
23
|
+
# Compile and add to the zipper
|
24
|
+
def compile(props=@properties_hash, tabs=0, default_namespace="poolparty")
|
25
|
+
o = _compile(props, tabs, default_namespace)
|
26
|
+
::Suitcase::Zipper.add(build_base_recipe_directory( default_namespace ), "chef/cookbooks")
|
27
|
+
o
|
28
|
+
end
|
29
|
+
|
30
|
+
def _compile(props=@properties_hash, tabs=0, default_namespace="poolparty")
|
6
31
|
cld_name = default_namespace
|
7
32
|
comp(cld_name, props, tabs)
|
8
33
|
end
|
@@ -16,8 +41,8 @@ module PoolParty
|
|
16
41
|
resources_to_string(props[:resources],tabs),
|
17
42
|
services_to_string(props[:services],tabs)
|
18
43
|
].join("\n")
|
19
|
-
::File.open("#{basedir}/recipes/default.rb", "w+") {|f| f << default_recipe }
|
20
|
-
|
44
|
+
::File.open("#{basedir}/recipes/default.rb", "w+") {|f| f << default_recipe }
|
45
|
+
|
21
46
|
default_recipe
|
22
47
|
end
|
23
48
|
|
@@ -29,7 +54,7 @@ module PoolParty
|
|
29
54
|
end
|
30
55
|
|
31
56
|
def base_dir(nm=nil)
|
32
|
-
@base_dir ||= "#{Default.tmp_path}/
|
57
|
+
@base_dir ||= "#{Default.tmp_path}/trash/chef/cookbooks/#{nm}"
|
33
58
|
end
|
34
59
|
|
35
60
|
def options_to_string(opts,tabs=0)
|
@@ -45,6 +70,12 @@ module PoolParty
|
|
45
70
|
handle_print_variables(vars)
|
46
71
|
end
|
47
72
|
|
73
|
+
if opts[:chef_recipe]
|
74
|
+
opts.delete(:chef_recipe).each do |rcp|
|
75
|
+
out << "include_recipe #{to_option_string(rcp.name)}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
48
79
|
if opts.has_key?(:line_in_file)
|
49
80
|
lines = opts.delete(:line_in_file).inject([]) do |sum, l|
|
50
81
|
sum << PoolParty::Resources::Exec.new(:name => l[:name], :command => PoolParty::Resources::LineInFile.command(l[:line], l[:file]) ).to_properties_hash
|
@@ -129,7 +160,7 @@ module PoolParty
|
|
129
160
|
str = "\n#{tf(tabs)}# #{kname}\n"
|
130
161
|
str << "#{tf(tabs+1)}"
|
131
162
|
klassarray.each do |hsh|
|
132
|
-
str <<
|
163
|
+
str << _compile(hsh,tabs+1, klassname)
|
133
164
|
end
|
134
165
|
str << "#{tf(tabs)}"
|
135
166
|
end
|
@@ -183,9 +214,9 @@ module PoolParty
|
|
183
214
|
nil
|
184
215
|
when :if_not
|
185
216
|
"not_if"
|
186
|
-
when :
|
217
|
+
when :not_if
|
187
218
|
"not_if"
|
188
|
-
when :
|
219
|
+
when :only_if
|
189
220
|
"only_if"
|
190
221
|
else
|
191
222
|
"#{key}"
|
data/lib/poolparty/lite.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "json"
|
3
|
-
require("#{::File.dirname(__FILE__)}/../../vendor/gems/dslify/lib/dslify")
|
3
|
+
require("#{::File.dirname(__FILE__)}/../../vendor/gems/dslify/lib/dslify") rescue( require 'dslify')
|
4
4
|
require "#{::File.dirname(__FILE__)}/poolparty/default"
|
5
5
|
require "#{::File.dirname(__FILE__)}/schema"
|
6
6
|
require "#{::File.dirname(__FILE__)}/net/init"
|
7
7
|
require "#{::File.dirname(__FILE__)}/exceptions/RemoteException.rb"
|
8
8
|
|
9
9
|
module PoolParty
|
10
|
+
extend ::PoolParty::Remote
|
11
|
+
|
10
12
|
def self.load_cloud_from_json(json_file_path=nil)
|
11
13
|
json_file = json_file_path || PoolParty::Default.properties_hash_file
|
12
14
|
PoolParty::Schema.new( ::File.read(json_file) ) rescue exit 1
|
13
|
-
end
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
class String
|
@@ -85,9 +85,9 @@ module PoolParty
|
|
85
85
|
# Use the keypair path
|
86
86
|
def keypair(*args)
|
87
87
|
if args && !args.empty?
|
88
|
-
args.each {|arg| _keypairs.unshift Key.new(arg) }
|
88
|
+
args.each {|arg| _keypairs.unshift Key.new(arg) unless arg.nil? || arg.empty? }
|
89
89
|
else
|
90
|
-
_keypairs.select {|key| key.exists? }.first
|
90
|
+
@keypair ||= _keypairs.select {|key| key.exists? }.first
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -97,10 +97,19 @@ module PoolParty
|
|
97
97
|
dsl_options[:keypairs] ||= [Key.new]
|
98
98
|
end
|
99
99
|
|
100
|
-
def full_keypair_path
|
100
|
+
def full_keypair_path
|
101
101
|
@full_keypair_path ||= keypair.full_filepath
|
102
102
|
end
|
103
103
|
|
104
|
+
def update_from_schema(schema)
|
105
|
+
keypairs = schema.options.delete(:keypairs).map {|a| PoolParty::Key.new(a.basename) }
|
106
|
+
options.merge! schema.options
|
107
|
+
dsl_options[:keypairs] = keypairs
|
108
|
+
|
109
|
+
dsl_options[:dependency_resolver] = schema.options.dependency_resolver.split("::")[-1].gsub(/Resolver/, '').preserved_class_constant("Resolver") rescue PoolParty::Chef
|
110
|
+
|
111
|
+
end
|
112
|
+
|
104
113
|
# TODO: deprecate
|
105
114
|
def number_of_resources
|
106
115
|
arr = resources.map do |n, r|
|
@@ -16,10 +16,7 @@ module PoolParty
|
|
16
16
|
#
|
17
17
|
# For example usage, see lib/poolparty/plugins/line.rb
|
18
18
|
def define_resource(name, &block)
|
19
|
-
|
20
|
-
klass = symc.class_constant(PoolParty::Resources::CustomResource, {:preserve => true}, &block)
|
21
|
-
PoolParty::Resources.module_eval &block
|
22
|
-
klass
|
19
|
+
name.to_s.new_resource_class(PoolParty::Resources::Resource, &block)
|
23
20
|
end
|
24
21
|
|
25
22
|
# Allow us to create virtual resources
|
@@ -3,36 +3,6 @@ require "ping"
|
|
3
3
|
module PoolParty
|
4
4
|
module Remote
|
5
5
|
|
6
|
-
# TODO: Rename and modularize the @inst.status =~ /pending/ so that it works on all
|
7
|
-
# remoter_bases
|
8
|
-
def launch_instance!(o={}, &block)
|
9
|
-
@inst = launch_new_instance!( o )
|
10
|
-
wait "2.seconds"
|
11
|
-
500.times do |i|
|
12
|
-
if @inst.status =~ /pending/
|
13
|
-
sleep(2)
|
14
|
-
@inst = describe_instance(@inst)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
when_instance_is_responding @inst do
|
18
|
-
block.call(@inst) if block
|
19
|
-
after_launch_instance(@inst)
|
20
|
-
end
|
21
|
-
@inst
|
22
|
-
end
|
23
|
-
|
24
|
-
# Called after an instance is launched
|
25
|
-
def after_launch_instance(instance=nil)
|
26
|
-
end
|
27
|
-
|
28
|
-
def when_instance_is_responding(inst, &block)
|
29
|
-
if ping_port(inst.ip, 22)
|
30
|
-
block.call if block
|
31
|
-
else
|
32
|
-
raise "Instance not responding at #{inst.ip}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
6
|
# A convenience method for waiting until there are no more
|
37
7
|
# pending instances and then running the block
|
38
8
|
def when_no_pending_instances(&block)
|
@@ -27,7 +27,7 @@ module PoolParty
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def ssh_options(opts={})
|
30
|
-
o = {"-i" =>
|
30
|
+
o = {"-i" => keypair.full_filepath,
|
31
31
|
"-l" => user,
|
32
32
|
"-o" =>"StrictHostKeyChecking=no"
|
33
33
|
}.merge(opts)
|
@@ -55,23 +55,24 @@ module PoolParty
|
|
55
55
|
:host=>target_host, :user=>'root')
|
56
56
|
# commands.each {|c| run_remote(c, target_host) }
|
57
57
|
end
|
58
|
-
|
59
|
-
def ping_port(host, port=22, retry_times=400)
|
58
|
+
|
59
|
+
def self.ping_port(host, port=22, retry_times=400)
|
60
60
|
connected = false
|
61
61
|
retry_times.times do |i|
|
62
62
|
begin
|
63
|
-
break if connected = TCPSocket.new(host, port).is_a?(TCPSocket)
|
63
|
+
break if connected = TCPSocket.new(host, port).is_a?(TCPSocket)
|
64
64
|
rescue Exception => e
|
65
65
|
sleep(2)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
connected
|
69
69
|
end
|
70
|
+
def ping_port(ip, port, retry_times=500);self.class.ping_port(ip, port, retry_times);end
|
70
71
|
|
71
72
|
def netssh(cmds=[], opts={})
|
72
73
|
user = opts.delete(:user) || user #rescue 'root'
|
73
74
|
host = opts.delete(:host) || target_host
|
74
|
-
ssh_options_hash = {:keys => [
|
75
|
+
ssh_options_hash = {:keys => [keypair.full_filepath],
|
75
76
|
:auth_methods => 'publickey',
|
76
77
|
:paranoid => false
|
77
78
|
}.merge(opts)
|
@@ -79,7 +80,7 @@ module PoolParty
|
|
79
80
|
# Start the connection
|
80
81
|
Net::SSH.start(host, user, ssh_options_hash) do |ssh|
|
81
82
|
cmds.each do |command|
|
82
|
-
ssh.exec!(command) do |ch, stream, data|
|
83
|
+
ssh.exec!(command) do |ch, stream, data|
|
83
84
|
if stream == :stdout
|
84
85
|
print data
|
85
86
|
else
|
@@ -23,7 +23,7 @@ module PoolParty
|
|
23
23
|
# This class is the base class for all remote types, such as ec2
|
24
24
|
# Everything remoting-wise is derived from this class
|
25
25
|
class RemoterBase
|
26
|
-
include Remote
|
26
|
+
include ::PoolParty::Remote
|
27
27
|
|
28
28
|
def initialize(prnt = nil)
|
29
29
|
@parent = prnt
|
@@ -77,6 +77,50 @@ module PoolParty
|
|
77
77
|
self.class.describe_instances(o ? options.merge(o) : options)
|
78
78
|
end
|
79
79
|
|
80
|
+
# TODO: Rename and modularize the @inst.status =~ /pending/ so that it works on all
|
81
|
+
# remoter_bases
|
82
|
+
def self.launch_instance!(o={}, &block)
|
83
|
+
@inst = launch_new_instance!( o )
|
84
|
+
sleep(2)
|
85
|
+
500.times do |i|
|
86
|
+
if @inst.status =~ /pending/
|
87
|
+
sleep(2)
|
88
|
+
@inst = describe_instance(@inst)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
when_instance_is_responding @inst do
|
92
|
+
block.call(@inst) if block
|
93
|
+
after_launch_instance(@inst)
|
94
|
+
end
|
95
|
+
@inst
|
96
|
+
end
|
97
|
+
def launch_instance!(o={}, &block); self.class.launch_instance!(self.options.merge(o), &block);end
|
98
|
+
|
99
|
+
# Called after an instance is launched
|
100
|
+
def self.after_launch_instance(instance=nil);end
|
101
|
+
|
102
|
+
def self.when_instance_is_responding(inst, &block)
|
103
|
+
if ping_port(inst.ip, 22)
|
104
|
+
block.call if block
|
105
|
+
else
|
106
|
+
raise "Instance not responding at #{inst.ip}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
def when_instance_is_responding(inst, &block);self.class.when_instance_is_responding;end
|
110
|
+
|
111
|
+
# TODO: BAD FORM, already defined in connections.rb. Fix this, ASAP
|
112
|
+
def self.ping_port(host, port=22, retry_times=400)
|
113
|
+
connected = false
|
114
|
+
retry_times.times do |i|
|
115
|
+
begin
|
116
|
+
break if connected = TCPSocket.new(host, port).is_a?(TCPSocket)
|
117
|
+
rescue Exception => e
|
118
|
+
sleep(2)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
connected
|
122
|
+
end
|
123
|
+
|
80
124
|
# After launch callback
|
81
125
|
# This is called after a new instance is launched
|
82
126
|
def after_launched(force=false)
|
@@ -1,16 +1,15 @@
|
|
1
1
|
require "tempfile"
|
2
|
+
# BIG TODO: Slim the place where the content is gathered from
|
2
3
|
module PoolParty
|
3
4
|
class ChefRecipe
|
4
5
|
include Dslify
|
5
6
|
end
|
6
7
|
class Chef
|
8
|
+
define_resource :chef_recipe do
|
9
|
+
end
|
7
10
|
|
8
11
|
plugin :chef do
|
9
|
-
def before_load(o, &block)
|
10
|
-
bootstrap_gems "chef", "ohai"
|
11
|
-
bootstrap_commands [
|
12
|
-
"mkdir -p /etc/chef/cookbooks /etc/chef/cache"
|
13
|
-
]
|
12
|
+
def before_load(o, &block)
|
14
13
|
end
|
15
14
|
|
16
15
|
def loaded o={}, &block
|
@@ -21,25 +20,29 @@ module PoolParty
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def basedir
|
24
|
-
@basedir ||= "#{Default.tmp_path}/dr_configure/chef/
|
23
|
+
@basedir ||= "#{Default.tmp_path}/dr_configure/chef/cookbooks/main"
|
25
24
|
end
|
26
25
|
|
27
26
|
def recipe file=nil, o={}, &block
|
28
27
|
if file
|
28
|
+
file = ::File.expand_path(file)
|
29
29
|
::FileUtils.mkdir_p "#{basedir}/recipes" unless ::File.directory? basedir
|
30
|
-
|
30
|
+
|
31
31
|
unless ::File.file?(file)
|
32
32
|
tfile = Tempfile.new("main-poolparty-recipe")
|
33
33
|
tfile << file # copy the string into the temp file
|
34
34
|
file = tfile.path
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
::FileUtils.rm "#{basedir}/recipes/default.rb" if ::File.file?("#{basedir}/recipes/default.rb")
|
37
38
|
::File.cp file, "#{basedir}/recipes/default.rb"
|
38
39
|
|
39
40
|
templates o[:templates] if o[:templates]
|
40
41
|
|
41
|
-
recipe_files << basedir
|
42
|
+
# recipe_files << basedir
|
43
|
+
# ::Suitcase::Zipper.add(basedir, "chef/cookbooks")
|
42
44
|
# TODO: Enable neat syntax from within poolparty
|
45
|
+
|
43
46
|
else
|
44
47
|
raise <<-EOR
|
45
48
|
PoolParty currently only supports passing recipes as files. Please specify a file in your chef block and try again"
|
@@ -51,10 +54,11 @@ module PoolParty
|
|
51
54
|
if templates
|
52
55
|
::FileUtils.mkdir_p "#{basedir}/templates/default/"
|
53
56
|
templates.each do |f|
|
57
|
+
f = ::File.expand_path(f)
|
54
58
|
if ::File.file?(f)
|
55
59
|
::File.cp f, "#{basedir}/templates/default/#{::File.basename(f)}"
|
56
60
|
elsif ::File.directory?(f)
|
57
|
-
Dir["#{f}
|
61
|
+
Dir["#{f}/**"].each {|f| ::File.cp f, "#{basedir}/templates/default/#{::File.basename(f)}" }
|
58
62
|
else
|
59
63
|
tfile = Tempfile.new("main-poolparty-recipe")
|
60
64
|
tfile << f # copy the string into the temp file
|
@@ -65,28 +69,25 @@ module PoolParty
|
|
65
69
|
end
|
66
70
|
|
67
71
|
def json file=nil, &block
|
68
|
-
if
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
::File.cp file, "#{Default.tmp_path}/dr_configure/dna.json"
|
74
|
-
elsif file.is_a?(String)
|
75
|
-
::File.open("#{Default.tmp_path}/dr_configure/dna.json", "w+"){|tf| tf << file } # is really a string
|
76
|
-
else
|
77
|
-
raise <<-EOM
|
78
|
-
Your json must either point to a file that exists or a string. Please check your configuration and try again
|
79
|
-
EOM
|
80
|
-
end
|
81
|
-
@json_file = "#{Default.tmp_path}/dr_configure/dna.json"
|
72
|
+
if file
|
73
|
+
if ::File.file? file
|
74
|
+
::Suitcase::Zipper.add_content_as(open(file).read, "dna.json", "chef")
|
75
|
+
elsif file.is_a?(String)
|
76
|
+
::Suitcase::Zipper.add_content_as(file, "dna.json", "chef")
|
82
77
|
else
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
78
|
+
raise <<-EOM
|
79
|
+
Your json must either point to a file that exists or a string. Please check your configuration and try again
|
80
|
+
EOM
|
81
|
+
end
|
82
|
+
else
|
83
|
+
unless @recipe
|
84
|
+
@recipe = ChefRecipe.new
|
85
|
+
@recipe.instance_eval &block if block
|
86
|
+
@recipe.recipes(recipe_files.empty? ? ["poolparty"] : ["poolparty", "main"])
|
87
|
+
# ::File.open("#{Default.tmp_path}/dr_configure/dna.json", "w+") {|f| f << @recipe.options.to_json }
|
88
|
+
::Suitcase::Zipper.add_content_as(@recipe.options.to_json, "dna.json", "chef")
|
89
|
+
|
90
|
+
configure_commands ["cp -f /var/poolparty/dr_configure/chef/dna.json /etc/chef/dna.json"]
|
90
91
|
end
|
91
92
|
end
|
92
93
|
end
|
@@ -94,37 +95,35 @@ module PoolParty
|
|
94
95
|
def include_recipes *recps
|
95
96
|
unless recps.empty?
|
96
97
|
recps.each do |rcp|
|
97
|
-
Dir[::File.expand_path(rcp)].each do |f|
|
98
|
-
|
98
|
+
Dir[::File.expand_path(rcp)].each do |f|
|
99
|
+
::Suitcase::Zipper.add(f, "chef/cookbooks")
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
105
|
def config file=""
|
105
|
-
if
|
106
|
-
|
106
|
+
if ::File.file? file
|
107
|
+
::Suitcase::Zipper.add_content_as(open(file).read, "solo.rb", "chef")
|
107
108
|
else
|
108
|
-
if
|
109
|
-
@config_file = file
|
110
|
-
else
|
111
|
-
conf_string = if file.empty?
|
109
|
+
conf_string = if file.empty?
|
112
110
|
# default config
|
113
|
-
|
111
|
+
<<-EOE
|
114
112
|
cookbook_path "/etc/chef/cookbooks"
|
115
113
|
node_path "/etc/chef/nodes"
|
116
114
|
log_level :info
|
117
115
|
file_store_path "/etc/chef"
|
118
116
|
file_cache_path "/etc/chef"
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
123
|
-
::File.open("#{Default.tmp_path}/dr_configure/chef_config.rb", "w+") do |tf|
|
124
|
-
tf << conf_string
|
125
|
-
end
|
126
|
-
@config_file = "#{Default.tmp_path}/dr_configure/chef_config.rb"
|
117
|
+
EOE
|
118
|
+
else
|
119
|
+
open(file).read
|
127
120
|
end
|
121
|
+
# ::FileUtils.mkdir_p "#{Default.tmp_path}/trash" unless ::File.directory? "#{Default.tmp_path}/trash"
|
122
|
+
# ::File.open("#{Default.tmp_path}/trash/solo.rb", "w+") do |tf|
|
123
|
+
# tf << conf_string
|
124
|
+
# end
|
125
|
+
::Suitcase::Zipper.add_content_as(conf_string, "solo.rb", "chef")
|
126
|
+
# ::Suitcase::Zipper.add("#{Default.tmp_path}/trash/solo.rb", "chef")
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
@@ -132,34 +131,24 @@ file_cache_path "/etc/chef"
|
|
132
131
|
@added_recipes ||= []
|
133
132
|
end
|
134
133
|
|
135
|
-
def
|
136
|
-
|
134
|
+
def before_bootstrap
|
135
|
+
puts "Called before_bootstrap in chef"
|
136
|
+
bootstrap_gems "chef", "ohai"
|
137
|
+
bootstrap_commands [
|
138
|
+
"mkdir -p /etc/chef/cookbooks /etc/chef/cache"
|
139
|
+
]
|
137
140
|
end
|
138
|
-
|
139
141
|
def before_configure
|
142
|
+
puts "Calling before_configure in Chef (dir: #{::File.directory?("/etc/chef")})"
|
140
143
|
config
|
141
144
|
json
|
142
145
|
|
143
146
|
if ::File.directory?("/etc/chef")
|
144
|
-
::Suitcase::Zipper.add("/etc/chef/cookbooks/*", "chef/
|
147
|
+
::Suitcase::Zipper.add("/etc/chef/cookbooks/*", "chef/cookbooks")
|
145
148
|
::Suitcase::Zipper.add("/etc/chef/dna.json", "chef/json")
|
146
149
|
::Suitcase::Zipper.add("/etc/chef/solo.rb", "chef/")
|
147
150
|
end
|
148
151
|
|
149
|
-
::Suitcase::Zipper.add(@config_file, "chef")
|
150
|
-
added_recipes.each do |rcp|
|
151
|
-
# ::FileUtils.cp_r rcp, "/tmp/poolparty/dr_configure/recipes/"
|
152
|
-
::Suitcase::Zipper.add(rcp, "chef/recipes")
|
153
|
-
end
|
154
|
-
|
155
|
-
::Suitcase::Zipper.add(@json_file, "chef/json")
|
156
|
-
configure_commands ["cp -f /var/poolparty/dr_configure/chef/json/dna.json /etc/chef/dna.json"]
|
157
|
-
|
158
|
-
recipe_files.each do |rf|
|
159
|
-
::FileUtils.mkdir_p "/tmp/poolparty/dr_configure/recipes/#{::File.basename(rf)}"
|
160
|
-
::FileUtils.cp_r rf, "/tmp/poolparty/dr_configure/recipes/#{::File.basename(rf)}"
|
161
|
-
# ::Suitcase::Zipper.add(rf, "chef/recipes")
|
162
|
-
end
|
163
152
|
end
|
164
153
|
|
165
154
|
end
|
@@ -14,7 +14,7 @@ module PoolParty
|
|
14
14
|
|
15
15
|
virtual_resource(:deploy_directory) do
|
16
16
|
|
17
|
-
def loaded(opts={}, &block)
|
17
|
+
def loaded(opts={}, &block)
|
18
18
|
package_deploy_directory
|
19
19
|
add_unpack_directory
|
20
20
|
end
|
@@ -30,6 +30,13 @@ module PoolParty
|
|
30
30
|
not_if "test -f #{to}"
|
31
31
|
command "cp -R /var/poolparty/dr_configure/user_directory/#{name}/* #{to}"
|
32
32
|
end
|
33
|
+
|
34
|
+
if owner?
|
35
|
+
has_exec(:name => "chown-#{name}") do
|
36
|
+
command "chown #{owner} -R #{to}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
33
40
|
end
|
34
41
|
|
35
42
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PoolParty
|
2
|
+
class GempackageResource
|
3
|
+
|
4
|
+
virtual_resource(:gem_package) do
|
5
|
+
|
6
|
+
def loaded(opts={}, &block)
|
7
|
+
if download_url?
|
8
|
+
has_exec(
|
9
|
+
:name => "download-#{name}",
|
10
|
+
:cwd => Default.remote_storage_path,
|
11
|
+
:command => "wget #{download_url} -O #{name}.gem",
|
12
|
+
:if_not => "test -f #{Default.remote_storage_path}/#{name}.gem"
|
13
|
+
)
|
14
|
+
has_exec(
|
15
|
+
:name => "install-#{name}-gem",
|
16
|
+
:command => "gem install --no-ri --no-rdoc #{Default.remote_storage_path}/#{name}.gem",
|
17
|
+
:if_not => "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version?}",
|
18
|
+
:requires => "download-#{name}"
|
19
|
+
)
|
20
|
+
else
|
21
|
+
has_exec(
|
22
|
+
:name => "#{name}",
|
23
|
+
:command => "gem install --no-ri --no-rdoc #{"--version #{version}" if version?} #{"--source #{source}" if source?} #{name}",
|
24
|
+
:if_not => "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version?}"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -6,8 +6,8 @@ module PoolParty
|
|
6
6
|
attr_accessor :filepath
|
7
7
|
|
8
8
|
# Create a new key that defaults to id_rsa as the name.
|
9
|
-
def initialize(
|
10
|
-
@filepath = (
|
9
|
+
def initialize(fpath=nil)
|
10
|
+
@filepath = (fpath.nil? || fpath.empty?) ? "id_rsa" : fpath
|
11
11
|
end
|
12
12
|
|
13
13
|
# If the full_filepath is nil, then the key doesn't exist
|
@@ -42,20 +42,23 @@ module PoolParty
|
|
42
42
|
# then it returns nil and assumes we it doesn't exist
|
43
43
|
def search_in_known_locations
|
44
44
|
self.class.keypair_paths.each do |path|
|
45
|
-
full_path = ::File.join( ::File.expand_path(path), filepath)
|
45
|
+
full_path = ::File.join( ::File.expand_path(path), ::File.basename(filepath))
|
46
46
|
return full_path if ::File.exists?(full_path)
|
47
47
|
end
|
48
|
+
# raise Exception.new("We cannot continue without a keypair. Please define a keypair in your clouds.rb")
|
49
|
+
# TODO: Add raise for keypair
|
48
50
|
nil
|
49
51
|
end
|
50
52
|
|
51
53
|
# Default locations to search for the key
|
52
54
|
def self.keypair_paths
|
53
|
-
[
|
55
|
+
[
|
56
|
+
"#{ENV["HOME"]}/.ssh",
|
54
57
|
"#{Default.poolparty_home_path}/keys",
|
55
|
-
Default.base_keypair_path,
|
56
|
-
Default.base_config_directory,
|
57
|
-
Default.base_ssh_path,
|
58
|
-
Default.remote_storage_path,
|
58
|
+
PoolParty::Default.base_keypair_path,
|
59
|
+
PoolParty::Default.base_config_directory,
|
60
|
+
PoolParty::Default.base_ssh_path,
|
61
|
+
PoolParty::Default.remote_storage_path,
|
59
62
|
Dir.pwd
|
60
63
|
]
|
61
64
|
end
|
@@ -59,7 +59,7 @@ module PoolParty
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.inherited(subclass)
|
62
|
-
method_name = subclass.to_s.top_level_class.gsub(/pool_party_/, '').gsub(/_class/, '').downcase.to_sym
|
62
|
+
method_name = subclass.to_s.top_level_class.gsub(/pool_party_/, '').gsub(/_class/, '').downcase.to_sym
|
63
63
|
add_has_and_does_not_have_methods_for(method_name)
|
64
64
|
end
|
65
65
|
|
@@ -4,7 +4,7 @@ module PoolParty
|
|
4
4
|
module PluginModel
|
5
5
|
|
6
6
|
def plugin(name=:plugin, cloud=nil, &block)
|
7
|
-
plugins
|
7
|
+
plugins[name] ||= PluginModel.new(name, &block)
|
8
8
|
end
|
9
9
|
alias_method :register_plugin, :plugin
|
10
10
|
|
@@ -15,8 +15,8 @@ module PoolParty
|
|
15
15
|
class PluginModel
|
16
16
|
attr_accessor :klass
|
17
17
|
|
18
|
-
def initialize(name,&block)
|
19
|
-
symc = "#{name}".top_level_class.camelcase
|
18
|
+
def initialize(name,&block)
|
19
|
+
symc = "#{name}".top_level_class.camelcase
|
20
20
|
klass = symc.class_constant(PoolParty::Plugin::Plugin, {:preserve => true}, &block)
|
21
21
|
|
22
22
|
lowercase_class_name = symc.downcase
|
@@ -28,9 +28,9 @@ module PoolParty
|
|
28
28
|
i = plugin_store.select {|i| i if i.class == #{lowercase_class_name.camelcase}Class }.first if plugin_store
|
29
29
|
if i
|
30
30
|
i
|
31
|
-
else
|
31
|
+
else
|
32
32
|
inst = #{lowercase_class_name.camelcase}Class.new(opts, parent, &block)
|
33
|
-
|
33
|
+
plugin_store << inst if plugin_store
|
34
34
|
inst
|
35
35
|
end
|
36
36
|
end
|
@@ -18,7 +18,7 @@ module PoolParty
|
|
18
18
|
|
19
19
|
meth = <<-EOM
|
20
20
|
def __#{lowercase_class_name}(opts={}, &block)
|
21
|
-
PoolParty::#{lowercase_class_name.camelcase}Class.new(opts, &block)
|
21
|
+
plugin_store << PoolParty::#{lowercase_class_name.camelcase}Class.new(opts, &block)
|
22
22
|
end
|
23
23
|
alias :#{lowercase_class_name} :__#{lowercase_class_name}
|
24
24
|
EOM
|
@@ -29,6 +29,7 @@ module PoolParty
|
|
29
29
|
activesupport
|
30
30
|
grempe-amazon-ec2
|
31
31
|
RubyInline
|
32
|
+
ohai
|
32
33
|
chef
|
33
34
|
auser-dslify
|
34
35
|
auser-butterfly
|
@@ -45,7 +46,19 @@ module PoolParty
|
|
45
46
|
})
|
46
47
|
class <<self; attr_reader :defaults; end
|
47
48
|
|
48
|
-
|
49
|
+
# In case the method is being called on ourself, let's check the
|
50
|
+
# defaults hash to see if it's available there
|
51
|
+
def method_missing(m,*a,&block)
|
52
|
+
if self.class.defaults.has_key?(m)
|
53
|
+
self.class.defaults[m]
|
54
|
+
elsif @cloud
|
55
|
+
@cloud.send m, *a, &block
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def initialize(host, opts={}, &block)
|
49
62
|
self.class.defaults.merge(opts).to_instance_variables(self)
|
50
63
|
@target_host = host
|
51
64
|
@cloud = opts[:cloud]
|
@@ -66,7 +79,7 @@ module PoolParty
|
|
66
79
|
|
67
80
|
def pack_the_dependencies
|
68
81
|
# Add the keypair to the instance... shudder
|
69
|
-
::Suitcase::Zipper.add(
|
82
|
+
::Suitcase::Zipper.add(keypair, "keys")
|
70
83
|
|
71
84
|
# Use the locally built poolparty gem if it is availabl
|
72
85
|
if edge_pp_gem = Dir["#{Default.vendor_path}/../pkg/*poolparty*gem"].pop
|
@@ -90,6 +103,7 @@ module PoolParty
|
|
90
103
|
|
91
104
|
::Suitcase::Zipper.add("#{::File.join(File.dirname(__FILE__), '..', 'templates', 'gemrc' )}", "etc/poolparty")
|
92
105
|
::Suitcase::Zipper.build_dir!("#{Default.tmp_path}/dependencies")
|
106
|
+
::Suitcase::Zipper.flush!
|
93
107
|
|
94
108
|
# ::FileUtils.rm_rf "#{Default.tmp_path}/trash"
|
95
109
|
end
|
@@ -5,15 +5,18 @@ module PoolParty
|
|
5
5
|
def self.commands
|
6
6
|
[
|
7
7
|
"mkdir -p /etc/chef/cookbooks /etc/chef/cache",
|
8
|
-
"cp -R /var/poolparty/dr_configure/chef/
|
9
|
-
"cp /var/poolparty/dr_configure/
|
8
|
+
"cp -R /var/poolparty/dr_configure/chef/cookbooks/* /etc/chef/cookbooks",
|
9
|
+
"cp /var/poolparty/dr_configure/chef/solo.rb /etc/chef/solo.rb",
|
10
|
+
"cp /var/poolparty/dr_configure/chef/dna.json /etc/chef/dna.json",
|
10
11
|
"/usr/bin/chef-solo -c /etc/chef/solo.rb -j /etc/chef/dna.json"
|
11
12
|
]
|
12
13
|
end
|
13
14
|
def self.files_to_upload
|
14
15
|
[
|
15
|
-
"#{Default.tmp_path}/
|
16
|
-
"#{Default.tmp_path}/dna.json"
|
16
|
+
"#{Default.tmp_path}/dr_configure/chef/solo.rb",
|
17
|
+
"#{Default.tmp_path}/dr_configure/chef/dna.json",
|
18
|
+
"#{Default.base_config_directory}/chef/solo.rb",
|
19
|
+
"#{Default.base_config_directory}/chef/dna.json"
|
17
20
|
]
|
18
21
|
end
|
19
22
|
end
|
@@ -17,13 +17,27 @@ module PoolParty
|
|
17
17
|
:dependency_resolver => 'chef'
|
18
18
|
})
|
19
19
|
end
|
20
|
-
|
21
|
-
|
20
|
+
|
21
|
+
# In case the method is being called on ourself, let's check the
|
22
|
+
# defaults hash to see if it's available there
|
23
|
+
def method_missing(m,*a,&block)
|
24
|
+
if self.class.defaults.has_key?(m)
|
25
|
+
self.class.defaults[m]
|
26
|
+
elsif @cloud
|
27
|
+
@cloud.send m, *a, &block
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_reader :cloud, :keypair
|
34
|
+
|
22
35
|
def initialize(host, opts={}, &block)
|
23
36
|
self.class.defaults.merge(opts).to_instance_variables(self)
|
24
37
|
@target_host = host
|
25
38
|
@configurator = "::PoolParty::Provision::#{dependency_resolver.capitalize}".constantize
|
26
39
|
@cloud = opts[:cloud]
|
40
|
+
@keypair = @cloud.keypair
|
27
41
|
|
28
42
|
@cloud.call_before_configure_callbacks if @cloud
|
29
43
|
prescribe_configuration
|
@@ -31,11 +45,12 @@ module PoolParty
|
|
31
45
|
end
|
32
46
|
|
33
47
|
def prescribe_configuration
|
48
|
+
::FileUtils.mkdir_p "#{Default.tmp_path}/dr_configure" unless ::File.directory?("#{Default.tmp_path}/dr_configure")
|
34
49
|
::File.cp $pool_specfile, "#{Default.tmp_path}/dr_configure/clouds.rb"
|
35
50
|
::File.open "#{Default.tmp_path}/dr_configure/clouds.json", "w" do |f|
|
36
51
|
f << cloud.to_properties_hash.to_json
|
37
52
|
end
|
38
|
-
|
53
|
+
|
39
54
|
setup_configurator
|
40
55
|
write_erlang_cookie
|
41
56
|
@configurator.files_to_upload.each {|f| ::FileUtils.cp f, "#{Default.tmp_path}/dr_configure/#{::File.basename(f)}" if ::File.file?(f) }
|
@@ -47,13 +62,13 @@ module PoolParty
|
|
47
62
|
'chmod 600 /var/poolparty/dr_configure/clouds.rb',
|
48
63
|
'cp -f /var/poolparty/dr_configure/clouds.json /etc/poolparty',
|
49
64
|
'cp /var/poolparty/dr_configure/clouds.rb /etc/poolparty',
|
50
|
-
'cp /var/poolparty/dr_configure/erlang.cookie /root/.erlang.cookie',
|
65
|
+
'cp /var/poolparty/dr_configure/erlang.cookie /root/.erlang.cookie',
|
51
66
|
'ruby /var/poolparty/dr_configure/erlang_cookie_maker',
|
52
67
|
"touch /var/poolparty/POOLPARTY.PROGRESS",
|
53
68
|
'echo "configure" >> /var/poolparty/POOLPARTY.PROGRESS'
|
54
69
|
]
|
55
70
|
commands << self.class.class_commands unless self.class.class_commands.empty?
|
56
|
-
commands << @configurator.commands
|
71
|
+
commands << @configurator.commands
|
57
72
|
end
|
58
73
|
|
59
74
|
def pack_up_and_ship_off_suitcase
|
@@ -65,7 +80,6 @@ module PoolParty
|
|
65
80
|
def setup_configurator
|
66
81
|
# @cloud.write_properties_hash("#{Default.tmp_path}/properties_hash.rb")
|
67
82
|
#TODO: move to puppet class
|
68
|
-
puts "writting new config file"
|
69
83
|
@cloud.build_and_store_new_config_file("#{Default.tmp_path}/dr_configure/poolparty.pp")
|
70
84
|
# Neighborhoods.clump(@cloud.remote_instances_list, "#{Default.tmp_path}/neighborhood.json")
|
71
85
|
end
|
data/lib/poolparty/schema.rb
CHANGED
@@ -40,6 +40,23 @@ module PoolParty
|
|
40
40
|
@hsh.send(sym, *args, &block)
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def to_cloud(node={})
|
45
|
+
require "ostruct"
|
46
|
+
|
47
|
+
$pool_specfile = "/etc/poolparty/clouds.rb"
|
48
|
+
|
49
|
+
remoter_base = PoolParty::Remote.module_eval(options.remote_base.split('::')[-1].camelcase)
|
50
|
+
# TODO: Seriously, make this sexier
|
51
|
+
|
52
|
+
cld = OpenStruct.new(options)
|
53
|
+
cld.keypair = ::PoolParty::Key.new("/etc/poolparty/#{node[:keypair]}")
|
54
|
+
cld.remoter_base = remoter_base
|
55
|
+
cld.build_and_store_new_config_file = "/etc/poolparty/clouds.json"
|
56
|
+
cld.dependency_resolver = PoolParty.module_eval(options.dependency_resolver.split("::")[-1].camelcase).send(:new)
|
57
|
+
|
58
|
+
cld
|
59
|
+
end
|
43
60
|
end
|
44
61
|
end
|
45
62
|
# class Hash
|
@@ -31,6 +31,6 @@ listen <%= @node[:poolparty][:haproxy_name] %>
|
|
31
31
|
mode <%= @node[:poolparty][:proxy_mode] %>
|
32
32
|
bind 0.0.0.0:<%= @node[:poolparty][:ports_haproxy].join(",0.0.0.0:") %>
|
33
33
|
cookie POOLPARTYPARTY
|
34
|
-
<% %x[/usr/bin/server-list-active
|
34
|
+
<% %x[/usr/bin/server-list-active internal_ip].split("\t").each_with_index do |ip, index| %>
|
35
35
|
server <%= index == 0 ? "master" : "node#{index}" %> <%= ip %>:<%= @node[:poolparty][:forwarding_port] %> weight 1 check cookie
|
36
36
|
<% end %>
|
@@ -30,15 +30,15 @@ module Suitcase
|
|
30
30
|
def self.build_dir!(dirpath)
|
31
31
|
::FileUtils.mkdir_p dirpath unless ::File.directory? dirpath
|
32
32
|
items.each do |name, path|
|
33
|
-
if name
|
33
|
+
if name.to_s =~ /string/
|
34
34
|
fpath = "#{dirpath}/#{path[:namespace]}/#{path[:name]}"
|
35
35
|
ensure_location_exists(::File.dirname(fpath))
|
36
36
|
::File.open(fpath, "w+") do |tf|
|
37
37
|
tf << path[:content]
|
38
38
|
end
|
39
|
-
else
|
39
|
+
else
|
40
40
|
end_path = "#{dirpath}/#{name}"
|
41
|
-
::FileUtils.mkdir_p ::File.dirname(end_path) unless ::File.directory? ::File.dirname(end_path) unless name == ::File.basename(name)
|
41
|
+
::FileUtils.mkdir_p ::File.dirname(end_path) unless ::File.directory? ::File.dirname(end_path) unless name == ::File.basename(name)
|
42
42
|
::FileUtils.cp path, end_path
|
43
43
|
end
|
44
44
|
end
|
@@ -112,7 +112,7 @@ module Suitcase
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def self.add_content_as(content="", filename="", namespace="files")
|
115
|
-
items.merge!({
|
115
|
+
items.merge!({"string_#{filename}_#{namespace}".to_sym => {:name => ::File.basename(filename), :content => content, :namespace => namespace}})
|
116
116
|
end
|
117
117
|
|
118
118
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{suitcase}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Ari Lerner"]
|
9
|
-
s.date = %q{2009-04-
|
9
|
+
s.date = %q{2009-04-16}
|
10
10
|
s.email = %q{arilerner@mac.com}
|
11
11
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
|
12
12
|
s.files = ["README.rdoc", "VERSION.yml", "lib/suitcase", "lib/suitcase/unzipper.rb", "lib/suitcase/zipper.rb", "lib/suitcase.rb", "test/suitcase_test.rb", "test/test_dir", "test/test_dir/box.rb", "test/test_dir/test.txt", "test/test_helper.rb", "LICENSE"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auser-poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -369,7 +369,8 @@ files:
|
|
369
369
|
- lib/poolparty/net/remoter_bases/ec2/ec2_response_object.rb
|
370
370
|
- lib/poolparty/plugins
|
371
371
|
- lib/poolparty/plugins/chef.rb
|
372
|
-
- lib/poolparty/plugins/
|
372
|
+
- lib/poolparty/plugins/deploy_directory.rb
|
373
|
+
- lib/poolparty/plugins/gem_package.rb
|
373
374
|
- lib/poolparty/plugins/git.rb
|
374
375
|
- lib/poolparty/plugins/line_in_file.rb
|
375
376
|
- lib/poolparty/plugins/rsyncmirror.rb
|
@@ -414,7 +415,6 @@ files:
|
|
414
415
|
- lib/poolparty/schema.rb
|
415
416
|
- lib/poolparty/services
|
416
417
|
- lib/poolparty/services/conditional.rb
|
417
|
-
- lib/poolparty/services/gem_package.rb
|
418
418
|
- lib/poolparty/spec
|
419
419
|
- lib/poolparty/spec/core
|
420
420
|
- lib/poolparty/spec/core/string.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module PoolParty
|
2
|
-
# module Resources
|
3
|
-
|
4
|
-
class Gempackage < Service
|
5
|
-
|
6
|
-
# When we call gempackage, we want the exec to run on the directory we suggest
|
7
|
-
# we also only want it to run if there is NOT a local gem already installed with
|
8
|
-
# the package details (version and name)
|
9
|
-
#
|
10
|
-
# TODO: Add it so that it tries to pull the gem off the master fileserver first...
|
11
|
-
def loaded(opts={})
|
12
|
-
if download_url
|
13
|
-
|
14
|
-
case_of "hostname"
|
15
|
-
when_is "master" do
|
16
|
-
has_exec(:name => "download-#{name}", :cwd => Default.remote_storage_path, :command => "wget #{download_url} -O #{name}.gem", :ifnot => "test -f #{Default.remote_storage_path}/#{name}.gem")
|
17
|
-
end
|
18
|
-
end_of
|
19
|
-
|
20
|
-
has_file({
|
21
|
-
:name => "#{Default.remote_storage_path}/#{name}.gem",
|
22
|
-
:source => "#{Base.fileserver_base}/#{name}.gem",
|
23
|
-
:requires => get_host("master")
|
24
|
-
})
|
25
|
-
|
26
|
-
has_exec(opts.merge({:name => "#{name}", :cwd =>"#{Default.remote_storage_path}"})) do
|
27
|
-
command "gem install --no-ri --no-rdoc #{Default.remote_storage_path}/#{name}.gem"
|
28
|
-
ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
|
29
|
-
requires get_file("#{Default.remote_storage_path}/#{name}.gem")
|
30
|
-
end
|
31
|
-
|
32
|
-
else
|
33
|
-
has_exec(opts.merge({:name => "#{name}", :cwd => "/tmp", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin"})) do
|
34
|
-
command "gem install --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name}"
|
35
|
-
ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
def virtual_resource?
|
40
|
-
true
|
41
|
-
end
|
42
|
-
def printable?
|
43
|
-
true
|
44
|
-
end
|
45
|
-
def class_type_name
|
46
|
-
"Exec"
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
# end
|
52
|
-
end
|