auser-poolparty 0.2.92 → 0.2.93

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/Manifest.txt CHANGED
@@ -10,7 +10,6 @@ bin/cloud-add-access
10
10
  bin/cloud-add-keypair
11
11
  bin/cloud-configure
12
12
  bin/cloud-contract
13
- bin/cloud-ensure-provisioning
14
13
  bin/cloud-expand
15
14
  bin/cloud-handle-load
16
15
  bin/cloud-list
@@ -36,13 +35,17 @@ bin/pool-list
36
35
  bin/pool-start
37
36
  bin/server-build-messenger
38
37
  bin/server-clean-cert-for
38
+ bin/server-ensure-provisioning
39
39
  bin/server-fire-cmd
40
40
  bin/server-get-load
41
41
  bin/server-list-active
42
42
  bin/server-list-responding
43
+ bin/server-provision
44
+ bin/server-query-agent
43
45
  bin/server-rerun
44
46
  bin/server-send-command
45
47
  bin/server-show-stats
48
+ bin/server-start-agent
46
49
  bin/server-start-client
47
50
  bin/server-start-master
48
51
  bin/server-start-node
@@ -218,6 +221,7 @@ lib/poolparty/helpers/ruberl.rb
218
221
  lib/poolparty/modules/cloud_dsl.rb
219
222
  lib/poolparty/modules/cloud_resourcer.rb
220
223
  lib/poolparty/modules/configurable.rb
224
+ lib/poolparty/modules/daemonizable.rb
221
225
  lib/poolparty/modules/definable_resource.rb
222
226
  lib/poolparty/modules/file_writer.rb
223
227
  lib/poolparty/modules/method_missing_sugar.rb
@@ -276,6 +280,7 @@ lib/poolparty/provisioners/capistrano/recipies/base.rb
276
280
  lib/poolparty/provisioners/capistrano/recipies/master.rb
277
281
  lib/poolparty/provisioners/capistrano/recipies/slave.rb
278
282
  lib/poolparty/provisioners/provisioner_base.rb
283
+ lib/poolparty/server/agent.rb
279
284
  lib/poolparty/spec.rb
280
285
  lib/poolparty/spec/core/string.rb
281
286
  lib/poolparty/spec/matchers/a_spec_extensions_base.rb
@@ -320,6 +325,7 @@ lib/poolparty/templates/puppetrunner
320
325
  lib/poolparty/templates/yaws.conf
321
326
  lib/poolparty/version.rb
322
327
  lib/poolpartycl.rb
328
+ log/agent.log
323
329
  log/pool.log
324
330
  poolparty.gemspec
325
331
  script/destroy
data/PostInstall.txt CHANGED
@@ -1,4 +1,4 @@
1
- Get ready to jump in the pool, you just installed PoolParty! (Updated at 18:36 12/21/08)
1
+ Get ready to jump in the pool, you just installed PoolParty! (Updated at 01:09 12/23/08)
2
2
 
3
3
  To get started, run the generator:
4
4
 
data/README.txt CHANGED
@@ -47,6 +47,8 @@ sudo gem install auser-poolparty
47
47
  * Refactor provisioning to use erlang
48
48
  * Add queuing of tasks on the messenger
49
49
  * Add syntax checker on the manifests
50
+ * Move in collectd support
51
+ * Add master query
50
52
 
51
53
  == LICENSE:
52
54
 
data/bin/cloud-configure CHANGED
@@ -11,17 +11,7 @@ end
11
11
  o.loaded_clouds.each do |cloud|
12
12
 
13
13
  with_cloud(cloud) do
14
-
15
- # hide_output do
16
- # if provision_class == "master" || provision_class == "all"
17
- @cl = self
18
- # daemon ? daemonize {Provisioner.configure_master(@cl, testing)} : Provisioner.configure_master(self, testing)
19
- verbose ? provisioner_for(master).configure(testing) : hide_output { provisioner_for(master).configure(testing) }
20
- # end
21
- # if provision_class == "slave" || provision_class == "all"
22
- # Provisioner.configure_slaves(self, testing)
23
- # end
24
- # end
25
- clear_base_directory unless testing
14
+ verbose ? provisioner_for(master).configure(testing) : hide_output { provisioner_for(master).configure(testing) }
15
+ cleanup_storage_directory unless testing
26
16
  end
27
17
  end
data/bin/cloud-provision CHANGED
@@ -18,7 +18,6 @@ o.loaded_clouds.each do |cloud|
18
18
  if instance_num
19
19
  @instance = get_instance_by_number( instance_num )
20
20
  instance_num == 0 ? provisioner_for(master).install(testing) : provisioner_for(@instance).install(testing)
21
- # Provisioner.process_clean_reconfigure_for!(@instance, self, testing)
22
21
  else
23
22
  if provision_slave
24
23
  vputs "Provisioning slaves"
@@ -29,7 +28,7 @@ o.loaded_clouds.each do |cloud|
29
28
  end
30
29
  end
31
30
 
