puppet 0.16.0 → 0.18.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (185) hide show
  1. data/CHANGELOG +98 -0
  2. data/Rakefile +5 -1
  3. data/bin/puppet +1 -1
  4. data/bin/puppetca +25 -11
  5. data/bin/puppetd +189 -66
  6. data/bin/puppetdoc +79 -62
  7. data/bin/puppetmasterd +93 -49
  8. data/bin/puppetrun +385 -0
  9. data/conf/redhat/client.init +5 -2
  10. data/conf/redhat/fileserver.conf +1 -1
  11. data/conf/redhat/lsb-config.patch +51 -0
  12. data/conf/redhat/puppet.spec +45 -18
  13. data/conf/redhat/puppetd.conf +32 -4
  14. data/conf/redhat/server.init +5 -2
  15. data/conf/solaris/pkginfo +7 -0
  16. data/conf/solaris/smf/puppetd.xml +77 -0
  17. data/conf/solaris/smf/puppetmasterd.xml +77 -0
  18. data/conf/solaris/smf/svc-puppetd +66 -0
  19. data/conf/solaris/smf/svc-puppetmasterd +62 -0
  20. data/examples/code/failers/noobjectrvalue +1 -0
  21. data/examples/code/snippets/deepclassheirarchy.pp +23 -0
  22. data/examples/code/snippets/defineoverrides.pp +17 -0
  23. data/examples/code/snippets/emptyexec.pp +3 -0
  24. data/examples/code/snippets/selectorvalues.pp +6 -1
  25. data/examples/code/snippets/tagged.pp +35 -0
  26. data/ext/ldap/puppet.schema +2 -2
  27. data/install.rb +4 -2
  28. data/lib/puppet.rb +206 -15
  29. data/lib/puppet/client.rb +30 -20
  30. data/lib/puppet/client/ca.rb +2 -2
  31. data/lib/puppet/client/dipper.rb +5 -9
  32. data/lib/puppet/client/master.rb +224 -44
  33. data/lib/puppet/client/pelement.rb +54 -9
  34. data/lib/puppet/client/proxy.rb +3 -2
  35. data/lib/puppet/client/reporter.rb +34 -0
  36. data/lib/puppet/client/runner.rb +17 -0
  37. data/lib/puppet/config.rb +136 -55
  38. data/lib/puppet/daemon.rb +59 -37
  39. data/lib/puppet/element.rb +2 -1
  40. data/lib/puppet/event.rb +14 -3
  41. data/lib/puppet/filetype.rb +28 -19
  42. data/lib/puppet/log.rb +297 -132
  43. data/lib/puppet/metric.rb +31 -131
  44. data/lib/puppet/networkclient.rb +73 -46
  45. data/lib/puppet/parameter.rb +49 -1
  46. data/lib/puppet/parsedfile.rb +32 -12
  47. data/lib/puppet/parser/ast.rb +6 -1
  48. data/lib/puppet/parser/ast/astarray.rb +32 -6
  49. data/lib/puppet/parser/ast/collection.rb +91 -0
  50. data/lib/puppet/parser/ast/compdef.rb +2 -2
  51. data/lib/puppet/parser/ast/component.rb +24 -11
  52. data/lib/puppet/parser/ast/function.rb +50 -0
  53. data/lib/puppet/parser/ast/hostclass.rb +70 -22
  54. data/lib/puppet/parser/ast/node.rb +17 -8
  55. data/lib/puppet/parser/ast/nodedef.rb +1 -1
  56. data/lib/puppet/parser/ast/objectdef.rb +28 -10
  57. data/lib/puppet/parser/ast/selector.rb +4 -1
  58. data/lib/puppet/parser/functions.rb +145 -0
  59. data/lib/puppet/parser/interpreter.rb +243 -86
  60. data/lib/puppet/parser/lexer.rb +5 -4
  61. data/lib/puppet/parser/parser.rb +586 -505
  62. data/lib/puppet/parser/scope.rb +337 -187
  63. data/lib/puppet/rails.rb +115 -0
  64. data/lib/puppet/rails/database.rb +40 -0
  65. data/lib/puppet/rails/host.rb +83 -0
  66. data/lib/puppet/rails/rails_object.rb +42 -0
  67. data/lib/puppet/rails/rails_parameter.rb +5 -0
  68. data/lib/puppet/reports/rrdgraph.rb +20 -0
  69. data/lib/puppet/reports/tagmail.rb +94 -0
  70. data/lib/puppet/server.rb +20 -4
  71. data/lib/puppet/server/authconfig.rb +14 -3
  72. data/lib/puppet/server/authstore.rb +2 -2
  73. data/lib/puppet/server/ca.rb +23 -11
  74. data/lib/puppet/server/filebucket.rb +10 -10
  75. data/lib/puppet/server/fileserver.rb +4 -8
  76. data/lib/puppet/server/master.rb +19 -22
  77. data/lib/puppet/server/pelement.rb +28 -16
  78. data/lib/puppet/server/report.rb +184 -0
  79. data/lib/puppet/server/runner.rb +62 -0
  80. data/lib/puppet/server/servlet.rb +23 -9
  81. data/lib/puppet/sslcertificates/ca.rb +25 -1
  82. data/lib/puppet/statechange.rb +34 -53
  83. data/lib/puppet/storage.rb +1 -2
  84. data/lib/puppet/transaction.rb +305 -133
  85. data/lib/puppet/transaction/report.rb +42 -0
  86. data/lib/puppet/transportable.rb +57 -33
  87. data/lib/puppet/type.rb +260 -127
  88. data/lib/puppet/type/component.rb +9 -21
  89. data/lib/puppet/type/cron.rb +367 -116
  90. data/lib/puppet/type/exec.rb +15 -16
  91. data/lib/puppet/type/group.rb +9 -1
  92. data/lib/puppet/type/nameservice.rb +2 -5
  93. data/lib/puppet/type/nameservice/netinfo.rb +3 -0
  94. data/lib/puppet/type/nameservice/objectadd.rb +23 -10
  95. data/lib/puppet/type/nameservice/pw.rb +16 -3
  96. data/lib/puppet/type/package.rb +25 -75
  97. data/lib/puppet/type/package/apple.rb +15 -1
  98. data/lib/puppet/type/package/apt.rb +37 -2
  99. data/lib/puppet/type/package/blastwave.rb +136 -0
  100. data/lib/puppet/type/package/dpkg.rb +4 -4
  101. data/lib/puppet/type/package/gem.rb +119 -0
  102. data/lib/puppet/type/package/openbsd.rb +7 -6
  103. data/lib/puppet/type/package/ports.rb +7 -2
  104. data/lib/puppet/type/package/rpm.rb +1 -1
  105. data/lib/puppet/type/package/sun.rb +23 -9
  106. data/lib/puppet/type/package/sunfreeware.rb +7 -0
  107. data/lib/puppet/type/package/yum.rb +16 -9
  108. data/lib/puppet/type/parsedtype.rb +7 -5
  109. data/lib/puppet/type/parsedtype/mount.rb +55 -34
  110. data/lib/puppet/type/parsedtype/port.rb +7 -1
  111. data/lib/puppet/type/parsedtype/sshkey.rb +6 -16
  112. data/lib/puppet/type/pfile.rb +115 -23
  113. data/lib/puppet/type/pfile/checksum.rb +18 -5
  114. data/lib/puppet/type/pfile/content.rb +2 -2
  115. data/lib/puppet/type/pfile/ensure.rb +3 -3
  116. data/lib/puppet/type/pfile/group.rb +2 -2
  117. data/lib/puppet/type/pfile/source.rb +28 -17
  118. data/lib/puppet/type/pfile/target.rb +25 -17
  119. data/lib/puppet/type/pfilebucket.rb +25 -6
  120. data/lib/puppet/type/schedule.rb +6 -6
  121. data/lib/puppet/type/service.rb +24 -14
  122. data/lib/puppet/type/service/debian.rb +1 -1
  123. data/lib/puppet/type/service/redhat.rb +13 -10
  124. data/lib/puppet/type/service/smf.rb +3 -3
  125. data/lib/puppet/type/state.rb +1 -2
  126. data/lib/puppet/type/symlink.rb +3 -4
  127. data/lib/puppet/type/user.rb +22 -10
  128. data/lib/puppet/type/yumrepo.rb +6 -1
  129. data/lib/puppet/type/zone.rb +595 -0
  130. data/lib/puppet/util.rb +58 -12
  131. data/test/client/client.rb +2 -2
  132. data/test/client/master.rb +92 -3
  133. data/test/client/pelement.rb +99 -0
  134. data/test/executables/puppetbin.rb +3 -4
  135. data/test/executables/puppetca.rb +3 -3
  136. data/test/executables/puppetd.rb +3 -3
  137. data/test/executables/puppetmasterd.rb +1 -5
  138. data/test/executables/puppetmodule.rb +2 -2
  139. data/test/language/ast.rb +200 -11
  140. data/test/language/functions.rb +245 -0
  141. data/test/language/interpreter.rb +155 -6
  142. data/test/language/lexer.rb +35 -2
  143. data/test/language/node.rb +48 -1
  144. data/test/language/parser.rb +250 -1
  145. data/test/language/rails.rb +105 -0
  146. data/test/language/scope.rb +304 -10
  147. data/test/language/snippets.rb +54 -5
  148. data/test/language/transportable.rb +60 -28
  149. data/test/other/config.rb +214 -1
  150. data/test/other/events.rb +67 -9
  151. data/test/other/log.rb +31 -5
  152. data/test/other/metrics.rb +23 -21
  153. data/test/other/parsedfile.rb +29 -2
  154. data/test/other/puppet.rb +79 -0
  155. data/test/other/report.rb +106 -0
  156. data/test/other/storage.rb +2 -2
  157. data/test/other/transactions.rb +128 -2
  158. data/test/puppet/utiltest.rb +10 -5
  159. data/test/puppettest.rb +193 -21
  160. data/test/server/authstore.rb +13 -4
  161. data/test/server/bucket.rb +33 -8
  162. data/test/server/ca.rb +44 -6
  163. data/test/server/master.rb +6 -7
  164. data/test/server/pelement.rb +15 -5
  165. data/test/server/report.rb +93 -0
  166. data/test/server/runner.rb +107 -0
  167. data/test/server/server.rb +28 -1
  168. data/test/types/cron.rb +339 -31
  169. data/test/types/file.rb +256 -24
  170. data/test/types/filebucket.rb +6 -2
  171. data/test/types/filesources.rb +41 -92
  172. data/test/types/group.rb +31 -1
  173. data/test/types/host.rb +2 -1
  174. data/test/types/mount.rb +18 -1
  175. data/test/types/package.rb +200 -18
  176. data/test/types/service.rb +5 -1
  177. data/test/types/sshkey.rb +2 -1
  178. data/test/types/symlink.rb +3 -2
  179. data/test/types/type.rb +180 -1
  180. data/test/types/user.rb +65 -27
  181. data/test/types/yumrepo.rb +15 -0
  182. data/test/types/zone.rb +437 -0
  183. metadata +43 -4
  184. data/bin/cf2puppet +0 -186
  185. data/conf/redhat/puppetmasterd.conf +0 -5
