poolparty 0.2.6 → 0.2.18
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +123 -4
- data/PostInstall.txt +2 -1
- data/bin/cloud +16 -7
- data/bin/cloud-provision +9 -5
- data/bin/cloud-run +19 -0
- data/bin/cloud-ssh +2 -7
- data/bin/cloud-start +2 -1
- data/bin/pool +3 -3
- data/bin/server-build-messenger +20 -0
- data/bin/server-fire-cmd +14 -0
- data/bin/server-get-load +29 -0
- data/bin/server-list-active +25 -0
- data/bin/server-list-responding +24 -0
- data/bin/server-rerun +24 -0
- data/bin/server-start-master +27 -0
- data/bin/server-start-node +33 -0
- data/config/requirements.rb +1 -1
- data/erl_crash.dump +8409 -0
- data/lib/erlang/messenger/Emakefile +1 -0
- data/lib/erlang/messenger/Makefile +15 -0
- data/lib/erlang/messenger/README +5 -0
- data/lib/erlang/messenger/Rakefile +60 -0
- data/lib/erlang/messenger/control +11 -0
- data/lib/erlang/messenger/ebin/master.app +19 -0
- data/lib/erlang/messenger/ebin/master_app.beam +0 -0
- data/lib/erlang/messenger/ebin/node.app +19 -0
- data/lib/erlang/messenger/ebin/node_app.beam +0 -0
- data/lib/erlang/messenger/ebin/packager.app +19 -0
- data/lib/erlang/messenger/ebin/pm_client.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_cluster.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_event_handler.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_master_rel-0.1.rel +1 -0
- data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_node_rel-0.1.rel +1 -0
- data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
- data/lib/erlang/messenger/ebin/pm_packager.beam +0 -0
- data/lib/erlang/messenger/ebin/utils.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/AUTHORS +2 -0
- data/lib/erlang/messenger/lib/eunit/CHANGELOG +14 -0
- data/lib/erlang/messenger/lib/eunit/COPYING +504 -0
- data/lib/erlang/messenger/lib/eunit/Makefile +28 -0
- data/lib/erlang/messenger/lib/eunit/NOTES +276 -0
- data/lib/erlang/messenger/lib/eunit/README +3 -0
- data/lib/erlang/messenger/lib/eunit/doc/edoc-info +3 -0
- data/lib/erlang/messenger/lib/eunit/doc/erlang.png +0 -0
- data/lib/erlang/messenger/lib/eunit/doc/eunit.html +172 -0
- data/lib/erlang/messenger/lib/eunit/doc/index.html +17 -0
- data/lib/erlang/messenger/lib/eunit/doc/modules-frame.html +12 -0
- data/lib/erlang/messenger/lib/eunit/doc/overview-summary.html +984 -0
- data/lib/erlang/messenger/lib/eunit/doc/overview.edoc +980 -0
- data/lib/erlang/messenger/lib/eunit/doc/packages-frame.html +11 -0
- data/lib/erlang/messenger/lib/eunit/doc/stylesheet.css +55 -0
- data/lib/erlang/messenger/lib/eunit/ebin/autoload.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/code_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.app +21 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.appup +1 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_autoexport.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_data.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_lib.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_proc.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_serial.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_server.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_striptests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_test.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tests.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/eunit_tty.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/ebin/file_monitor.beam +0 -0
- data/lib/erlang/messenger/lib/eunit/examples/eunit_examples.erl +339 -0
- data/lib/erlang/messenger/lib/eunit/examples/fib.erl +19 -0
- data/lib/erlang/messenger/lib/eunit/examples/tests.txt +1 -0
- data/lib/erlang/messenger/lib/eunit/include/eunit.hrl +313 -0
- data/lib/erlang/messenger/lib/eunit/src/Makefile +46 -0
- data/lib/erlang/messenger/lib/eunit/src/autoload.erl +388 -0
- data/lib/erlang/messenger/lib/eunit/src/code_monitor.erl +243 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.app.src +21 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.appup.src +1 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit.erl +196 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_autoexport.erl +102 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_data.erl +798 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_internal.hrl +48 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_lib.erl +682 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_proc.erl +552 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_serial.erl +157 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_server.erl +340 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_striptests.erl +64 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_test.erl +334 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_tests.erl +45 -0
- data/lib/erlang/messenger/lib/eunit/src/eunit_tty.erl +272 -0
- data/lib/erlang/messenger/lib/eunit/src/file_monitor.erl +409 -0
- data/lib/erlang/messenger/lib/eunit/sys.config +9 -0
- data/lib/erlang/messenger/lib/eunit/vsn.mk +1 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_master_rel-0.1.script +242 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.boot +0 -0
- data/lib/erlang/messenger/pm_node_rel-0.1.script +242 -0
- data/lib/erlang/messenger/src/master_app.erl +39 -0
- data/lib/erlang/messenger/src/node_app.erl +39 -0
- data/lib/erlang/messenger/src/pm_client.erl +19 -0
- data/lib/erlang/messenger/src/pm_cluster.erl +57 -0
- data/lib/erlang/messenger/src/pm_event_handler.erl +21 -0
- data/lib/erlang/messenger/src/pm_master.erl +118 -0
- data/lib/erlang/messenger/src/pm_master_supervisor.erl +40 -0
- data/lib/erlang/messenger/src/pm_node.erl +124 -0
- data/lib/erlang/messenger/src/pm_node_supervisor.erl +40 -0
- data/lib/erlang/messenger/src/pm_packager.erl +73 -0
- data/lib/erlang/messenger/src/utils.erl +38 -0
- data/lib/poolparty/base_packages/haproxy.rb +9 -2
- data/lib/poolparty/base_packages/heartbeat.rb +40 -28
- data/lib/poolparty/base_packages/poolparty.rb +39 -16
- data/lib/poolparty/base_packages/ruby.rb +2 -3
- data/lib/poolparty/config/allowed_commands.yml +1 -0
- data/lib/poolparty/core/array.rb +5 -2
- data/lib/poolparty/core/hash.rb +16 -2
- data/lib/poolparty/core/string.rb +9 -2
- data/lib/poolparty/core/symbol.rb +2 -2
- data/lib/poolparty/dependency_resolutions/base.rb +12 -0
- data/lib/poolparty/dependency_resolutions/puppet.rb +49 -0
- data/lib/poolparty/exceptions/UnacceptableCommand.rb +5 -0
- data/lib/poolparty/helpers/console.rb +3 -2
- data/lib/poolparty/helpers/display.rb +3 -3
- data/lib/poolparty/helpers/messenger.rb +29 -0
- data/lib/poolparty/helpers/optioner.rb +6 -2
- data/lib/poolparty/helpers/provisioner_base.rb +18 -11
- data/lib/poolparty/helpers/provisioners/master.rb +24 -22
- data/lib/poolparty/helpers/provisioners/slave.rb +8 -4
- data/lib/poolparty/modules/definable_resource.rb +1 -0
- data/lib/poolparty/modules/file_writer.rb +11 -10
- data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
- data/lib/poolparty/modules/pretty_printer.rb +11 -11
- data/lib/poolparty/modules/resourcing_dsl.rb +61 -0
- data/lib/poolparty/monitors/base_monitor.rb +17 -3
- data/lib/poolparty/monitors/monitors/cpu_monitor.rb +15 -0
- data/lib/poolparty/monitors/monitors/memory_monitor.rb +23 -0
- data/lib/poolparty/net/remote_instance.rb +6 -1
- data/lib/poolparty/net/remoter.rb +23 -5
- data/lib/poolparty/net/remoter_base.rb +5 -1
- data/lib/poolparty/plugins/git.rb +22 -24
- data/lib/poolparty/pool/base.rb +22 -6
- data/lib/poolparty/pool/cloud.rb +28 -4
- data/lib/poolparty/pool/custom_resource.rb +6 -6
- data/lib/poolparty/pool/loggable.rb +3 -0
- data/lib/poolparty/pool/pool.rb +1 -1
- data/lib/poolparty/pool/resource.rb +58 -94
- data/lib/poolparty/pool/resources/class_package.rb +6 -6
- data/lib/poolparty/pool/resources/conditional.rb +5 -1
- data/lib/poolparty/pool/resources/exec.rb +6 -2
- data/lib/poolparty/pool/resources/gem.rb +22 -8
- data/lib/poolparty/pool/resources/remote_file.rb +5 -1
- data/lib/poolparty/pool/resources/symlink.rb +25 -0
- data/lib/poolparty/pool/resources/variable.rb +8 -7
- data/lib/poolparty/pool/tmp/.ppkeys +3 -0
- data/lib/poolparty/pool/tmp/happydayz +1 -0
- data/lib/poolparty/pool/tmp/install_master.sh +33 -0
- data/lib/poolparty/pool/tmp/pool.spec +11 -0
- data/lib/poolparty/pool/tmp/poolparty.pp +600 -0
- data/lib/poolparty/pool/tmp/tc-instances.list +1 -0
- data/lib/poolparty/templates/cib.xml +54 -0
- data/lib/poolparty/templates/ha.cf +12 -3
- data/lib/poolparty/templates/haproxy.conf +3 -3
- data/lib/poolparty/templates/haresources +3 -0
- data/lib/poolparty/templates/poolparty.monitor +14 -0
- data/lib/poolparty/templates/puppet.conf +3 -4
- data/lib/poolparty/version.rb +1 -1
- data/lib/poolparty.rb +9 -6
- data/poolparty.gemspec +7 -6
- data/setup.rb +3 -3
- data/spec/poolparty/bin/console_spec.rb +1 -1
- data/spec/poolparty/core/array_spec.rb +5 -0
- data/spec/poolparty/core/hash_spec.rb +19 -1
- data/spec/poolparty/core/string_spec.rb +13 -0
- data/spec/poolparty/dependency_resolutions/base_spec.rb +11 -0
- data/spec/poolparty/helpers/messenger_spec.rb +14 -0
- data/spec/poolparty/helpers/optioner_spec.rb +2 -1
- data/spec/poolparty/helpers/provisioner_base_spec.rb +1 -1
- data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +3 -3
- data/spec/poolparty/modules/file_writer_spec.rb +9 -0
- data/spec/poolparty/monitors/base_monitor_spec.rb +19 -0
- data/spec/poolparty/monitors/monitors/cpu_monitor_spec.rb +17 -0
- data/spec/poolparty/net/remote_instance_spec.rb +6 -1
- data/spec/poolparty/net/remote_spec.rb +51 -42
- data/spec/poolparty/net/remoter_spec.rb +2 -1
- data/spec/poolparty/plugins/git_spec.rb +2 -2
- data/spec/poolparty/pool/base_spec.rb +20 -2
- data/spec/poolparty/pool/cloud_spec.rb +30 -1
- data/spec/poolparty/pool/custom_resource_spec.rb +2 -2
- data/spec/poolparty/pool/plugin_spec.rb +4 -4
- data/spec/poolparty/pool/pool_spec.rb +1 -1
- data/spec/poolparty/pool/resource_spec.rb +66 -0
- data/spec/poolparty/pool/resources/gem_spec.rb +29 -3
- data/spec/poolparty/pool/resources/symlink_spec.rb +22 -0
- data/spec/poolparty/pool/resources/variable_spec.rb +4 -0
- data/spec/poolparty/spec_helper.rb +5 -0
- data/tasks/cloud.rake +0 -54
- data/tasks/development.rake +0 -12
- data/tasks/ec2.rake +1 -16
- data/tasks/instance.rake +0 -61
- data/test_manifest.pp +286 -166
- data/website/index.html +5 -5
- data/website/index.txt +3 -3
- metadata +137 -8
- data/bin/pool-start-monitor +0 -1
- data/lib/erlang/eb_server.erl +0 -27
- data/lib/poolparty/plugins/gem_package.rb +0 -17
- data/spec/poolparty/modules/tmp/willy/nilly.rb +0 -1
@@ -3,38 +3,36 @@ module PoolParty
|
|
3
3
|
|
4
4
|
virtual_resource(:git) do
|
5
5
|
|
6
|
-
def loaded(opts={})
|
7
|
-
install_git
|
6
|
+
def loaded(opts={}, parent=self)
|
8
7
|
has_git_repos
|
9
8
|
end
|
10
|
-
|
11
|
-
def install_git
|
12
|
-
has_package(:name => "git-core")
|
13
|
-
end
|
14
|
-
|
9
|
+
|
15
10
|
def has_git_repos
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
exec(:name => "git-update-#{name}", :cwd => "#{path}") do
|
11
|
+
exec({:name => "git-#{name}"}) do
|
12
|
+
command parent.user ? "git clone #{parent.user}@#{parent.source} #{parent.path}" : "git clone #{parent.source} #{parent.to ? parent.to : ""}"
|
13
|
+
cwd "#{parent.cwd if parent.cwd}"
|
14
|
+
creates "#{::File.join( (parent.cwd ? parent.cwd : cwd), ::File.basename(parent.source, ::File.extname(parent.source)) )}/.git"
|
15
|
+
|
16
|
+
exec(:name => "update-#{name}") do
|
17
|
+
cwd ::File.dirname(parent.creates)
|
26
18
|
command "git pull"
|
27
|
-
requires "Exec['git-#{@parent.name}']"
|
28
|
-
end
|
29
|
-
|
30
|
-
if symlink
|
31
|
-
has_file(:name => "#{symlink}") do
|
32
|
-
ensures @parent.path
|
33
|
-
end
|
34
19
|
end
|
20
|
+
|
35
21
|
end
|
36
22
|
end
|
37
23
|
|
24
|
+
# Since git is not a native type, we have to say which core resource
|
25
|
+
# it is using to be able to require it
|
26
|
+
def class_type_name
|
27
|
+
"exec"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Because we are requiring an exec, instead of a built-in package of the git, we have to overload
|
31
|
+
# the to_s method and prepend it with the same name as above
|
32
|
+
def key
|
33
|
+
"git-#{name}"
|
34
|
+
end
|
35
|
+
|
38
36
|
end
|
39
37
|
|
40
38
|
end
|
data/lib/poolparty/pool/base.rb
CHANGED
@@ -13,18 +13,17 @@ module PoolParty
|
|
13
13
|
:environment => "production",
|
14
14
|
:user => "root", # This should change here
|
15
15
|
:base_keypair_path => "~/.ec2",
|
16
|
-
:tmp_path => "tmp",
|
17
|
-
:remote_storage_path => "/var/poolparty",
|
18
|
-
:storage_directory => File.join(Dir.pwd, "tmp"),
|
16
|
+
:tmp_path => "/tmp/poolparty",
|
17
|
+
:remote_storage_path => "/var/poolparty",
|
19
18
|
:fileserver_base => "puppet:///files",
|
20
19
|
:base_config_directory => "/etc/poolparty",
|
21
|
-
:template_directory => "
|
20
|
+
:template_directory => "templates",
|
22
21
|
:template_path => "/var/lib/puppet/templates",
|
22
|
+
:module_path => "/etc/puppet/modules/poolparty",
|
23
23
|
:default_specfile_name => "pool.spec",
|
24
24
|
:port => "80",
|
25
25
|
:forwarding_port => "8080",
|
26
|
-
:proxy_mode => "http",
|
27
|
-
:pool_logger_location => File.join(Dir.pwd, "logs"),
|
26
|
+
:proxy_mode => "http",
|
28
27
|
# EC2 Options
|
29
28
|
:ami => "ami-1cd73375"
|
30
29
|
})
|
@@ -69,6 +68,23 @@ module PoolParty
|
|
69
68
|
"ppkeys"
|
70
69
|
]
|
71
70
|
end
|
71
|
+
|
72
|
+
def storage_directory
|
73
|
+
[
|
74
|
+
"/var/poolparty"
|
75
|
+
].select do |dir|
|
76
|
+
dir if ::File.directory?(dir) && ::File.readable?(dir)
|
77
|
+
end.first || ::File.join( "/tmp/poolparty")
|
78
|
+
end
|
79
|
+
|
80
|
+
def pool_logger_location
|
81
|
+
File.join(Dir.pwd, "logs")
|
82
|
+
end
|
83
|
+
|
84
|
+
# Array of allowed_commands that you can run on the remote nodes
|
85
|
+
def allowed_commands
|
86
|
+
@allowed_commands ||= open(::File.join( ::File.dirname(__FILE__), "..", "config", "allowed_commands.yml")).read.split(/\n/).map {|a| a.chomp }
|
87
|
+
end
|
72
88
|
|
73
89
|
end
|
74
90
|
end
|
data/lib/poolparty/pool/cloud.rb
CHANGED
@@ -47,18 +47,21 @@ module PoolParty
|
|
47
47
|
# this can be overridden in the spec, but ec2 is the default
|
48
48
|
self.using :ec2
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
# Keypairs
|
52
52
|
# If the parent (pool) doesn't have a keypair defined on it, then generate one based on the
|
53
53
|
# pool_name and the cloud_name
|
54
54
|
def keypair(*args)
|
55
55
|
has_keypair? ? options[:keypair] : generate_keypair(*args)
|
56
56
|
end
|
57
|
+
# Let's just make sure that the keypair exists on the options
|
57
58
|
def has_keypair?
|
58
59
|
options.has_key?(:keypair) && options[:keypair]
|
59
60
|
end
|
61
|
+
# Generate a keypair based on the parent's name (if there is a parent)
|
62
|
+
# and the cloud's name
|
60
63
|
def generate_keypair(*args)
|
61
|
-
options[:keypair] = args.length > 0 ? args[0] : "#{@parent.respond_to?(:name) ? @parent.name : ""}_#{@name}"
|
64
|
+
options[:keypair] = args.length > 0 ? args[0] : "#{@parent && @parent.respond_to?(:name) ? @parent.name : ""}_#{@name}"
|
62
65
|
end
|
63
66
|
|
64
67
|
# Prepare to send the new configuration to the instances
|
@@ -104,13 +107,14 @@ module PoolParty
|
|
104
107
|
copy_file_to_storage_directory(::File.join(::File.dirname(__FILE__), "..", "templates", f))
|
105
108
|
end
|
106
109
|
end
|
107
|
-
|
110
|
+
|
108
111
|
# Configuration files
|
109
112
|
def build_manifest
|
113
|
+
@build_manifest ||= build_from_existing_file
|
110
114
|
unless @build_manifest
|
111
115
|
reset_resources!
|
112
116
|
add_poolparty_base_requirements
|
113
|
-
|
117
|
+
|
114
118
|
@build_manifest = returning Array.new do |str|
|
115
119
|
|
116
120
|
str << resources_string_from_resources(resources)
|
@@ -130,6 +134,14 @@ module PoolParty
|
|
130
134
|
@build_manifest
|
131
135
|
end
|
132
136
|
|
137
|
+
def build_from_existing_file
|
138
|
+
if ::FileTest.file?("/etc/puppet/manifests/classes/poolparty.pp")
|
139
|
+
open("/etc/puppet/manifests/classes/poolparty.pp").read
|
140
|
+
else
|
141
|
+
nil
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
133
145
|
# To allow the remote instances to do their job,
|
134
146
|
# they need a few options to run, these are the required options
|
135
147
|
# to be saved on the remote "master" machine
|
@@ -149,6 +161,18 @@ module PoolParty
|
|
149
161
|
ruby
|
150
162
|
poolparty
|
151
163
|
end
|
164
|
+
|
165
|
+
def provisioning?
|
166
|
+
@provisioning_in_progress == true
|
167
|
+
end
|
168
|
+
|
169
|
+
def provisioning_in_progress
|
170
|
+
@provisioning_in_progress = true
|
171
|
+
end
|
172
|
+
|
173
|
+
def provisioning_complete
|
174
|
+
@provisioning_in_progress = false
|
175
|
+
end
|
152
176
|
|
153
177
|
# Add to the services pool for the manifest listing
|
154
178
|
def add_service(serv)
|
@@ -22,11 +22,11 @@ module PoolParty
|
|
22
22
|
class CallFunction < Resource
|
23
23
|
def initialize(str="", opts={}, parent=self, &block)
|
24
24
|
@str = str
|
25
|
-
super(opts, parent, &block)
|
25
|
+
# super(opts, parent, &block)
|
26
26
|
end
|
27
|
-
def to_string(
|
27
|
+
def to_string(pre="")
|
28
28
|
returning Array.new do |arr|
|
29
|
-
arr << "#{
|
29
|
+
arr << "#{pre}#{@str}"
|
30
30
|
end.join("\n")
|
31
31
|
end
|
32
32
|
end
|
@@ -42,10 +42,10 @@ module PoolParty
|
|
42
42
|
super(subclass)
|
43
43
|
end
|
44
44
|
|
45
|
-
def to_string(
|
45
|
+
def to_string(pre="")
|
46
46
|
returning Array.new do |output|
|
47
|
-
output << "#{
|
48
|
-
output << self.class.custom_functions_to_string(
|
47
|
+
output << "#{pre} # Custom Functions\n"
|
48
|
+
output << self.class.custom_functions_to_string(pre)
|
49
49
|
end.join("\n")
|
50
50
|
end
|
51
51
|
end
|
data/lib/poolparty/pool/pool.rb
CHANGED
@@ -17,14 +17,19 @@ module PoolParty
|
|
17
17
|
resources[type] ||= []
|
18
18
|
end
|
19
19
|
|
20
|
-
def add_resource(type, opts={}, parent=self, &block)
|
21
|
-
|
22
|
-
|
20
|
+
def add_resource(type, opts={}, parent=self, &block)
|
21
|
+
resource = get_resource(type, opts[:name], parent)
|
22
|
+
if resource
|
23
|
+
resource
|
24
|
+
else
|
25
|
+
returning "PoolParty::Resources::#{type.to_s.camelize}".classify.constantize.new(opts, parent, &block) do |o|
|
26
|
+
resource(type) << o
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
26
|
-
def get_resource(type,
|
27
|
-
resource(type).select {|resource| resource.
|
31
|
+
def get_resource(type, key, parent=self)
|
32
|
+
resource(type).select {|resource| resource.key == key }.first
|
28
33
|
end
|
29
34
|
|
30
35
|
#:nodoc:
|
@@ -32,11 +37,11 @@ module PoolParty
|
|
32
37
|
@resources = nil
|
33
38
|
end
|
34
39
|
|
35
|
-
def resources_string(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
+
# def resources_string(pre="")
|
41
|
+
# returning Array.new do |output|
|
42
|
+
# output << resources_string_from_resources(resources)
|
43
|
+
# end.join("\n")
|
44
|
+
# end
|
40
45
|
|
41
46
|
def custom_file(path, str)
|
42
47
|
write_to_file_in_storage_directory(path, str)
|
@@ -56,11 +61,11 @@ module PoolParty
|
|
56
61
|
lowercase_class_name = subclass.to_s.downcase
|
57
62
|
|
58
63
|
# Add add resource method to the Resources module
|
59
|
-
unless PoolParty::Resources.respond_to?(lowercase_class_name.to_sym)
|
64
|
+
unless PoolParty::Resources.respond_to?(lowercase_class_name.to_sym)
|
60
65
|
method =<<-EOE
|
61
66
|
def #{lowercase_class_name}(opts={}, parent=self, &blk)
|
62
67
|
add_resource(:#{lowercase_class_name}, opts, parent, &blk)
|
63
|
-
end
|
68
|
+
end
|
64
69
|
EOE
|
65
70
|
PoolParty::Resources.module_eval method
|
66
71
|
PoolParty::Resources.add_has_and_does_not_have_methods_for(lowercase_class_name.to_sym)
|
@@ -85,64 +90,39 @@ module PoolParty
|
|
85
90
|
# Finally, it uses the parent's options as the lowest priority
|
86
91
|
def initialize(opts={}, parent=self, &block)
|
87
92
|
# Take the options of the parents
|
88
|
-
|
93
|
+
set_resource_parent(parent)
|
89
94
|
set_vars_from_options(opts) unless opts.empty?
|
90
95
|
self.instance_eval &block if block
|
91
|
-
loaded(opts)
|
96
|
+
loaded(opts, @parent)
|
97
|
+
end
|
98
|
+
|
99
|
+
def set_resource_parent(parent=nil)
|
100
|
+
if parent && parent != self
|
101
|
+
@parent = parent
|
102
|
+
requires parent.to_s if @parent.is_a?(PoolParty::Resources::Resource) && printable? && @parent.printable?
|
103
|
+
end
|
92
104
|
end
|
93
105
|
|
106
|
+
# def requirement_tree
|
107
|
+
# p = @parent
|
108
|
+
# returning Array.new do |arr|
|
109
|
+
# arr << p.to_s
|
110
|
+
# while p && p != self && p.is_a?(PoolParty::Resources::Resource) && p.requires
|
111
|
+
# arr << p.requires
|
112
|
+
# p = p.parent
|
113
|
+
# end
|
114
|
+
# end.flatten.uniq
|
115
|
+
# end
|
116
|
+
|
94
117
|
# Stub, so you can create virtual resources
|
95
|
-
|
118
|
+
# This is called after the resource is initialized
|
119
|
+
# with the options given to it in the init-block
|
120
|
+
def loaded(opts={}, parent=self)
|
96
121
|
end
|
97
122
|
|
98
123
|
# DSL Overriders
|
99
|
-
|
100
|
-
# Allows us to send require to require a resource
|
101
|
-
def require(str="")
|
102
|
-
options[:require]
|
103
|
-
end
|
104
|
-
def requires(str="")
|
105
|
-
options.merge!(:require => str)
|
106
|
-
end
|
107
|
-
def ensures(str="running")
|
108
|
-
if %w(absent running).map {|a| self.send a.to_sym}.include?(str)
|
109
|
-
str == "absent" ? is_absent : is_present
|
110
|
-
else
|
111
|
-
options.merge!(:ensure => str)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
# Allows us to send an ensure to ensure the presence of a resource
|
115
|
-
def is_present(*args)
|
116
|
-
options.merge!(:ensure => present)
|
117
|
-
end
|
118
|
-
# Ensures that what we are sending is absent
|
119
|
-
def is_absent(*args)
|
120
|
-
options.merge!(:ensure => absent)
|
121
|
-
end
|
122
|
-
# Alias for unless
|
123
|
-
def ifnot(str="")
|
124
|
-
options.merge!(:unless => str)
|
125
|
-
end
|
126
|
-
def present
|
127
|
-
"present"
|
128
|
-
end
|
129
|
-
def absent
|
130
|
-
"absent"
|
131
|
-
end
|
124
|
+
include PoolParty::ResourcingDsl
|
132
125
|
|
133
|
-
# Give us a template to work with on the resource
|
134
|
-
# Make sure this template is moved to the tmp directory as well
|
135
|
-
def template(file, opts={})
|
136
|
-
raise TemplateNotFound.new("no template given") unless file
|
137
|
-
raise TemplateNotFound.new("template cannot be found #{file}") unless ::File.file?(file)
|
138
|
-
unless opts[:just_copy]
|
139
|
-
options.merge!({:content => "template(\"#{::File.basename(file)}\")"})
|
140
|
-
options.delete(:source) if options.has_key?(:source)
|
141
|
-
copy_template_to_storage_directory(file)
|
142
|
-
else
|
143
|
-
copy_file_to_storage_directory(file)
|
144
|
-
end
|
145
|
-
end
|
146
126
|
# This way we can subclass resources without worry
|
147
127
|
def class_type_name
|
148
128
|
self.class.to_s.top_level_class
|
@@ -161,11 +141,11 @@ module PoolParty
|
|
161
141
|
self.class.custom_functions << str
|
162
142
|
end
|
163
143
|
|
164
|
-
def self.custom_functions_to_string(
|
144
|
+
def self.custom_functions_to_string(pre="")
|
165
145
|
returning Array.new do |output|
|
166
146
|
PoolParty::Resources.available_custom_resources.each do |resource|
|
167
147
|
resource.custom_functions.each do |func|
|
168
|
-
output << "#{
|
148
|
+
output << "#{pre*2}#{func}"
|
169
149
|
end
|
170
150
|
end
|
171
151
|
end.join("\n")
|
@@ -180,47 +160,31 @@ module PoolParty
|
|
180
160
|
def virtual_resource?
|
181
161
|
false
|
182
162
|
end
|
163
|
+
def printable?
|
164
|
+
true
|
165
|
+
end
|
183
166
|
# We want to gather the options, but if the option sent is nil
|
184
167
|
# then we want to override the option value by sending the key as
|
185
168
|
# a method so that we can override this if necessary.
|
186
169
|
# Only runs on objects that have options defined, otherwise
|
187
170
|
# it returns an empty hash
|
188
171
|
def get_modified_options
|
189
|
-
|
190
|
-
|
191
|
-
|
172
|
+
unless @modified_options
|
173
|
+
if options
|
174
|
+
opts = options.inject({}) do |sum,h|
|
175
|
+
sum.merge!({h[0].to_sym => ((h[1].nil?) ? self.send(h[0].to_sym) : h[1]) })
|
176
|
+
end
|
177
|
+
else
|
178
|
+
opts = {}
|
192
179
|
end
|
193
|
-
|
194
|
-
opts = {}
|
180
|
+
@modified_options = opts.reject {|k,v| disallowed_options.include?(k) }
|
195
181
|
end
|
196
|
-
|
182
|
+
@modified_options
|
197
183
|
end
|
198
184
|
|
199
|
-
#
|
200
|
-
#
|
201
|
-
|
202
|
-
opts = get_modified_options
|
203
|
-
returning Array.new do |output|
|
204
|
-
|
205
|
-
output << @prestring || ""
|
206
|
-
|
207
|
-
if resources && !resources.empty?
|
208
|
-
@cp = classpackage_with_self(self)
|
209
|
-
output << @cp.to_string
|
210
|
-
output << "include #{@cp.name.sanitize}"
|
211
|
-
end
|
212
|
-
|
213
|
-
unless virtual_resource?
|
214
|
-
output << "#{prev}#{class_type_name} {"
|
215
|
-
output << "#{prev}\"#{self.key}\":"
|
216
|
-
output << opts.flush_out("#{prev*2}").join(",\n")
|
217
|
-
output << "#{prev}}"
|
218
|
-
end
|
219
|
-
|
220
|
-
output << @poststring || ""
|
221
|
-
|
222
|
-
end.join("\n")
|
223
|
-
end
|
185
|
+
# For the time being, we'll make puppet the only available dependency resolution
|
186
|
+
# base, but in the future, we can rip this out and make it an option
|
187
|
+
include PoolParty::DependencyResolutions::Puppet
|
224
188
|
end
|
225
189
|
|
226
190
|
# Adds two methods to the module
|
@@ -27,14 +27,14 @@ module PoolParty
|
|
27
27
|
def to_string
|
28
28
|
returning String.new do |output|
|
29
29
|
output << "# #{name.sanitize}"
|
30
|
-
output << "\nclass #{name.sanitize} {\n"
|
30
|
+
output << "\nclass #{name.sanitize.downcase} {\n"
|
31
31
|
output << resources_string_from_resources(resources)
|
32
32
|
output << "\n}\n"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def include_string
|
37
|
-
"include #{name.sanitize}"
|
37
|
+
"include #{name.sanitize.downcase}"
|
38
38
|
end
|
39
39
|
|
40
40
|
def name(*args)
|
@@ -43,19 +43,19 @@ module PoolParty
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
def resources_string_from_resources(resources,
|
46
|
+
def resources_string_from_resources(resources, pre="\t")
|
47
47
|
@variables = resources.extract! {|name,resource| name == :variable}
|
48
48
|
returning Array.new do |str|
|
49
49
|
unless @variables.empty?
|
50
50
|
str << "\n# Variables \n"
|
51
51
|
@variables.each do |name, variable|
|
52
|
-
str << variable.to_string("#{
|
52
|
+
str << variable.to_string("#{pre}")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
resources.each do |type, resource|
|
57
|
-
str << "\n#{
|
58
|
-
str << resource.to_string("#{
|
57
|
+
str << "\n#{pre*2}# #{type}\n"
|
58
|
+
str << resource.to_string("#{pre*2}")
|
59
59
|
end
|
60
60
|
end.join("\n")
|
61
61
|
end
|
@@ -7,9 +7,13 @@ module PoolParty
|
|
7
7
|
:path => "/usr/bin:/bin:/usr/local/bin:$PATH"
|
8
8
|
})
|
9
9
|
|
10
|
-
|
10
|
+
# Execs cannot have the following parameters
|
11
|
+
# We use version in the gempackage resource
|
12
|
+
# So we have to exclude it here. Alternatively, we could
|
13
|
+
# exclude it in the gempackage, but this is an example
|
14
|
+
# of how to exclude it as well
|
11
15
|
def disallowed_options
|
12
|
-
[:ensure, :name]
|
16
|
+
[:ensure, :name, :source, :version]
|
13
17
|
end
|
14
18
|
|
15
19
|
def key
|
@@ -1,14 +1,28 @@
|
|
1
1
|
module PoolParty
|
2
2
|
module Resources
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
|
4
|
+
class Gempackage < Resource
|
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
|
+
def loaded(opts={}, parent=self)
|
10
|
+
has_exec(opts.merge({:name => name, :cwd => "/tmp", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin"}), parent) do
|
11
|
+
command "gem install -y --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name}"
|
12
|
+
ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def virtual_resource?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
def printable?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
def class_type_name
|
22
|
+
"Exec"
|
23
|
+
end
|
24
|
+
|
9
25
|
end
|
10
26
|
|
11
|
-
add_has_and_does_not_have_methods_for(:gem)
|
12
|
-
|
13
27
|
end
|
14
28
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module PoolParty
|
2
2
|
module Resources
|
3
3
|
|
4
|
-
class Remotefile <
|
4
|
+
class Remotefile < Resource
|
5
5
|
# Not really my favorite of lines
|
6
6
|
include PoolParty::Configurable
|
7
7
|
|
@@ -16,6 +16,10 @@ module PoolParty
|
|
16
16
|
"file"
|
17
17
|
end
|
18
18
|
|
19
|
+
def source(arg=nil)
|
20
|
+
arg ? options[:source] = arg : "#{Base.fileserver_base}/#{::File.basename(name)}"
|
21
|
+
end
|
22
|
+
|
19
23
|
end
|
20
24
|
|
21
25
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module PoolParty
|
2
|
+
module Resources
|
3
|
+
|
4
|
+
class Symlink < Resource
|
5
|
+
|
6
|
+
def class_type_name
|
7
|
+
"file"
|
8
|
+
end
|
9
|
+
|
10
|
+
def disallowed_options
|
11
|
+
[:name, :source]
|
12
|
+
end
|
13
|
+
|
14
|
+
def present
|
15
|
+
source
|
16
|
+
end
|
17
|
+
|
18
|
+
def printable?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -8,17 +8,18 @@ module PoolParty
|
|
8
8
|
:value => ""
|
9
9
|
})
|
10
10
|
|
11
|
-
def to_string(
|
11
|
+
def to_string(pre="\t")
|
12
12
|
"$#{name} = #{value_string}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def value_string
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
value.to_option_string
|
17
|
+
# case value.class.to_s
|
18
|
+
# when "Array"
|
19
|
+
# "[ #{value.map{|a| "'#{a}'"}.join(", ")} ]"
|
20
|
+
# else
|
21
|
+
# "'#{value}'"
|
22
|
+
# end
|
22
23
|
end
|
23
24
|
|
24
25
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
write this text
|