32
- clear_base_directory unless testing
31
+ cleanup_storage_directory unless testing
33
32
  end
34
33
 
35
34
  end
@@ -26,8 +26,8 @@ o.loaded_clouds.each do |cloud|
26
26
 
27
27
  node_id = node.gsub(/node/, '')
28
28
 
29
- cmd = ". /etc/profile && #{str};cloud-provision -n #{cloud.name} -i #{node_id};#{str}"
30
- running_cmd = "ps aux | grep -v grep | grep \"cloud-provision -n #{cloud.name} -i #{node_id};\""
29
+ cmd = ". /etc/profile && #{str};server-provision -n #{cloud.name} -i #{node_id};#{str}"
30
+ running_cmd = "ps aux | grep -v grep | grep \"server-provision -n #{cloud.name} -i #{node_id};\""
31
31
 
32
32
  vputs "Executing #{cmd}"
33
33
  running = %x[#{running_cmd}]
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+ require "poolpartycl"
5
+
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('-p', '--slave', 'Provision slave (default: false)') { optioner.provision_slave true }
9
+ opts.on('-i num', '--id num', 'Instance num to provision') { |i| optioner.instance_number i }
10
+ end
11
+
12
+ o.loaded_clouds.each do |cloud|
13
+
14
+ with_cloud(cloud) do
15
+ setup_dev
16
+ instance_num = instance_number.to_i if instance_number
17
+
18
+ if instance_num
19
+ @instance = get_instance_by_number( instance_num )
20
+ instance_num == 0 ? provisioner_for(master).install(testing) : provisioner_for(@instance).install(testing)
21
+ else
22
+ if provision_slave
23
+ vputs "Provisioning slaves"
24
+ verbose ? provisioner_for(nil).install(testing) : hide_output { provisioner_for(nil).install(testing) }
25
+ else
26
+ vputs "Provisioning master"
27
+ verbose ? provisioner_for(master).install(testing) : hide_output { provisioner_for(master).install(testing) }
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -1,7 +1,6 @@
1
1
  # Basic poolparty template
2
2
 
3
3
  pool :<%= name -%> do
4
- plugin_directory "#{File.dirname(__FILE__)}/plugins"
5
4
 
6
5
  cloud :app do
7
6
  instances 2..5
data/lib/poolparty.rb CHANGED
@@ -39,7 +39,7 @@ ActiveSupport::Dependencies.load_paths << File.dirname(__FILE__)
39
39
  require "#{File.dirname(__FILE__)}/poolparty/#{f}"
40
40
  end
41
41
 
42
- %w(core modules exceptions dependency_resolutions aska monitors provisioners extra net).each do |dir|
42
+ %w(core modules exceptions dependency_resolutions aska monitors provisioners server extra net).each do |dir|
43
43
  Dir[File.dirname(__FILE__) + "/poolparty/#{dir}/**.rb"].each do |file|
44
44
  require file
45
45
  end
@@ -58,24 +58,9 @@ module PoolParty
58
58
  template File.join(File.dirname(__FILE__), "..", "templates/puppetrunner")
59
59
  end
60
60
 
61
- # execute_on_node do
62
- has_cron(:name => "node puppetd runner", :user => Base.user, :minute => "*/10") do
63
- requires get_gempackage("poolparty")
64
- command "/usr/bin/puppetrunner"
65
- end
66
- has_exec(:command => "/usr/bin/puppetrunner")
61
+ # has_exec(:name => "Puppet runner", :command => "/usr/bin/puppetrunner")
62
+ has_cron(:name => "Run the provisioner", :command => "/usr/bin/puppetrunner", :minute => "*/15")
67
63
  has_user(:name => user)
68
- # end
69
-
70
- # end
71
-
72
- # Cloud panel setup
73
-
74
- # has_directory(:name => "/var/www/cloudpanel")
75
-
76
- # has_file(:name => "/etc/yaws/conf.d/localhost.conf") do
77
- # template File.join(File.dirname(__FILE__), "..", "templates/yaws.conf")
78
- # end
79
64
 
80
65
  # Custom run puppet to minimize footprint
81
66
  # TODO: Update the offsetted times
@@ -91,11 +76,11 @@ module PoolParty
91
76
 
92
77
  execute_on_master do
93
78
  has_exec(:name => "update_hosts", :command => ". /etc/profile && server-update-hosts -n #{cloud.name}")
94
- has_exec(:command => ". /etc/profile && cloud-handle-load -n #{cloud.name}")
95
- has_exec(:command => ". /etc/profile && cloud-ensure-provisioning -n #{cloud.name}")
79
+ has_exec(:name => "Handle load", :command => ". /etc/profile && cloud-handle-load -n #{cloud.name}")
80
+ has_exec(:name => "Ensure provisioning", :command => ". /etc/profile && server-ensure-provisioning -n #{cloud.name}")
96
81
  has_exec(:name => "start master messenger", :command => ". /etc/profile && server-start-master") #, :ifnot => "/bin/ps aux | /bin/grep -q pm_master"
97
82
  has_exec(:name => "start client server", :command => ". /etc/profile && server-start-client") #, :ifnot => "/bin/ps aux | /bin/grep -q client_server"
98
- has_exec(:command => ". /etc/profile && cloud-maintain -n #{cloud.name}")
83
+ has_exec(:name => "Maintain the cloud", :command => ". /etc/profile && cloud-maintain -n #{cloud.name}")
99
84
  has_cron(:name => "ensure puppetmaster is running", :command => ". /etc/profile && puppetmasterd --verbose", :hour => "1")
100
85
 
101
86
  end
@@ -57,19 +57,7 @@ module PoolParty
57
57
  end
58
58
  # Daemonize the process
59
59
  def daemonize(&block)
60
- vputs "Daemonizing..."
61
- trap("CHLD") {Process.wait(-1, Process::WNOHANG)}
62
- pid = fork do
63
- Signal.trap('HUP', 'IGNORE') # Don't die upon logout
64
- File.open("/dev/null", "r+") do |devnull|
65
- $stdout.reopen(devnull)
66
- $stderr.reopen(devnull)
67
- $stdin.reopen(devnull) unless @use_stdin
68
- end
69
- block.call if block
70
- end
71
- Process.detach(pid)
72
- pid
60
+ Daemonize.daemonize(&block)
73
61
  end
74
62
 
75
63
  end
@@ -0,0 +1,140 @@
1
+ module PoolParty
2
+
3
+ module Daemonizeable
4
+
5
+ attr_accessor :pid_file
6
+
7
+ def self.included(base)
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ def pid
12
+ @pid ||= File.file?(pid_file) ? open(pid_file).read.to_i : nil
13
+ end
14
+
15
+ def pid_file
16
+ @pid_file ||= PoolParty::Base.agent_pid_file
17
+ end
18
+
19
+ # Returns +true+ the process identied by +pid+ is running.
20
+ def running?
21
+ return false unless pid
22
+ Process.getpgid(pid) != -1
23
+ rescue Errno::ESRCH
24
+ false
25
+ end
26
+
27
+ # Turns the current script into a daemon process that detaches from the console.
28
+ def daemonize(&block)
29
+ raise unless pid_file
30
+
31
+ remove_stale_pid_file
32
+
33
+ pwd = Dir.pwd # Current directory is changed during daemonization, so store it
34
+
35
+ vputs "Daemonizing..."
36
+ trap("CHLD") {Process.wait(-1, Process::WNOHANG)}
37
+ @pid = fork do
38
+ Signal.trap('HUP', 'IGNORE') # Don't die upon logout
39
+ File.open("/dev/null", "r+") do |devnull|
40
+ $stdout.reopen(devnull)
41
+ $stderr.reopen(devnull)
42
+ $stdin.reopen(devnull) unless @use_stdin
43
+ end
44
+ block.call if block
45
+ end
46
+
47
+ Dir.chdir(pwd)
48
+
49
+ write_pid_file
50
+
51
+ trap('HUP') { restart }
52
+ at_exit do
53
+ remove_pid_file
54
+ end
55
+ Process.detach(pid)
56
+ end
57
+
58
+ # Register a proc to be called to restart the server.
59
+ def on_restart(&block)
60
+ @on_restart = block
61
+ end
62
+
63
+ # Restart the server.
64
+ def restart
65
+ raise ArgumentError, "Can't restart, no 'on_restart' proc specified" unless @on_restart
66
+ stop
67
+ remove_pid_file
68
+ @on_restart.call
69
+ exit!
70
+ end
71
+
72
+ module ClassMethods
73
+ # Send a QUIT signal the process which PID is stored in +pid_file+.
74
+ # If the process is still running after +timeout+, KILL signal is
75
+ # sent.
76
+ def kill(pid_file, timeout=60)
77
+ if pid = send_signal('QUIT', pid_file)
78
+ Timeout.timeout(timeout) do
79
+ sleep 0.1 while Process.running?(pid)
80
+ end
81
+ end
82
+ rescue Timeout::Error
83
+ print "Timeout! "
84
+ send_signal('KILL', pid_file)
85
+ rescue Interrupt
86
+ send_signal('KILL', pid_file)
87
+ ensure
88
+ puts pid_file
89
+ File.delete(pid_file) if File.exists?(pid_file)
90
+ end
91
+
92
+ # Restart the server by sending HUP signal.
93
+ def restart(pid_file)
94
+ send_signal('HUP', pid_file)
95
+ end
96
+
97
+ # Send a +signal+ to the process which PID is stored in +pid_file+.
98
+ def send_signal(signal, pid_file)
99
+ if File.exist?(pid_file) && pid = open(pid_file).read
100
+ pid = pid.to_i
101
+ print "Sending #{signal} signal to process #{pid} ... "
102
+ Process.kill(signal, pid)
103
+ puts
104
+ pid
105
+ else
106
+ puts "Can't stop process, no PID found in #{pid_file}"
107
+ nil
108
+ end
109
+ rescue Errno::ESRCH # No such process
110
+ puts "process not found!"
111
+ nil
112
+ end
113
+ end
114
+
115
+ protected
116
+ def remove_pid_file
117
+ File.delete(@pid_file) if @pid_file && File.exists?(@pid_file)
118
+ end
119
+
120
+ def write_pid_file
121
+ FileUtils.mkdir_p File.dirname(@pid_file)
122
+ open(@pid_file,"w") { |f| f.write(@pid) }
123
+ File.chmod(0644, @pid_file)
124
+ end
125
+
126
+ # If PID file is stale, remove it.
127
+ def remove_stale_pid_file
128
+ if File.exist?(@pid_file)
129
+ if pid && running?
130
+ puts "Pid file exists" and raise
131
+ else
132
+ remove_pid_file
133
+ end
134
+ end
135
+ end
136
+ end
137
+ class Daemonize
138
+ include Daemonizeable
139
+ end
140
+ end
@@ -6,9 +6,7 @@ module PoolParty
6
6
  ::FileUtils.cp file, path unless file == path || ::File.file?(path)
7
7
  end
8
8
  def cleanup_storage_directory
9
- Dir["#{Base.storage_directory}/**/*"].each do |f|
10
- ::FileUtils.rm f if ::File.file?(f)
11
- end
9
+ ::FileUtils.rm_rf "#{Base.storage_directory}"
12
10
  end
13
11
  def copy_template_to_storage_directory(file)
14
12
  make_template_directory
@@ -22,7 +20,13 @@ module PoolParty
22
20
  end
23
21
  ::File.basename(path)
24
22
  end
25
- def make_directory_in_storage_directory(dirname="newdir")
23
+ def copy_directory_into_storage_directory(from, pat)
24
+ to = ::File.join(Base.storage_directory, pat)
25
+
26
+ # make_directory_in_storage_directory(to) unless ::File.directory?(to)
27
+ FileUtils.cp_r(from, to)
28
+ end
29
+ def make_directory_in_storage_directory(dirname="newdir")
26
30
  path = ::File.join( Base.storage_directory, dirname )
27
31
  make_base_path path
28
32
  end
@@ -61,22 +61,6 @@ module PoolParty
61
61
  def list_of_node_ips(options={})
62
62
  list_of_running_instances.collect {|ri| ri.ip }
63
63
  end
64
-
65
- # Get the instance first instance file that exists on the system from the expected places
66
- # denoted in the local_instances_list_file_locations
67
- def get_working_listing_file
68
- local_instances_list_file_locations.reject {|f| f unless File.file?(f) }.first
69
- end
70
- # Expected places for the instances.list to be located at on the machine
71
- def local_instances_list_file_locations
72
- [
73
- "#{Base.storage_directory}/#{name}-instances.list",
74
- "#{Base.base_config_directory}/#{name}-instances.list",
75
- "~/.#{name}-instances.list",
76
- "~/#{name}-instances.list",
77
- "#{name}-instances.list"
78
- ]
79
- end
80
64
 
81
65
  # List calculation methods
82
66
  #
@@ -191,12 +175,7 @@ module PoolParty
191
175
  last_instances = nonmaster_nonterminated_instances[(@num_instances - (num))..(@num_instances)]
192
176
  last_instances.each do |inst|
193
177
  vputs "Provision slave: #{inst}"
194
- # hide_output {PoolParty::Provisioner.process_clean_reconfigure_for!(inst, self)}
195
- # PoolParty::Provisioner.provision_slave(inst, self, false) unless inst.master? rescue vputs "Error"
196
- verbose ? provisioner_for(inst).install(testing) : hide_output { provisioner_for(inst).install(testing) }
197
- # hide_output {PoolParty::Provisioner.process_clean_reconfigure_for!(inst, self)}
198
- # cmd = ". /etc/profile && cloud-provision -i #{inst.name.gsub(/node/, '')} &"
199
- # vputs "Provision slave with command #{cmd}"
178
+ verbose ? provisioner_for(inst).install(testing) : hide_output { provisioner_for(inst).install(testing)}
200
179
  end
201
180
  # PoolParty::Provisioner.reconfigure_master(self)
202
181
  end
@@ -295,7 +274,7 @@ module PoolParty
295
274
  # Rsync a file or directory to a node. Rsync to master by default
296
275
  def rsync_to(source, target=source, num=0)
297
276
  str = "#{rsync_to_command(source, target, get_instance_by_number( num ))}"
298
- vputs "Running: #{str}"
277
+ dputs "Running: #{str}"
299
278
  verbose ? Kernel.system(str) : hide_output {Kernel.system str}
300
279
  end
301
280
 
@@ -326,18 +305,6 @@ module PoolParty
326
305
  run_command_on(cmd, get_instance_by_number( num || 0 ) )
327
306
  end
328
307
 
329
- # Prepare reconfiguration on the master
330
- # TODO: Curious about the puppet/ssl problems...
331
- # puppetd --test --no-daemonize 2>&1 &
332
- # rm -rf /etc/puppet/ssl/*;
333
- def prepare_reconfiguration
334
- unless @prepared
335
- # cmd = "/etc/init.d/puppetmaster restart"
336
- # run_command_on(cmd, master)
337
- @prepared = true
338
- end
339
- end
340
-
341
308
  def self.included(receiver)
342
309
  receiver.extend self
343
310
  end
@@ -26,6 +26,8 @@ module PoolParty
26
26
  :proxy_mode => "http",
27
27
  :messenger_client_port => 7050,
28
28
  :minimum_runtime => 3000, #50.minutes in seconds
29
+ :agent_pid_file => ::File.readable?("/var/run/poolparty_agent.pid") ? "/var/run/agent.pid" : "#{Dir.pwd}/agent.pid",
30
+ :agent_port => 8081,
29
31
  # EC2 Options
30
32
  :ami => "ami-1cd73375",
31
33
  :size => 'm1.small', # must be 'm1.small', 'm1.large', 'm1.xlarge', 'c1.medium', or 'c1.xlarge'
@@ -111,6 +113,14 @@ module PoolParty
111
113
  "#{Dir.pwd}/monitors"
112
114
  ].select {|d| d if viable_directory?(d) }