@@ -0,0 +1 @@
1
+ $variable = file { "/etc/passwd": owner => root }
@@ -0,0 +1,23 @@
1
+ # $Id: deepclassheirarchy.pp 1185 2006-05-12 22:22:45Z luke $
2
+
3
+ class base {
4
+ file { "/tmp/deepclassheir1": ensure => file, mode => 755 }
5
+ }
6
+
7
+ class sub1 inherits base {
8
+ file { "/tmp/deepclassheir2": ensure => file, mode => 755 }
9
+ }
10
+
11
+ class sub2 inherits sub1 {
12
+ file { "/tmp/deepclassheir3": ensure => file, mode => 755 }
13
+ }
14
+
15
+ class sub3 inherits sub2 {
16
+ file { "/tmp/deepclassheir4": ensure => file, mode => 755 }
17
+ }
18
+
19
+ class sub4 inherits sub3 {
20
+ file { "/tmp/deepclassheir5": ensure => file, mode => 755 }
21
+ }
22
+
23
+ include sub4
@@ -0,0 +1,17 @@
1
+ # $Id: defineoverrides.pp 1181 2006-05-09 06:01:04Z luke $
2
+
3
+ $file = "/tmp/defineoverrides1"
4
+
5
+ define myfile(mode) {
6
+ file { $name: ensure => file, mode => $mode }
7
+ }
8
+
9
+ class base {
10
+ myfile { $file: mode => 644 }
11
+ }
12
+
13
+ class sub inherits base {
14
+ myfile { $file: mode => 755 }
15
+ }
16
+
17
+ include sub
@@ -0,0 +1,3 @@
1
+ exec { "touch /tmp/emptyexectest":
2
+ path => "/usr/bin:/bin"
3
+ }
@@ -30,8 +30,13 @@ $mode5 = yay ? {
30
30
  default => 644
31
31
  }
