auser-poolparty 0.2.58 → 0.2.59
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/lib/poolparty/base_packages/poolparty.rb +8 -3
- data/lib/poolparty/core/string.rb +3 -0
- data/lib/poolparty/helpers/provisioner_base.rb +4 -2
- data/lib/poolparty/helpers/provisioners/master.rb +33 -14
- data/lib/poolparty/helpers/provisioners/slave.rb +8 -2
- data/lib/poolparty/modules/cloud_dsl.rb +1 -1
- data/lib/poolparty/modules/cloud_resourcer.rb +5 -0
- data/lib/poolparty/modules/file_writer.rb +3 -2
- data/lib/poolparty/monitors/base_monitor.rb +2 -1
- data/lib/poolparty/net/remote_bases/ec2.rb +5 -4
- data/lib/poolparty/net/remote_instance.rb +3 -3
- data/lib/poolparty/net/remoter.rb +9 -0
- data/lib/poolparty/net/remoter_base.rb +14 -4
- data/lib/poolparty/plugins/deploydirectory.rb +18 -9
- data/lib/poolparty/plugins/line.rb +2 -1
- data/lib/poolparty/plugins/rsyncmirror.rb +3 -6
- data/lib/poolparty/pool/cloud.rb +9 -2
- data/lib/poolparty/pool/pool.rb +4 -3
- data/lib/poolparty/pool/resource.rb +9 -1
- data/lib/poolparty/pool/resources/conditional.rb +13 -7
- data/lib/poolparty/templates/haproxy.conf +1 -1
- data/lib/poolparty/templates/puppetrerun +16 -1
- data/lib/poolparty/templates/puppetrunner +15 -0
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +3 -2
- data/spec/poolparty/helpers/provisioners/master_spec.rb +1 -1
- data/spec/poolparty/net/remote_instance_spec.rb +1 -1
- data/spec/poolparty/net/remoter_base_spec.rb +1 -1
- data/spec/poolparty/plugins/deploydirectory_spec.rb +8 -1
- data/spec/poolparty/pool/cloud_spec.rb +1 -1
- data/spec/poolparty/pool/pool_spec.rb +1 -1
- data/spec/poolparty/pool/resources/conditional_spec.rb +13 -1
- metadata +3 -2
data/Manifest.txt
CHANGED
@@ -273,6 +273,7 @@ lib/poolparty/templates/poolparty.monitor
|
|
273
273
|
lib/poolparty/templates/puppet.conf
|
274
274
|
lib/poolparty/templates/puppetcleaner
|
275
275
|
lib/poolparty/templates/puppetrerun
|
276
|
+
lib/poolparty/templates/puppetrunner
|
276
277
|
lib/poolparty/templates/yaws.conf
|
277
278
|
lib/poolparty/version.rb
|
278
279
|
lib/poolpartycl.rb
|
@@ -6,9 +6,10 @@ module PoolParty
|
|
6
6
|
# Build hostsfile
|
7
7
|
# TODO: COME BACK AND CLEAN THIS UP
|
8
8
|
(self.respond_to?(:list_of_running_instances) ? self : parent).list_of_running_instances.each do |ri|
|
9
|
-
has_host({:name => "
|
9
|
+
has_host({:name => "#{ri.name}", :ip => ri.ip})
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
# has_host({:name => "$hostname", :ip => "127.0.0.1", :alias => "localhost"})
|
12
13
|
|
13
14
|
has_package(:name => "erlang")
|
14
15
|
has_package(:name => "erlang-dev")
|
@@ -50,7 +51,7 @@ module PoolParty
|
|
50
51
|
# execute_on_node do
|
51
52
|
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
52
53
|
requires get_gempackage("poolparty")
|
53
|
-
command
|
54
|
+
command "/usr/bin/puppetrun"
|
54
55
|
end
|
55
56
|
# end
|
56
57
|
|
@@ -97,6 +98,10 @@ module PoolParty
|
|
97
98
|
mode 744
|
98
99
|
template File.join(File.dirname(__FILE__), "..", "templates/puppetrerun")
|
99
100
|
end
|
101
|
+
has_remotefile(:name => "/usr/bin/puppetrunner") do
|
102
|
+
mode 744
|
103
|
+
template File.join(File.dirname(__FILE__), "..", "templates/puppetrunner")
|
104
|
+
end
|
100
105
|
|
101
106
|
# has_host(:name => "puppet", :ip => (self.respond_to?(:master) ? self : parent).master.ip)
|
102
107
|
end
|
@@ -275,7 +275,10 @@ module PoolParty
|
|
275
275
|
end
|
276
276
|
|
277
277
|
def fix_rubygems
|
278
|
-
|
278
|
+
<<-EOE
|
279
|
+
#{installer_for("ruby rubygems")}
|
280
|
+
echo '#{open(::File.join(template_directory, "gem")).read}' > /usr/bin/gem
|
281
|
+
EOE
|
279
282
|
end
|
280
283
|
|
281
284
|
def create_local_node
|
@@ -306,7 +309,6 @@ aptitude update -y #{unix_hide_string} <<heredoc
|
|
306
309
|
Y
|
307
310
|
|
308
311
|
heredoc
|
309
|
-
aptitude autoclean #{unix_hide_string}
|
310
312
|
fi
|
311
313
|
"
|
312
314
|
else
|
@@ -25,9 +25,9 @@ module PoolParty
|
|
25
25
|
setup_autosigning,
|
26
26
|
install_poolparty,
|
27
27
|
setup_poolparty,
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
create_local_node,
|
29
|
+
run_first_time,
|
30
|
+
restart_puppetmaster
|
31
31
|
] << configure_tasks
|
32
32
|
end
|
33
33
|
|
@@ -43,12 +43,14 @@ module PoolParty
|
|
43
43
|
# If the master is not in the hosts file, then add it to the hosts file
|
44
44
|
def create_local_hosts_entry
|
45
45
|
<<-EOS
|
46
|
-
|
46
|
+
echo "Creating local host entry"
|
47
|
+
if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')" ]; then echo '#{@master_ip} puppet master localhost' >> /etc/hosts; fi
|
47
48
|
EOS
|
48
49
|
end
|
49
50
|
|
50
51
|
def setup_basic_structure
|
51
52
|
<<-EOS
|
53
|
+
echo "Creating basic structure for poolparty"
|
52
54
|
mkdir -p /etc/puppet/manifests/nodes
|
53
55
|
mkdir -p /etc/puppet/manifests/classes
|
54
56
|
echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp
|
@@ -59,12 +61,14 @@ cp #{Base.remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
|
|
59
61
|
|
60
62
|
def setup_configs
|
61
63
|
<<-EOS
|
64
|
+
echo "Setting up configuration"
|
62
65
|
echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/puppet.conf
|
63
66
|
EOS
|
64
67
|
end
|
65
68
|
|
66
69
|
def setup_fileserver
|
67
70
|
<<-EOS
|
71
|
+
echo "Setting up the master fileserver"
|
68
72
|
echo "
|
69
73
|
[files]
|
70
74
|
path #{Base.remote_storage_path}
|
@@ -77,12 +81,14 @@ mkdir -p /etc/poolparty
|
|
77
81
|
# Change this eventually for better security supportsetup_fileserver
|
78
82
|
def setup_autosigning
|
79
83
|
<<-EOS
|
84
|
+
echo "Creating accessibility for the nodes"
|
80
85
|
echo "*" > /etc/puppet/autosign.conf
|
81
86
|
EOS
|
82
87
|
end
|
83
88
|
|
84
89
|
def setup_poolparty
|
85
90
|
<<-EOS
|
91
|
+
echo "Setting the poolparty configuration"
|
86
92
|
cp #{Base.remote_storage_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
|
87
93
|
cp #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/#{Base.default_specfile_name}
|
88
94
|
EOS
|
@@ -94,7 +100,7 @@ cp #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_
|
|
94
100
|
|
95
101
|
def install_poolparty
|
96
102
|
<<-EOE
|
97
|
-
|
103
|
+
echo "Installing poolparty"
|
98
104
|
cd /var/poolparty
|
99
105
|
wget http://rubyforge.org/frs/download.php/44731/logging-0.9.4.gem -O logging.gem 2>&1
|
100
106
|
wget http://rubyforge.org/frs/download.php/45581/ZenTest-3.11.0.gem -O ZenTest.gem 2>&1
|
@@ -123,17 +129,26 @@ wget http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem -O amazon-
|
|
123
129
|
|
124
130
|
# ps aux | grep puppetmasterd | awk '{print $2}' | xargs kill
|
125
131
|
# /etc/init.d/puppetmaster stop; rm -rf /etc/puppet/ssl; /etc/init.d/puppetmaster start
|
126
|
-
def
|
132
|
+
def restart_puppetmaster
|
127
133
|
<<-EOS
|
134
|
+
echo "(Re)starting poolparty"
|
128
135
|
. /etc/profile
|
129
|
-
|
136
|
+
/etc/init.d/puppetmaster stop #{unix_hide_string}
|
130
137
|
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string} # just in case
|
131
138
|
rm -rf /etc/puppet/ssl
|
132
139
|
# Start it back up
|
133
|
-
puppetmasterd --verbose
|
134
|
-
|
140
|
+
# puppetmasterd --verbose
|
141
|
+
/etc/init.d/puppetmaster start
|
135
142
|
EOS
|
136
143
|
end
|
144
|
+
|
145
|
+
def run_first_time
|
146
|
+
<<-EOE
|
147
|
+
echo "#{open(File.join(template_directory, "puppetrerun")).read}" > /usr/bin/puppetrerun
|
148
|
+
chmod +x /usr/bin/puppetrerun
|
149
|
+
/bin/sh /usr/bin/puppetrerun
|
150
|
+
EOE
|
151
|
+
end
|
137
152
|
|
138
153
|
# TODO:
|
139
154
|
# Consider this method in the manifest
|
@@ -153,6 +168,7 @@ node "#{ri.name}" inherits default {}
|
|
153
168
|
|
154
169
|
def move_templates
|
155
170
|
<<-EOS
|
171
|
+
echo "Moving templates into place"
|
156
172
|
mkdir -p #{Base.template_path}
|
157
173
|
cp -R #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path}
|
158
174
|
EOS
|
@@ -160,22 +176,25 @@ cp -R #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_p
|
|
160
176
|
|
161
177
|
def create_poolparty_manifest
|
162
178
|
<<-EOS
|
179
|
+
echo "Creating the manifest"
|
163
180
|
cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
|
164
181
|
#{copy_ssh_app}
|
165
182
|
EOS
|
166
183
|
end
|
167
184
|
|
168
185
|
def clean_master_certs
|
169
|
-
returning
|
170
|
-
s << "puppetca --clean master.compute-1.internal 2>&1 > /dev/null
|
186
|
+
str = returning Array.new do |s|
|
187
|
+
s << "puppetca --clean master.compute-1.internal 2>&1 > /dev/null"
|
171
188
|
s << "puppetca --clean master.ec2.internal 2>&1 > /dev/null"
|
172
|
-
|
173
|
-
|
189
|
+
end.join(";")
|
190
|
+
"if [ -f '/usr/bin/puppetcleaner' ]; then /usr/bin/env puppetcleaner; else #{str}; fi"
|
174
191
|
end
|
175
192
|
|
176
193
|
def restart_puppetd
|
194
|
+
terminate_string = "ps aux | grep puppetmaster | awk '{print $2}' | xargs kill #{unix_hide_string}; puppetmasterd --verbose"
|
177
195
|
<<-EOS
|
178
|
-
|
196
|
+
echo "Running puppet manifest"
|
197
|
+
/bin/sh /usr/bin/puppetrerun
|
179
198
|
EOS
|
180
199
|
end
|
181
200
|
end
|
@@ -15,6 +15,12 @@ module PoolParty
|
|
15
15
|
start_puppet
|
16
16
|
]
|
17
17
|
end
|
18
|
+
|
19
|
+
def setup_poolparty
|
20
|
+
<<-EOE
|
21
|
+
echo "#{open(File.join(template_directory, "puppetrun")).read}" > /usr/bin/puppetrun
|
22
|
+
EOE
|
23
|
+
end
|
18
24
|
|
19
25
|
def setup_puppet
|
20
26
|
<<-EOE
|
@@ -34,7 +40,7 @@ module PoolParty
|
|
34
40
|
def run_once_and_clean
|
35
41
|
<<-EOS
|
36
42
|
rm -rf /etc/puppet/ssl
|
37
|
-
|
43
|
+
/bin/sh /usr/bin/puppetrerun
|
38
44
|
rm -rf /etc/puppet/ssl
|
39
45
|
EOS
|
40
46
|
end
|
@@ -43,7 +49,7 @@ rm -rf /etc/puppet/ssl
|
|
43
49
|
# puppetd --listen --fqdn #{@instance.name}
|
44
50
|
def start_puppet
|
45
51
|
<<-EOS
|
46
|
-
|
52
|
+
/bin/sh /usr/bin/puppetrerun
|
47
53
|
EOS
|
48
54
|
end
|
49
55
|
|
@@ -3,6 +3,11 @@ require "ftools"
|
|
3
3
|
module PoolParty
|
4
4
|
module CloudResourcer
|
5
5
|
|
6
|
+
def plugin_directory(*args)
|
7
|
+
args = ["/plugins"] if args.empty?
|
8
|
+
args.each {|arg| Dir["#{arg}/*/*.rb"].each {|f| require f rescue "" }}
|
9
|
+
end
|
10
|
+
|
6
11
|
# Store block
|
7
12
|
def store_block(&block)
|
8
13
|
@store_block ||= block
|
@@ -61,9 +61,10 @@ module PoolParty
|
|
61
61
|
def make_template_directory(dir=nil)
|
62
62
|
path = dir ? ::File.join(Base.tmp_path, Base.template_directory, ::File.basename(dir)) : ::File.join(Base.tmp_path, Base.template_directory)
|
63
63
|
begin
|
64
|
-
|
64
|
+
make_base_directory
|
65
|
+
FileUtils.mkdir path unless ::File.directory?(path)
|
65
66
|
rescue Errno::EEXIST
|
66
|
-
FileUtils.rm path
|
67
|
+
FileUtils.rm path if ::File.exists?(path)
|
67
68
|
make_template_directory(dir)
|
68
69
|
end
|
69
70
|
path
|
@@ -23,7 +23,8 @@ module PoolParty
|
|
23
23
|
args.each do |arg|
|
24
24
|
(available_monitors << "#{arg}".downcase.to_sym unless available_monitors.include?("#{arg}".downcase.to_sym))
|
25
25
|
|
26
|
-
InstanceMethods.module_eval "def #{arg}; @#{arg} ||=
|
26
|
+
InstanceMethods.module_eval "def #{arg}; @#{arg} ||= get_live_#{arg}; end"
|
27
|
+
InstanceMethods.module_eval "def get_live_#{arg}; messenger_send!(\"get_current_load #{arg}\").to_f rescue -1.0; end"
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
@@ -49,13 +49,14 @@ begin
|
|
49
49
|
:name => @name,
|
50
50
|
:hostname => h[:ip],
|
51
51
|
:ip => h[:ip].convert_from_ec2_to_ip,
|
52
|
-
:
|
52
|
+
:index => i,
|
53
|
+
:launching_time => (h[:launching_time])
|
53
54
|
})
|
54
|
-
end
|
55
|
+
end.sort_by {|a| a[:index] }
|
55
56
|
end
|
56
57
|
# Get the s3 description for the response in a hash format
|
57
58
|
def get_instances_description
|
58
|
-
EC2ResponseObject.get_descriptions(ec2.describe_instances)
|
59
|
+
EC2ResponseObject.get_descriptions(ec2.describe_instances)
|
59
60
|
end
|
60
61
|
|
61
62
|
def after_launch_master(instance=nil)
|
@@ -158,7 +159,7 @@ begin
|
|
158
159
|
:name => resp.instanceId,
|
159
160
|
:ip => resp.dnsName || "not-assigned",
|
160
161
|
:status => resp.instanceState.name,
|
161
|
-
:launching_time => resp.launchTime,
|
162
|
+
:launching_time => resp.launchTime.parse_datetime,
|
162
163
|
:keypair => resp.keyName
|
163
164
|
}
|
164
165
|
rescue Exception => e
|
@@ -69,13 +69,13 @@ module PoolParty
|
|
69
69
|
end
|
70
70
|
# Commands for the servers
|
71
71
|
def self.puppet_runner_command
|
72
|
-
". /etc/profile &&
|
72
|
+
". /etc/profile && puppetrunner"
|
73
73
|
end
|
74
74
|
def self.puppet_master_rerun_command
|
75
|
-
"
|
75
|
+
". /etc/profile && puppetrerun"
|
76
76
|
end
|
77
77
|
def self.puppet_rerun_commad
|
78
|
-
|
78
|
+
puppet_runner_command
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -31,6 +31,15 @@ module PoolParty
|
|
31
31
|
def rsync_command
|
32
32
|
"rsync -azP --exclude cache -e '#{ssh_string}'"
|
33
33
|
end
|
34
|
+
def remote_ssh_array
|
35
|
+
["-o StrictHostKeyChecking=no", "-l '#{Base.user}'", '-i "'+remote_keypair_path+'"']
|
36
|
+
end
|
37
|
+
def remote_ssh_string
|
38
|
+
(["ssh"] << remote_ssh_array).join(" ")
|
39
|
+
end
|
40
|
+
def remote_rsync_command
|
41
|
+
"rsync -azP --exclude cache -e '#{remote_ssh_string}'"
|
42
|
+
end
|
34
43
|
# Open the cached local copy of the instances list and
|
35
44
|
# create a new RemoteInstance from each line
|
36
45
|
def list_from_local
|
@@ -79,20 +79,30 @@ module PoolParty
|
|
79
79
|
key = keyp ? keyp : keypair
|
80
80
|
unless @describe_instances
|
81
81
|
tmpInstanceList = describe_instances.select {|a| key ? a[:keypair] == key : true }
|
82
|
-
has_master = tmpInstanceList.
|
82
|
+
has_master = !tmpInstanceList.select {|a| a[:name] == "master" }.empty?
|
83
83
|
if has_master
|
84
84
|
@describe_instances = tmpInstanceList
|
85
|
-
else
|
85
|
+
else
|
86
86
|
@id = 0
|
87
|
-
|
87
|
+
running = select_from_instances_on_status(/running/, tmpInstanceList)
|
88
|
+
pending = select_from_instances_on_status(/pending/, tmpInstanceList)
|
89
|
+
terminated = select_from_instances_on_status(/shutting/, tmpInstanceList)
|
90
|
+
|
91
|
+
running = running.map do |inst|
|
88
92
|
inst[:name] = (@id == 0 ? "master" : "node#{@id}")
|
89
93
|
@id += 1
|
90
94
|
inst
|
91
|
-
end
|
95
|
+
end.sort_by {|a| a[:index] }
|
96
|
+
|
97
|
+
@describe_instances = [running, pending, terminated].flatten
|
92
98
|
end
|
93
99
|
end
|
94
100
|
@describe_instances
|
95
101
|
end
|
102
|
+
# Select the instances based on their status
|
103
|
+
def select_from_instances_on_status(status=/running/, list=[])
|
104
|
+
list.select {|a| a[:status] =~ status}
|
105
|
+
end
|
96
106
|
# Instances
|
97
107
|
# Get the master from the cloud
|
98
108
|
def master
|
@@ -4,26 +4,35 @@ module PoolParty
|
|
4
4
|
virtual_resource(:deploydirectory) do
|
5
5
|
|
6
6
|
def loaded(opts={}, parent=self)
|
7
|
-
package_directory
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
has_rsync_mirror(:dir => cwd)
|
7
|
+
package_directory
|
8
|
+
unpack_directory
|
9
|
+
sync_directories
|
12
10
|
end
|
13
11
|
|
14
12
|
def package_directory
|
15
13
|
path = ::File.join( Base.tmp_path, "#{::File.basename(from_dir)}.tar.gz" )
|
16
14
|
# cd /Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/poolparty/spec/poolparty/plugins/ && tar -czf plugins.tar.gz . && mv plugins.tar.gz /tmp/poolparty && cd /tmp/poolparty
|
17
|
-
|
15
|
+
archive_name = "#{name.dir_safe}.tar.gz"
|
16
|
+
cmd = "cd #{::File.expand_path(from_dir)} && tar -czf #{archive_name} . && mv #{archive_name} #{Base.tmp_path}"
|
18
17
|
`#{cmd}` unless testing
|
19
18
|
end
|
20
19
|
|
21
|
-
def unpack_directory
|
22
|
-
|
23
|
-
|
20
|
+
def unpack_directory
|
21
|
+
execute_on_master do
|
22
|
+
has_exec({:name => "deploy-directory-#{name}", :requires => get_directory("#{cwd}"), :cwd => cwd}) do
|
23
|
+
# && rm #{Base.tmp_path}/#{parent.name.dir_safe}.tar.gz
|
24
|
+
command "cd #{parent.cwd}; tar -zxf #{Base.remote_storage_path}/#{parent.name.dir_safe}.tar.gz; rm #{Base.remote_storage_path}/#{parent.name.dir_safe}.tar.gz"
|
25
|
+
onlyif "test -f #{Base.remote_storage_path}/#{parent.name.dir_safe}.tar.gz"
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
30
|
+
def sync_directories
|
31
|
+
# execute_on_master do
|
32
|
+
has_rsyncmirror(:dir => cwd, :name => "deploydirectory-#{name}")
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
|
27
36
|
def from(dir)
|
28
37
|
from_dir (dir.include?(" ") ? dir.gsub(/[ ]/, '') : dir)
|
29
38
|
end
|
@@ -26,11 +26,12 @@ module PoolParty
|
|
26
26
|
EOE
|
27
27
|
end
|
28
28
|
|
29
|
-
def delete_lines_from(file="", pattern
|
29
|
+
def delete_lines_from(file="", pattern=//, opts={})
|
30
30
|
call_function <<-EOE
|
31
31
|
delete_lines {
|
32
32
|
'#{file}' :
|
33
33
|
file => '#{file}',
|
34
|
+
#{opts.flush_out("\t", ",")}
|
34
35
|
pattern => '#{pattern}'
|
35
36
|
}
|
36
37
|
EOE
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module PoolParty
|
2
|
-
class
|
2
|
+
class Rsyncmirror
|
3
3
|
|
4
4
|
virtual_resource(:rsyncmirror) do
|
5
5
|
|
6
6
|
def loaded(opts={}, parent=self)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def has_rsync_mirror(opts={}, parent=self)
|
11
|
-
has_exec(:command => "rsync -aRqv --no-implied-dirs --delete --delete-excluded '#{Base.user}@master:#{opts[:dir]}' '#{opts[:dir]}'", :name => "rsync-#{name}")
|
7
|
+
@parent = parent
|
8
|
+
has_exec(opts.merge({:command => "#{cloud.remote_rsync_command} --no-implied-dirs --delete-excluded #{Base.user}@master:#{dir}/ #{dir}/".safe_quote, :name => "rsync-#{name}"}))
|
12
9
|
end
|
13
10
|
|
14
11
|
# Since git is not a native type, we have to say which core resource
|
data/lib/poolparty/pool/cloud.rb
CHANGED
@@ -45,11 +45,18 @@ module PoolParty
|
|
45
45
|
|
46
46
|
def initialize(name, parent, &block)
|
47
47
|
@name = name
|
48
|
-
|
48
|
+
|
49
|
+
plugin_directory "#{::Dir.pwd}/plugins"
|
50
|
+
|
49
51
|
set_parent(parent) if parent
|
50
52
|
self.instance_eval &block if block
|
53
|
+
|
54
|
+
setup_defaults
|
55
|
+
end
|
56
|
+
|
57
|
+
def setup_defaults
|
51
58
|
# this can be overridden in the spec, but ec2 is the default
|
52
|
-
self.using :ec2
|
59
|
+
self.using :ec2
|
53
60
|
end
|
54
61
|
|
55
62
|
# Keypairs
|
data/lib/poolparty/pool/pool.rb
CHANGED
@@ -34,13 +34,14 @@ module PoolParty
|
|
34
34
|
})
|
35
35
|
|
36
36
|
def initialize(name,&block)
|
37
|
+
setup_defaults
|
38
|
+
|
37
39
|
@name = name
|
38
40
|
instance_eval &block if block
|
39
41
|
end
|
40
42
|
|
41
|
-
def
|
42
|
-
|
43
|
-
args.each {|arg| Dir["#{arg}/*/*.rb"].each {|f| require f rescue "" }}
|
43
|
+
def setup_defaults
|
44
|
+
plugin_directory "#{::Dir.pwd}/plugins"
|
44
45
|
end
|
45
46
|
|
46
47
|
# This is where the entire process starts
|
@@ -18,7 +18,7 @@ module PoolParty
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def add_resource(type, opts={}, parent=self, &block)
|
21
|
-
if in_resources?(type, opts[:name])
|
21
|
+
if in_resources?(type, opts[:name])
|
22
22
|
get_resource(type, opts[:name], parent)
|
23
23
|
else
|
24
24
|
returning "PoolParty::Resources::#{type.to_s.camelize}".classify.constantize.new(opts, parent, &block) do |o|
|
@@ -150,6 +150,14 @@ module PoolParty
|
|
150
150
|
self.class.custom_functions << str
|
151
151
|
end
|
152
152
|
|
153
|
+
def cloud
|
154
|
+
@p = parent
|
155
|
+
while !@p.is_a?(PoolParty::Cloud)
|
156
|
+
@p = @p.parent
|
157
|
+
end
|
158
|
+
@p
|
159
|
+
end
|
160
|
+
|
153
161
|
def self.custom_functions_to_string(pre="")
|
154
162
|
returning Array.new do |output|
|
155
163
|
PoolParty::Resources.available_custom_resources.each do |resource|
|
@@ -2,16 +2,16 @@ module PoolParty
|
|
2
2
|
module Resources
|
3
3
|
|
4
4
|
def execute_on_master(parent=self, &block)
|
5
|
-
execute_if("$hostname", "==", "master", parent, &block)
|
5
|
+
execute_if("$hostname", "==", "master", {}, parent, &block)
|
6
6
|
end
|
7
7
|
|
8
8
|
def execute_on_node(parent=self, &block)
|
9
|
-
execute_if("$hostname", "!=", "master", parent, &block)
|
9
|
+
execute_if("$hostname", "!=", "master", {:notequal => true}, parent, &block)
|
10
10
|
end
|
11
11
|
|
12
|
-
def execute_if(attr_s="$hostname", comparison="==", str="", parent=self, &block)
|
12
|
+
def execute_if(attr_s="$hostname", comparison="==", str="", cust_opts={}, parent=self, &block)
|
13
13
|
# parent = parent.is_a?(PoolParty::Cloud::Cloud) ? parent : parent.parent
|
14
|
-
opts = {:attribute => attr_s, :equal => str, :comparison => comparison}
|
14
|
+
opts = {:attribute => attr_s, :equal => str, :comparison => comparison}.merge(cust_opts)
|
15
15
|
options = parent.respond_to?(:options) ? parent.options.merge!(opts) : opts
|
16
16
|
# @c = PoolParty::Resources::Conditional.new(options, parent, &block)
|
17
17
|
parent.add_resource(:conditional, options, parent, &block)
|
@@ -24,6 +24,7 @@ module PoolParty
|
|
24
24
|
name "#{opts[:name] ? opts[:name] : opts[:attribute]} #{opts[:comparison]} #{opts[:equal]}"
|
25
25
|
attribute opts[:attribute]
|
26
26
|
equal opts[:equal]
|
27
|
+
notequal opts.has_key?(:notequal) ? opts[:notequal] : false
|
27
28
|
super
|
28
29
|
end
|
29
30
|
|
@@ -34,7 +35,7 @@ module PoolParty
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def disallowed_options
|
37
|
-
[:comparison]
|
38
|
+
[:comparison, :notequal]
|
38
39
|
end
|
39
40
|
|
40
41
|
def printable?
|
@@ -49,8 +50,13 @@ module PoolParty
|
|
49
50
|
returning Array.new do |output|
|
50
51
|
output << "# #{name.sanitize}"
|
51
52
|
output << "case #{attribute} {"
|
52
|
-
|
53
|
-
|
53
|
+
if notequal
|
54
|
+
output << "#{equal} : {}"
|
55
|
+
output << "default : { #{resources_string_from_resources(resources)} }"
|
56
|
+
else
|
57
|
+
output << "#{equal} : { #{resources_string_from_resources(resources)} }"
|
58
|
+
output << "default : {}"
|
59
|
+
end
|
54
60
|
output << "}"
|
55
61
|
end.join("\n")
|
56
62
|
end
|
@@ -28,7 +28,7 @@ defaults
|
|
28
28
|
stats uri /poolparty
|
29
29
|
stats realm Statistics\ for\ PoolParty
|
30
30
|
|
31
|
-
listen
|
31
|
+
listen poolparty
|
32
32
|
bind 0.0.0.0:<%= ports_haproxy.join(",0.0.0.0:") %>
|
33
33
|
cookie POOLPARTYPARTY
|
34
34
|
<%- node_ips_haproxy.chomp.split(/\t/).each_with_index do |ip, index| -%>
|
@@ -2,4 +2,19 @@
|
|
2
2
|
|
3
3
|
. /etc/profile
|
4
4
|
# rm -rf /etc/puppet/ssl
|
5
|
-
|
5
|
+
if [ `/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master` ];
|
6
|
+
then
|
7
|
+
echo '';
|
8
|
+
else
|
9
|
+
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill
|
10
|
+
/etc/init.d/puppetmaster stop
|
11
|
+
rm -rf /etc/puppet/ssl
|
12
|
+
/etc/init.d/puppetmaster start
|
13
|
+
if [ `/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master` ];
|
14
|
+
then
|
15
|
+
echo '';
|
16
|
+
else
|
17
|
+
# Try again
|
18
|
+
/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
19
|
+
fi
|
20
|
+
fi
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
. /etc/profile
|
4
|
+
# rm -rf /etc/puppet/ssl
|
5
|
+
if [ `hostname` -eq "master"];
|
6
|
+
then
|
7
|
+
/bin/sh puppetrerun
|
8
|
+
else
|
9
|
+
if [ `/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master` ];
|
10
|
+
then
|
11
|
+
echo '';
|
12
|
+
else
|
13
|
+
/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
14
|
+
fi
|
15
|
+
fi
|
data/lib/poolparty/version.rb
CHANGED
data/poolparty.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.59
|
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: 2008-11-
|
12
|
+
date: 2008-11-14 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -381,6 +381,7 @@ files:
|
|
381
381
|
- lib/poolparty/templates/puppet.conf
|
382
382
|
- lib/poolparty/templates/puppetcleaner
|
383
383
|
- lib/poolparty/templates/puppetrerun
|
384
|
+
- lib/poolparty/templates/puppetrunner
|
384
385
|
- lib/poolparty/templates/yaws.conf
|
385
386
|
- lib/poolparty/version.rb
|
386
387
|
- lib/poolpartycl.rb
|
@@ -27,7 +27,7 @@ describe "Master provisioner" do
|
|
27
27
|
@master.should_receive(:setup_fileserver)
|
28
28
|
end
|
29
29
|
it "should call create_local_node" do
|
30
|
-
@master.should_receive(:create_local_node)
|
30
|
+
@master.should_receive(:create_local_node).twice
|
31
31
|
end
|
32
32
|
it "should call the custom_install_tasks" do
|
33
33
|
@master.should_receive(:custom_install_tasks)
|
@@ -70,7 +70,7 @@ describe "Remote Instance" do
|
|
70
70
|
@ri.respond_to?(:puppet_runner_command).should == true
|
71
71
|
end
|
72
72
|
it "should return the puppet_runner_command with puppetd" do
|
73
|
-
@ri.puppet_runner_command.should =~ /
|
73
|
+
@ri.puppet_runner_command.should =~ /puppetrun/
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -54,7 +54,7 @@ describe "RemoterBase" do
|
|
54
54
|
@tr.list_of_instances("fake_keypair").map {|a| a[:name] }.should == ["master", "node1", "node2", "node3"]
|
55
55
|
end
|
56
56
|
it "should be able to grab all the blist keypairs" do
|
57
|
-
@tr.list_of_instances("blist").map {|a| a[:name] }.should == ["
|
57
|
+
@tr.list_of_instances("blist").map {|a| a[:name] }.should == ["node4"]
|
58
58
|
end
|
59
59
|
end
|
60
60
|
describe "get by name" do
|
@@ -11,7 +11,11 @@ describe "Remote Instance" do
|
|
11
11
|
end
|
12
12
|
describe "wrapped" do
|
13
13
|
before(:each) do
|
14
|
-
@tc = TestClass.new
|
14
|
+
@tc = TestClass.new
|
15
|
+
@cloud = MyOpenStruct.new(:keypair => "keys", :remote_keypair_path => "/keypair_path", :name => "cloudcloud")
|
16
|
+
@cloud.stub!(:is_a?).with(PoolParty::Cloud::Cloud).and_return true
|
17
|
+
@tc.stub!(:parent).and_return @cloud
|
18
|
+
|
15
19
|
@options = {:name => "deploydirectory", :from => ::File.dirname(__FILE__), :to => "/var/www/deploydirectory", :testing => false}
|
16
20
|
end
|
17
21
|
it "should be a string" do
|
@@ -39,6 +43,9 @@ describe "Remote Instance" do
|
|
39
43
|
it "should not have the to in the to_string" do
|
40
44
|
@tc.resource(:deploydirectory).first.to_string.should_not =~ /to /
|
41
45
|
end
|
46
|
+
it "should have onlyif in the to_string" do
|
47
|
+
@tc.resource(:deploydirectory).first.to_string.should =~ /onlyif/
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
@@ -284,7 +284,7 @@ describe "Cloud" do
|
|
284
284
|
File.open("test_manifest.pp", "w+") {|f| f << @manifest}
|
285
285
|
end
|
286
286
|
it "should include the hosts for all the listed local instances" do
|
287
|
-
@manifest.should =~ /
|
287
|
+
@manifest.should =~ /master :/
|
288
288
|
end
|
289
289
|
end
|
290
290
|
describe "building with an existing manifest" do
|
@@ -36,7 +36,7 @@ describe "Pool" do
|
|
36
36
|
plugin_directory "yaway"
|
37
37
|
end
|
38
38
|
end
|
39
|
-
it "should call Dir when the plugin directory is set" do
|
39
|
+
it "should call Dir when the plugin directory is set" do
|
40
40
|
Dir.should_receive(:[]).with("yaway/*/*.rb").once.and_return []
|
41
41
|
end
|
42
42
|
end
|
@@ -9,7 +9,7 @@ describe "Conditional" do
|
|
9
9
|
describe "wrapped" do
|
10
10
|
before(:each) do
|
11
11
|
@cloud = cloud :conditional_cloud_spec do
|
12
|
-
execute_if("$hostname", "==", "'master'", self) do
|
12
|
+
execute_if("$hostname", "==", "'master'", {}, self) do
|
13
13
|
has_file({:name => "/etc/apache2/puppetmaster2.conf"})
|
14
14
|
end
|
15
15
|
end
|
@@ -30,6 +30,18 @@ describe "Conditional" do
|
|
30
30
|
it "should have the parent as the cloud" do
|
31
31
|
@cond.parent.should == @cloud
|
32
32
|
end
|
33
|
+
describe "helpers" do
|
34
|
+
it "should have execute_on_master with the string $hostname == 'master'" do
|
35
|
+
str = execute_on_master do
|
36
|
+
has_file(:name => "/etc/vars")
|
37
|
+
end.to_string.should =~ /\$hostname==master/
|
38
|
+
end
|
39
|
+
it "should have execute_on_node with the string $hostname != 'master'" do
|
40
|
+
str = execute_on_node do
|
41
|
+
has_file(:name => "/etc/vars")
|
42
|
+
end.to_string.should =~ /\$hostname!=master/
|
43
|
+
end
|
44
|
+
end
|
33
45
|
describe "to_string" do
|
34
46
|
before(:each) do
|
35
47
|
@string = @cond.to_string
|
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: 0.2.
|
4
|
+
version: 0.2.59
|
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: 2008-11-
|
12
|
+
date: 2008-11-14 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -381,6 +381,7 @@ files:
|
|
381
381
|
- lib/poolparty/templates/puppet.conf
|
382
382
|
- lib/poolparty/templates/puppetcleaner
|
383
383
|
- lib/poolparty/templates/puppetrerun
|
384
|
+
- lib/poolparty/templates/puppetrunner
|
384
385
|
- lib/poolparty/templates/yaws.conf
|
385
386
|
- lib/poolparty/version.rb
|
386
387
|
- lib/poolpartycl.rb
|