113
115
  end
116
+
117
+ def custom_modules_directories
118
+ [
119
+ "/var/poolparty/modules",
120
+ "/etc/poolparty/modules",
121
+ "#{Dir.pwd}/modules"
122
+ ].select {|d| d if viable_directory?(d) }
123
+ end
114
124
  # Only return true if the directory we are reading is both readable
115
125
  # and exists
116
126
  def viable_directory?(dir)
@@ -85,6 +85,7 @@ module PoolParty
85
85
  make_base_directory
86
86
  copy_misc_templates
87
87
  copy_custom_monitors
88
+ copy_custom_modules
88
89
  store_keys_in_file
89
90
  Script.save!(self)
90
91
  # not my favorite...
@@ -150,11 +151,23 @@ module PoolParty
150
151
  def copy_custom_monitors
151
152
  unless Base.custom_monitor_directories.empty?
152
153
  make_directory_in_storage_directory("monitors")
153
- Dir["#{Base.custom_monitor_directories}/*.rb"].each do |f|
154
- copy_file_to_storage_directory(f, "monitors")
154
+ Base.custom_monitor_directories.each do |dir|
155
+ Dir["#{dir}/*.rb"].each {|f| copy_file_to_storage_directory(f, "monitors")}
155
156
  end
156
157
  end