32
32
 
33
+ $mode6 = $mode5 ? {
34
+ 755 => 755
35
+ }
36
+
33
37
  file { "/tmp/selectorvalues1": ensure => file, mode => $mode1 }
34
38
  file { "/tmp/selectorvalues2": ensure => file, mode => $mode2 }
35
39
  file { "/tmp/selectorvalues3": ensure => file, mode => $mode3 }
36
40
  file { "/tmp/selectorvalues4": ensure => file, mode => $mode4 }
37
- file { "/tmp/selectorvalues5": ensure => file, mode => $mode4 }
41
+ file { "/tmp/selectorvalues5": ensure => file, mode => $mode5 }
42
+ file { "/tmp/selectorvalues6": ensure => file, mode => $mode6 }
@@ -0,0 +1,35 @@
1
+ # $Id: tagged.pp 1139 2006-04-26 17:01:46Z luke $
2
+
3
+ tag testing
4
+ tag(funtest)
5
+
6
+ define tagdefine {
7
+ $path = tagged(tagdefine) ? {
8
+ true => "true", false => "false"
9
+ }
10
+
11
+ file { "/tmp/taggeddefine$path": ensure => file }
12
+ }
13
+
14
+ tagdefine {}
15
+
16
+ $yayness = tagged(yayness) ? {
17
+ true => "true", false => "false"
18
+ }
19
+
20
+ $testing = tagged(testing) ? {
21
+ true => "true", false => "false"
22
+ }
23
+
24
+ $both = tagged(testing, yayness) ? {
25
+ true => "true", false => "false"
26
+ }
27
+
28
+ $bothtrue = tagged(testing, testing) ? {
29
+ true => "true", false => "false"
30
+ }
31
+
32
+ file { "/tmp/taggedyayness$yayness": ensure => file }
33
+ file { "/tmp/taggedtesting$testing": ensure => file }
34
+ file { "/tmp/taggedboth$both": ensure => file }
35
+ file { "/tmp/taggedbothtrue$bothtrue": ensure => file }
@@ -1,6 +1,6 @@
1
1
  # These OIDs are all fake. No guarantees there won't be conflicts.