157
158
  end
159
+
160
+ def copy_custom_modules
161
+ unless Base.custom_modules_directories.empty?
162
+ make_directory_in_storage_directory("modules")
163
+ Base.custom_modules_directories.each do |dir|
164
+ Dir["#{dir}/*"].each do |d|
165
+ to = ::File.join("modules", ::File.basename(d))
166
+ copy_directory_into_storage_directory(d, to) if ::File.directory?(d)
167
+ end
168
+ end
169
+ end
170
+ end
158
171
 
159
172
  # Configuration files
160
173
  def build_manifest
@@ -29,9 +29,7 @@ module PoolParty
29
29
 
30
30
  else
31
31
  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
32
- command "gem install --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name} <<heredoc
33
- 1
34
- heredoc"
32
+ command "gem install --no-ri --no-rdoc #{"--version #{version}" if version} #{"--source #{source}" if source} #{name}"
35
33
  ifnot "gem list --local #{name} | grep #{name} #{"| grep #{version}" if version}"
36
34
  end
37
35
  end
@@ -17,6 +17,10 @@ module PoolParty
17
17
  source || from
18
18
  end
19
19
 
20
+ def ensure
21
+ present
22
+ end
23
+
20
24
  def printable?
21
25
  true
22
26
  end
@@ -6,6 +6,10 @@ module PoolParty
6
6
 