2
2
  #
3
- # $Id: puppet.schema 931 2006-02-23 20:21:10Z luke $
3
+ # $Id: puppet.schema 1260 2006-06-13 18:09:07Z luke $
4
4
 
5
5
  attributetype ( 1.1.3.10 NAME 'puppetclass'
6
6
  DESC 'Puppet Node Class'
@@ -12,6 +12,6 @@ attributetype ( 1.1.3.9 NAME 'parentnode'
12
12
  EQUALITY caseIgnoreIA5Match
13
13
  SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
14
14
 
15
- objectclass ( 1.1.1.2 NAME 'puppetClient' SUP ipHost AUXILIARY
15
+ objectclass ( 1.1.1.2 NAME 'puppetClient' SUP top AUXILIARY
16
16
  DESC 'Puppet Client objectclass'
17
17
  MAY ( puppetclass $ parentnode ))
data/install.rb CHANGED
@@ -30,7 +30,7 @@
30
30
  # 5) Install all library files ending in .rb from lib/ into Ruby's
31
31
  # site_lib/version directory.
32
32
  #
33
- # $Id: install.rb 1030 2006-03-14 04:29:26Z luke $
33
+ # $Id: install.rb 1266 2006-06-13 23:07:18Z luke $
34
34
  #++
35
35
 
36
36
  require 'rbconfig'
@@ -167,6 +167,7 @@ def prepare_installation
167
167
  FileUtils.makedirs(bd)
168
168
  FileUtils.makedirs(sd)
169
169
  else
170
+ bd = Config::CONFIG['bindir']
170
171
  bds << Config::CONFIG['bindir']
171
172
  end
172
173
 
@@ -278,6 +279,7 @@ def install_binfile(from, op_file, target)
278
279
  installed_wrapper = true
279
280
  end
280
281
  end
282
+ p target
281
283
  FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true)
282
284
  File.unlink(tmp_file)
283
285
  end
@@ -299,5 +301,5 @@ prepare_installation
299
301
  run_tests(tests) if InstallOptions.tests
300
302
  #build_rdoc(rdoc) if InstallOptions.rdoc
301
303
  #build_ri(ri) if InstallOptions.ri
302
- do_bins(bins, Config::CONFIG['bindir'])
304
+ do_bins(bins, InstallOptions.bin_dir)
303
305
  do_libs(libs)
data/lib/puppet.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'singleton'
2
2
  require 'puppet/event-loop'
3
+ require 'puppet/util'
3
4
  require 'puppet/log'
4
5
  require 'puppet/config'
5
- require 'puppet/util'
6
6
 
7
7
  # see the bottom of the file for further inclusions
8
8
 
@@ -14,12 +14,23 @@ require 'puppet/util'
14
14
  #
15
15
  # it's also a place to find top-level commands like 'debug'
16
16
  module Puppet
17
- PUPPETVERSION = '0.16.0'
17
+ PUPPETVERSION = '0.18.4'
18
18
 
19
19
  def Puppet.version
20
20
  return PUPPETVERSION
21
21
  end
22
22
 
23
+ class << self
24
+ # So we can monitor signals and such.
25
+ include SignalObserver
26
+
27
+ include Puppet::Util
28
+
29
+ # To keep a copy of arguments. Set within Config#addargs, because I'm
30
+ # lazy.
31
+ attr_accessor :args
32
+ end
33
+
23
34
  class Error < RuntimeError
24
35
  attr_accessor :stack, :line, :file
25
36
  attr_writer :backtrace
@@ -65,6 +76,9 @@ module Puppet
65
76
  # the hash that determines how our system behaves
66
77
  @@config = Puppet::Config.new
67
78
 
79
+ # The services running in this process.
80
+ @services ||= []
81
+
68
82
  # define helper messages for each of the message levels
69
83
  Puppet::Log.eachlevel { |level|
70
84
  define_method(level,proc { |args|
@@ -100,10 +114,28 @@ module Puppet
100
114
  conf = "/etc/puppet"
101
115
  var = "/var/puppet"
102
116
  end
117
+
103
118
  self.setdefaults(:puppet,
104
119
  :confdir => [conf, "The main Puppet configuration directory."],
105
- :vardir => [var, "Where Puppet stores dynamic and growing data."],
106
- :logdir => ["$vardir/log", "The Puppet log directory."],
120
+ :vardir => [var, "Where Puppet stores dynamic and growing data."]
121
+ )
122
+
123
+ if self.name == "puppetmasterd"
124
+ self.setdefaults(:puppetmasterd,
125
+ :logdir => {:default => "$vardir/log",
126
+ :mode => 0750,
127
+ :owner => "$user",
128
+ :group => "$group",
129
+ :desc => "The Puppet log directory."
130
+ }
131
+ )
132
+ else
133
+ self.setdefaults(:puppet,
134
+ :logdir => ["$vardir/log", "The Puppet log directory."]
135
+ )
136
+ end
137
+
138
+ self.setdefaults(:puppet,
107
139
  :statedir => { :default => "$vardir/state",
108
140
  :mode => 01777,
109
141
  :desc => "The directory where Puppet state is stored. Generally,
@@ -209,11 +241,6 @@ module Puppet
209
241
  :runinterval => [1800, # 30 minutes
210
242
  "How often puppetd applies the client configuration; in seconds"]
211
243
  )
212
- self.setdefaults("metrics",
213
- :rrddir => ["$vardir/rrd",
214
- "The directory where RRD database files are stored."],
215
- :rrdgraph => [false, "Whether RRD information should be graphed."]
216
- )
217
244
 
218
245
  # configuration parameter access and stuff
219
246
  def self.[](param)
@@ -264,11 +291,175 @@ module Puppet
264
291
  end
265
292
  end
266
293
 
267
- # Start our event loop. This blocks, waiting for someone, somewhere,
268
- # to generate events of some kind.
269
- def self.start
270
- #Puppet.info "Starting loop"
271
- EventLoop.current.run
294
+ # Run all threads to their ends
295
+ def self.join
296
+ defined? @threads and @threads.each do |t| t.join end
297
+ end
298
+
299
+ # Create a new service that we're supposed to run
300
+ def self.newservice(service)
301
+ @services ||= []
302
+
303
+ @services << service
304
+ end
305
+
306
+ def self.newthread(&block)
307
+ @threads ||= []
308
+
309
+ @threads << Thread.new do
310
+ yield
311
+ end
312
+ end
313
+
314
+ def self.newtimer(hash, &block)
315
+ timer = nil
316
+ threadlock(:timers) do
317
+ @timers ||= []
318
+ timer = EventLoop::Timer.new(hash)
319
+ @timers << timer
320
+
321
+ if block_given?
322
+ observe_signal(timer, :alarm, &block)
323
+ end
324
+ end
325
+
326
+ # In case they need it for something else.
327
+ timer
328
+ end
329
+
330
+ # Relaunch the executable.
331
+ def self.restart
332
+ command = $0 + " " + self.args.join(" ")
333
+ Puppet.notice "Restarting with '%s'" % command
334
+ Puppet.shutdown(false)
335
+ exec(command)
336
+ end
337
+
338
+ # Trap a couple of the main signals. This should probably be handled
339
+ # in a way that anyone else can register callbacks for traps, but, eh.
340
+ def self.settraps
341
+ [:INT, :TERM].each do |signal|
342
+ trap(signal) do
343
+ Puppet.notice "Caught #{signal}; shutting down"
344
+ Puppet.shutdown
345
+ end
346
+ end
347
+
348
+ # Handle restarting.
349
+ trap(:HUP) do
350
+ if client = @services.find { |s| s.is_a? Puppet::Client::MasterClient } and client.running?
351
+ client.restart
352
+ else
353
+ Puppet.restart
354
+ end
355
+ end
356
+
357
+ # Provide a hook for running clients where appropriate
358
+ trap(:USR1) do
359
+ done = 0
360
+ Puppet.notice "Caught USR1; triggering client run"
361
+ @services.find_all { |s| s.is_a? Puppet::Client }.each do |client|
362
+ if client.respond_to? :running?
363
+ if client.running?
364
+ Puppet.info "Ignoring running %s" % client.class
365
+ else
366
+ done += 1
367
+ begin
368
+ client.runnow
369
+ rescue => detail
370
+ Puppet.err "Could not run client: %s" % detail
371
+ end
372
+ end
373
+ else
374
+ Puppet.info "Ignoring %s; cannot test whether it is running" %
375
+ client.class
376
+ end
377
+ end
378
+
379
+ unless done > 0
380
+ Puppet.notice "No clients were run"
381
+ end
382
+ end
383
+ end
384
+
385
+ # Shutdown our server process, meaning stop all services and all threads.
386
+ # Optionally, exit.
387
+ def self.shutdown(leave = true)
388
+ Puppet.notice "Shutting down"
389
+ # Unmonitor our timers
390
+ defined? @timers and @timers.each do |timer|
391
+ EventLoop.current.ignore_timer timer
392
+ end
393
+
394
+ # This seems to exit the process, although I can't find where it does
395
+ # so. Leaving it out doesn't seem to hurt anything.
396
+ #if EventLoop.current.running?
397
+ # EventLoop.current.quit
398
+ #end
399
+
400
+ # Stop our services
401
+ defined? @services and @services.each do |svc|
402
+ begin
403
+ timeout(20) do
404
+ svc.shutdown
405
+ end
406
+ rescue TimeoutError
407
+ Puppet.err "%s could not shut down within 20 seconds" % svc.class
408
+ end
409
+ end
410
+
411
+ # And wait for them all to die, giving a decent amount of time
412
+ defined? @threads and @threads.each do |thr|
413
+ begin
414
+ timeout(20) do
415
+ thr.join
416
+ end
417
+ rescue TimeoutError
418
+ # Just ignore this, since we can't intelligently provide a warning
419
+ end
420
+ end
421
+
422
+ if leave
423
+ exit(0)
424
+ end
425
+ end
426
+
427
+ # Start all of our services and optionally our event loop, which blocks,
428
+ # waiting for someone, somewhere, to generate events of some kind.
429
+ def self.start(block = true)
430
+ # Starting everything in its own thread, fwiw
431
+ defined? @services and @services.each do |svc|
432
+ newthread do
433
+ begin
434
+ svc.start
435
+ rescue => detail
436
+ if Puppet[:debug]
437
+ puts detail.backtrace
438
+ end
439
+ @services.delete svc
440
+ Puppet.err "Could not start %s: %s" % [svc.class, detail]
441
+ end
442
+ end
443
+ end
444
+
445
+ unless @services.length > 0
446
+ Puppet.notice "No remaining services; exiting"
447
+ exit(1)
448
+ end
449
+
450
+ # We need to give the services a chance to register their timers before
451
+ # we try to start monitoring them.
452
+ sleep 0.5
453
+
454
+ if defined? @timers and ! @timers.empty?
455
+ @timers.each do |timer|
456
+ EventLoop.current.monitor_timer timer
457
+ end
458
+ end
459
+
460
+ if block
461
+ EventLoop.current.run
462
+ end
272
463
  end
273
464
 
274
465
  # Create the timer that our different objects (uh, mostly the client)
@@ -333,4 +524,4 @@ require 'puppet/server'
333
524
  require 'puppet/type'
334
525
  require 'puppet/storage'
335
526
 
336
- # $Id: puppet.rb 1094 2006-04-06 06:51:26Z luke $
527
+ # $Id: puppet.rb 1426 2006-07-22 21:10:47Z luke $
data/lib/puppet/client.rb CHANGED
@@ -9,11 +9,9 @@ module Puppet
9
9
  # but at least it's better organized for now
10
10
  class Client
11
11
  include Puppet
12
- include SignalObserver
13
12
 
14
13
  include Puppet::Util
15
14
 
16
-
17
15
  # FIXME The cert stuff should only come up with networking, so it
18
16
  # should be in the network client, not the normal client. But if i do
19
17
  # that, it's hard to tell whether the certs have been initialized.
@@ -22,7 +20,8 @@ module Puppet
22
20
  attr_accessor :schedule, :lastrun, :local, :stopping
23
21
 
24
22
  class << self
25
- attr_reader :drivername
23
+ attr_reader :drivername, :handler
24
+ attr_accessor :netclient
26
25
  end
27
26
 
28
27
  def initcerts
@@ -75,7 +74,17 @@ module Puppet
75
74
  args[:CAFile] = @cacertfile
76
75
  end
77
76
 
78
- @driver = Puppet::NetworkClient.new(args)
77
+ netclient = nil
78
+ unless netclient = self.class.netclient
79
+ unless handler = self.class.handler
80
+ raise Puppet::DevError,
81
+ "Class %s has no handler defined" % self.class
82
+ end
83
+ namespace = self.class.handler.interface.prefix
84
+ netclient = Puppet::NetworkClient.netclient(namespace)
85
+ self.class.netclient = netclient
86
+ end
87
+ @driver = netclient.new(args)
79
88
  @local = false
80
89
  elsif hash.include?(driverparam)
81
90
  @driver = hash[driverparam]
@@ -96,6 +105,9 @@ module Puppet
96
105
  self.run
97
106
  self.lastrun = Time.now.to_i
98
107
  rescue => detail
108
+ if Puppet[:debug]
109
+ puts detail.backtrace
110
+ end
99
111
  Puppet.err "Could not run %s: %s" % [self.class, detail]
100
112
  end
101
113
  end
@@ -119,39 +131,34 @@ module Puppet
119
131
  @driver.ca_file = @cacertfile
120
132
  end
121
133
 
122
- # FIXME this should probably not store every single time.
123
134
  def shutdown
124
135
  if self.stopping
125
136
  Puppet.notice "Already in shutdown"
126
137
  else
127
138
  self.stopping = true
128
- Puppet::Storage.store
129
- exit
139
+ if self.respond_to? :running? and self.running?
140
+ Puppet::Storage.store
141
+ end
142
+ rmpidfile()
130
143
  end
131
144
  end
132
145
 
133
146
  # Start listening for events. We're pretty much just listening for
134
147
  # timer events here.
135
148
  def start
136
- # Create our timer
137
- timer = EventLoop::Timer.new(
149
+ # Create our timer. Puppet will handle observing it and such.
150
+ timer = Puppet.newtimer(
138
151
  :interval => Puppet[:runinterval],
139
152
  :tolerance => 1,
140
153
  :start? => true
141
- )
142
-
143
- # Stick it in the loop
144
- EventLoop.current.monitor_timer timer
145
-
146
- # Run once before we start following the timer
147
- self.runnow
148
-
149
- # And run indefinitely
150
- observe_signal timer, :alarm do
154
+ ) do
151
155
  if self.scheduled?
152
156
  self.runnow
153
157
  end
154
158
  end
159
+
160
+ # Run once before we start following the timer
161
+ self.runnow
155
162
  end
156
163
 
157
164
  require 'puppet/client/proxy'
@@ -160,8 +167,11 @@ module Puppet
160
167
  require 'puppet/client/file'
161
168
  require 'puppet/client/log'
162
169
  require 'puppet/client/master'
170
+ require 'puppet/client/runner'
163
171
  require 'puppet/client/status'
172
+ require 'puppet/client/reporter'
173
+ require 'puppet/client/pelement'
164
174
  end
165
175
  end
166
176
 
167
- # $Id: client.rb 1098 2006-04-10 22:13:10Z luke $
177
+ # $Id: client.rb 1339 2006-06-29 20:32:17Z luke $