7
7
  include ::Capistrano::Configuration::Actions::Invocation
8
8
 
9
+ def loaded
10
+ dputs "Capistrano provisioner loaded..."
11
+ create_config
12
+ end
9
13
  def process_install!(testing=false)
10
14
  unless testing
11
15
  @cloud.rsync_storage_files_to(@instance)
@@ -27,7 +31,6 @@ module PoolParty
27
31
  def configure_tasks
28
32
  provision_master? ? master_configure_tasks : slave_configure_tasks
29
33
  end
30
-
31
34
  def master_install_tasks
32
35
  [
33
36
  "custom_install_tasks",
@@ -61,10 +64,6 @@ module PoolParty
61
64
  "slave_configure_slave_task"
62
65
  ]#.flatten.map {|a| a.to_sym }
63
66
  end
64
- # Run tasks after the initialized
65
- def loaded
66
- create_config
67
- end
68
67
 
69
68
  def set_poolparty_roles
70
69
  returning Array.new do |arr|
@@ -27,6 +27,7 @@ Capistrano::Configuration.instance(:must_exist).load do
27
27
  create_local_node_entry_for_puppet
28
28
  move_provisioner_manifest
29
29
  move_template_files
30
+ move_custom_modules
30
31
  setup_poolparty_base_structure
31
32
  ensure_provisioner_is_running
32
33
  run_provisioner
@@ -43,7 +44,10 @@ Capistrano::Configuration.instance(:must_exist).load do
43
44
  def download_base_gems
44
45
  run(returning(Array.new) do |arr|
45
46
  base_gems.each do |name, url|
46
- arr << "wget #{url} -O #{Base.remote_storage_path}/#{name}.gem 2>&1; echo 'downloaded #{name}'" if url
47
+ if url && !url.empty?
48
+ arr << "curl -L -o #{Base.remote_storage_path}/#{name}.gem #{url} 2>&1; echo 'downloaded #{name}'"
49
+ arr << "if test -s #{Base.remote_storage_path}/#{name}.gem; then echo ''; else rm #{Base.remote_storage_path}/#{name}.gem; fi; echo ''"
50
+ end
47
51
  end
48
52
  end.join(" && "))
49
53
  end
@@ -52,7 +56,7 @@ Capistrano::Configuration.instance(:must_exist).load do
52
56
  run(returning(Array.new) do |arr|
53
57
  base_gems.each do |name, url|
54
58
  str = url.empty? ? "#{name}" : "#{Base.remote_storage_path}/#{name}.gem"
55
- arr << "/usr/bin/gem install --ignore-dependencies --no-ri --no-rdoc #{str}"
59
+ arr << "/usr/bin/gem install --ignore-dependencies --no-ri --no-rdoc #{str}; echo 'insatlled #{name}'"
56
60
  end
57
61
  end.join(" && "))
58
62
  end
@@ -62,7 +66,7 @@ Capistrano::Configuration.instance(:must_exist).load do
62
66
  end
63
67
  desc "Restart provisioner base"
64
68
  def restart_provisioner_base
65
- run "/etc/init.d/puppetmaster stop;rm -rf /etc/poolparty/ssl;puppetmasterd --verbose;/etc/init.d/puppetmaster start"
69
+ run "/etc/init.d/puppetmaster stop;rm -rf /etc/poolparty/ssl;start_provisioner_based --verbose;/etc/init.d/puppetmaster start"
66
70
  end
67
71
  desc "Ensure provisioner is running"
68
72
  def ensure_provisioner_is_running
@@ -86,6 +90,14 @@ Capistrano::Configuration.instance(:must_exist).load do
86
90
  cp -R #{remote_storage_path}/templates/* #{template_path}
87
91
  EOR
88
92
  end
93
+ desc "Move custom modules"
94
+ def move_custom_modules
95
+ run <<-EOR
96
+ if test -d #{remote_storage_path}/modules; then
97
+ mkdir -p #{base_config_directory}/modules && cp -R #{remote_storage_path}/modules #{base_config_directory};
98
+ fi
99
+ EOR
100
+ end
89
101
  desc "Move manifest into place"
90
102
  def move_provisioner_manifest
91
103
  run <<-EOR
@@ -0,0 +1,59 @@
1
+ # require 'eventmachine'
2
+ #
3
+ # module PoolParty
4
+ #
5
+ # module AgentServer
6
+ # attr_reader :cloud
7
+ # def initialize(cloud)
8
+ # @cloud = cloud
9
+ # end
10
+ # def receive_data(data)
11
+ # begin
12
+ # meth, args = data.split(" ")[0], data.split(" ")[1..-1]
13
+ # puts "meth: #{meth}"
14
+ # if meth
15
+ # msg = "#{meth} #{args.join(" ") if args && args.length > 0}"
16
+ # open("log/agent.log", "a+") {|f| f << msg }
17
+ # send_data msg if @cloud.debugging
18
+ # out = @cloud.send meth.to_sym, *args
19
+ # send_data "#{out}"
20
+ # end
21
+ # close_connection if data =~ /quit|exit/i
22
+ # rescue Exception => e
23
+ # send_data "#{e}"
24
+ # end
25
+ # end
26
+ # end
27
+ #
28
+ # class Agent
29
+ # include Daemonizeable
30
+ # attr_reader :cloud
31
+ #
32
+ # def initialize(cld)
33
+ # @cloud = cld
34
+ # end
35
+ #
36
+ # def verbose;@cloud.verbose;end
37
+ # def debug;@cloud.debugging;end
38
+ # def kill
39
+ # self.class.kill pid_file
40
+ # end
41
+ # # Run the agent
42
+ # def run
43
+ # unless running?
44
+ # kill if cloud.kill
45
+ #
46
+ # if debug
47
+ # EventMachine::run {EventMachine::start_server "127.0.0.1", Base.agent_port, AgentServer, @cloud}
48
+ # end
49
+ # daemonize do
50
+ # EventMachine::run {EventMachine::start_server "127.0.0.1", Base.agent_port, AgentServer, @cloud}
51
+ # end
52
+ # end
53
+ # end
54
+ # def self.run_for(cld)
55
+ # new(cld).run
56
+ # end
57
+ # end
58
+ #
59
+ # end
@@ -2,8 +2,10 @@
2
2
  vardir = /var/lib/puppet
3
3
  logdir = /var/log/puppet
4
4
  ssldir = /etc/poolparty/ssl
5
- pluginsync = false
6
- factsync = false
5
+ modulepath = /etc/poolparty/modules:$confdir/modules
6
+ # factsync = true
7
+ # pluginsync = true
8
+ # factpath = $vardir/lib/facter
7
9
 
8
10
  [puppetca]
9
11
  config = $config/puppetca.conf
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 92
5
+ TINY = 93
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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.92
4
+ version: 0.2.93
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-12-21 00:00:00 -08:00
12
+ date: 2008-12-23 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,6 @@ executables:
61
61
  - cloud-add-keypair
62
62
  - cloud-configure
63
63
  - cloud-contract
64
- - cloud-ensure-provisioning
65
64
  - cloud-expand
66
65
  - cloud-handle-load
67
66
  - cloud-list
@@ -87,13 +86,17 @@ executables:
87
86
  - pool-start
88
87
  - server-build-messenger
89
88
  - server-clean-cert-for
89
+ - server-ensure-provisioning
90
90
  - server-fire-cmd
91
91
  - server-get-load
92
92
  - server-list-active
93
93
  - server-list-responding
94
+ - server-provision
95
+ - server-query-agent
94
96
  - server-rerun
95
97
  - server-send-command
96
98
  - server-show-stats
99
+ - server-start-agent
97
100
  - server-start-client
98
101
  - server-start-master
99
102
  - server-start-node
@@ -126,7 +129,6 @@ files:
126
129
  - bin/cloud-add-keypair
127
130
  - bin/cloud-configure
128
131
  - bin/cloud-contract
129
- - bin/cloud-ensure-provisioning
130
132
  - bin/cloud-expand
131
133
  - bin/cloud-handle-load
132
134
  - bin/cloud-list
@@ -152,13 +154,17 @@ files:
152
154
  - bin/pool-start
153
155
  - bin/server-build-messenger
154
156
  - bin/server-clean-cert-for
157
+ - bin/server-ensure-provisioning
155
158
  - bin/server-fire-cmd
156
159
  - bin/server-get-load
157
160
  - bin/server-list-active
158
161
  - bin/server-list-responding
162
+ - bin/server-provision
163
+ - bin/server-query-agent
159
164
  - bin/server-rerun
160
165
  - bin/server-send-command
161
166
  - bin/server-show-stats
167
+ - bin/server-start-agent
162
168
  - bin/server-start-client
163
169
  - bin/server-start-master
164
170
  - bin/server-start-node
@@ -334,6 +340,7 @@ files:
334
340
  - lib/poolparty/modules/cloud_dsl.rb
335
341
  - lib/poolparty/modules/cloud_resourcer.rb
336
342
  - lib/poolparty/modules/configurable.rb
343
+ - lib/poolparty/modules/daemonizable.rb
337
344
  - lib/poolparty/modules/definable_resource.rb
338
345
  - lib/poolparty/modules/file_writer.rb
339
346
  - lib/poolparty/modules/method_missing_sugar.rb
@@ -392,6 +399,7 @@ files:
392
399
  - lib/poolparty/provisioners/capistrano/recipies/master.rb
393
400
  - lib/poolparty/provisioners/capistrano/recipies/slave.rb
394
401
  - lib/poolparty/provisioners/provisioner_base.rb
402
+ - lib/poolparty/server/agent.rb
395
403
  - lib/poolparty/spec.rb
396
404
  - lib/poolparty/spec/core/string.rb
397
405
  - lib/poolparty/spec/matchers/a_spec_extensions_base.rb
@@ -436,6 +444,7 @@ files:
436
444
  - lib/poolparty/templates/yaws.conf
437
445
  - lib/poolparty/version.rb
438
446
  - lib/poolpartycl.rb
447
+ - log/agent.log
439
448
  - log/pool.log
440
449
  - poolparty.gemspec
441
450
  - script/destroy
@@ -535,7 +544,7 @@ files:
535
544
  has_rdoc: true
536
545
  homepage: http://poolparty.rubyforge.org
537
546
  post_install_message: |-
538
- Get ready to jump in the pool, you just installed PoolParty! (Updated at 18:36 12/21/08)
547
+ Get ready to jump in the pool, you just installed PoolParty! (Updated at 01:09 12/23/08)
539
548
 
540
549
  To get started, run the generator:
541
550
 
@@ -52,6 +52,12 @@ describe "FileWriter" do
52
52
  @test.copy_file_to_storage_directory(@filepath)
53
53
  end
54
54
  end
55
+ describe "cleanup_storage_directory" do
56
+ it "should call rm_rf on the FileUtils class with the storage_directory" do
57
+ ::FileUtils.should_receive(:rm_rf).with("#{Base.storage_directory}").and_return true
58
+ @test.cleanup_storage_directory
59
+ end
60
+ end
55
61
  after(:all) do
56
62
  ::File.unlink @path if ::File.file? @path
57
63
  end
@@ -6,7 +6,7 @@ describe "Symlink" do
6
6
  before(:each) do
7
7
  reset_resources!
8
8
  @cloud = cloud :symlink_test do
9
- has_symlink(:name => "/etc/apache2/puppetmaster.conf", :source => "/etc/http/puppetmaster.conf")
9
+ has_symlink(:name => "/etc/apache2/puppetmaster.conf")
10
10
  end
11
11
  @symlink = @cloud.resource(:symlink).first
12
12
  end
@@ -89,7 +89,6 @@ def stub_list_from_local_for(o)
89
89
  EOS
90
90
  @file = "filename"
91
91
  @file.stub!(:read).and_return @list
92
- o.stub!(:get_working_listing_file).and_return @file
93
92
  o.stub!(:open).and_return @file
94
93
 
95
94
  @ris = @list.split(/\n/).map {|line| PoolParty::Remote::RemoteInstance.new(line) }
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.92
4
+ version: 0.2.93
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-12-21 00:00:00 -08:00
12
+ date: 2008-12-23 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -61,7 +61,6 @@ executables:
61
61
  - cloud-add-keypair
62
62
  - cloud-configure
63
63
  - cloud-contract
64
- - cloud-ensure-provisioning
65
64
  - cloud-expand
66
65
  - cloud-handle-load
67
66
  - cloud-list
@@ -87,13 +86,17 @@ executables:
87
86
  - pool-start
88
87
  - server-build-messenger
89
88
  - server-clean-cert-for
89
+ - server-ensure-provisioning
90
90
  - server-fire-cmd
91
91
  - server-get-load
92
92
  - server-list-active
93
93
  - server-list-responding
94
+ - server-provision
95
+ - server-query-agent
94
96
  - server-rerun
95
97
  - server-send-command
96
98
  - server-show-stats
99
+ - server-start-agent
97
100
  - server-start-client
98
101
  - server-start-master
99
102
  - server-start-node
@@ -126,7 +129,6 @@ files:
126
129
  - bin/cloud-add-keypair
127
130
  - bin/cloud-configure
128
131
  - bin/cloud-contract
129
- - bin/cloud-ensure-provisioning
130
132
  - bin/cloud-expand
131
133
  - bin/cloud-handle-load
132
134
  - bin/cloud-list
@@ -152,13 +154,17 @@ files:
152
154
  - bin/pool-start
153
155
  - bin/server-build-messenger
154
156
  - bin/server-clean-cert-for
157
+ - bin/server-ensure-provisioning
155
158
  - bin/server-fire-cmd
156
159
  - bin/server-get-load
157
160
  - bin/server-list-active
158
161
  - bin/server-list-responding
162
+ - bin/server-provision
163
+ - bin/server-query-agent
159
164
  - bin/server-rerun
160
165
  - bin/server-send-command
161
166
  - bin/server-show-stats
167
+ - bin/server-start-agent
162
168
  - bin/server-start-client
163
169
  - bin/server-start-master
164
170
  - bin/server-start-node
@@ -334,6 +340,7 @@ files:
334
340
  - lib/poolparty/modules/cloud_dsl.rb
335
341
  - lib/poolparty/modules/cloud_resourcer.rb
336
342
  - lib/poolparty/modules/configurable.rb
343
+ - lib/poolparty/modules/daemonizable.rb
337
344
  - lib/poolparty/modules/definable_resource.rb
338
345
  - lib/poolparty/modules/file_writer.rb
339
346
  - lib/poolparty/modules/method_missing_sugar.rb
@@ -392,6 +399,7 @@ files:
392
399
  - lib/poolparty/provisioners/capistrano/recipies/master.rb
393
400
  - lib/poolparty/provisioners/capistrano/recipies/slave.rb
394
401
  - lib/poolparty/provisioners/provisioner_base.rb
402
+ - lib/poolparty/server/agent.rb
395
403
  - lib/poolparty/spec.rb
396
404
  - lib/poolparty/spec/core/string.rb
397
405
  - lib/poolparty/spec/matchers/a_spec_extensions_base.rb
@@ -436,6 +444,7 @@ files:
436
444
  - lib/poolparty/templates/yaws.conf
437
445
  - lib/poolparty/version.rb
438
446
  - lib/poolpartycl.rb
447
+ - log/agent.log
439
448
  - log/pool.log
440
449
  - poolparty.gemspec
441
450
  - script/destroy
@@ -535,7 +544,7 @@ files:
535
544
  has_rdoc: true
536
545
  homepage: http://poolparty.rubyforge.org
537
546
  post_install_message: |-
538
- Get ready to jump in the pool, you just installed PoolParty! (Updated at 18:36 12/21/08)
547
+ Get ready to jump in the pool, you just installed PoolParty! (Updated at 01:09 12/23/08)
539
548
 
540
549
  To get started, run the generator:
541
550