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
@@ -1,4 +1,4 @@
1
- class Puppet::Client::CAClient < Puppet::Client::ProxyClient
1
+ class Puppet::Client::CA < Puppet::Client::ProxyClient
2
2
  @drivername = :CA
3
3
 
4
4
  # set up the appropriate interface methods
@@ -18,4 +18,4 @@ class Puppet::Client::CAClient < Puppet::Client::ProxyClient
18
18
  end
19
19
  end
20
20
 
21
- # $Id: ca.rb 965 2006-03-02 07:30:14Z luke $
21
+ # $Id: ca.rb 1160 2006-05-02 04:30:40Z luke $
@@ -3,6 +3,8 @@ module Puppet
3
3
  # The client class for filebuckets.
4
4
  class Dipper < Puppet::Client
5
5
  @drivername = :Bucket
6
+
7
+ @handler = Puppet::Server::FileBucket
6
8
 
7
9
  attr_accessor :name
8
10
 
@@ -10,7 +12,7 @@ module Puppet
10
12
  def initialize(hash = {})
11
13
  if hash.include?(:Path)
12
14
  bucket = Puppet::Server::FileBucket.new(
13
- :Bucket => hash[:Path]
15
+ :Path => hash[:Path]
14
16
  )
15
17
  hash.delete(:Path)
16
18
  hash[:Bucket] = bucket
@@ -24,13 +26,7 @@ module Puppet
24
26
  unless FileTest.exists?(file)
25
27
  raise(BucketError, "File %s does not exist" % file)
26
28
  end
27
- contents = File.read(file)
28
- string = Base64.encode64(contents)
29
-
30
- sum = @driver.addfile(string,file)
31
- string = ""
32
- contents = ""
33
- return sum
29
+ return @driver.addfile(Base64.encode64(File.read(file)),file)
34
30
  end
35
31
 
36
32
  # Restore the file
@@ -77,4 +73,4 @@ module Puppet
77
73
  end
78
74
  end
79
75
 
80
- # $Id: dipper.rb 1113 2006-04-17 16:15:33Z luke $
76
+ # $Id: dipper.rb 1224 2006-05-25 06:24:44Z luke $
@@ -2,7 +2,11 @@
2
2
  require 'sync'
3
3
 
4
4
  class Puppet::Client::MasterClient < Puppet::Client
5
- @@sync = Sync.new
5
+ unless defined? @@sync
6
+ @@sync = Sync.new
7
+ end
8
+
9
+ @handler = Puppet::Server::Master
6
10
 
7
11
  Puppet.setdefaults("puppetd",
8
12
  :puppetdlockfile => [ "$statedir/puppetdlock",
@@ -13,18 +17,49 @@ class Puppet::Client::MasterClient < Puppet::Client
13
17
  new configurations, where you want to fix the broken configuration
14
18
  rather than reverting to a known-good one."
15
19
  ]
20
+ )
16
21
 
22
+ Puppet.setdefaults(:puppetd,
23
+ :reportserver => ["$server",
24
+ "The server to which to send transaction reports."
25
+ ],
26
+ :report => [false,
27
+ "Whether to send reports after every transaction."
28
+ ]
29
+ )
17
30
 
31
+ Puppet.setdefaults("puppet",
32
+ :pluginpath => ["$vardir/plugins",
33
+ "Where Puppet should look for plugins. Multiple directories should
34
+ be colon-separated, like normal PATH variables."],
35
+ :plugindest => ["$vardir/plugins",
36
+ "Where Puppet should store plugins that it pulls down from the central
37
+ server."],
38
+ :pluginsource => ["puppet://$server/plugins",
39
+ "From where to retrieve plugins. The standard Puppet ``file`` type
40
+ is used for retrieval, so anything that is a valid file source can
41
+ be used here."],
42
+ :pluginsync => [false,
43
+ "Whether plugins should be synced with the central server."],
44
+ :pluginsignore => [".svn CVS",
45
+ "What files to ignore when pulling down plugins.."]
18
46
  )
19
47
 
20
48
  @drivername = :Master
21
49
 
22
50
  attr_accessor :objects
23
51
 
52
+ class << self
53
+ # Puppetd should only have one instance running, and we need a way
54
+ # to retrieve it.
55
+ attr_accessor :instance
56
+ include Puppet::Util
57
+ end
58
+
24
59
  def self.facts
25
60
  facts = {}
26
61
  Facter.each { |name,fact|
27
- facts[name] = fact.downcase
62
+ facts[name] = fact.to_s.downcase
28
63
  }
29
64
 
30
65
  # Add our client version to the list of facts, so people can use it
@@ -35,18 +70,23 @@ class Puppet::Client::MasterClient < Puppet::Client
35
70
  end
36
71
 
37
72
  # This method actually applies the configuration.
38
- def apply
73
+ def apply(tags = nil, ignoreschedules = false)
39
74
  dostorage()
40
75
  unless defined? @objects
41
76
  raise Puppet::Error, "Cannot apply; objects not defined"
42
77
  end
43
78
 
44
- # this is a gross hack... but i don't see a good way around it
45
- # set all of the variables to empty
46
- Puppet::Transaction.init
47
-
48
79
  transaction = @objects.evaluate
49
- transaction.toplevel = true
80
+
81
+ if tags
82
+ transaction.tags = tags
83
+ end
84
+
85
+ if ignoreschedules
86
+ transaction.ignoreschedules = true
87
+ end
88
+
89
+ transaction.addtimes :config_retrieval => @configtime
50
90
 
51
91
  begin
52
92
  transaction.evaluate
@@ -61,11 +101,17 @@ class Puppet::Client::MasterClient < Puppet::Client
61
101
  ensure
62
102
  Puppet::Storage.store
63
103
  end
64
- Puppet::Metric.gather
65
- Puppet::Metric.tally
66
- if Puppet[:rrdgraph] == true
67
- Metric.store
68
- Metric.graph
104
+
105
+ if Puppet[:report]
106
+ begin
107
+ report = transaction.report()
108
+ if Puppet[:rrdgraph] == true
109
+ report.graph()
110
+ end
111
+ reportclient().report(report)
112
+ rescue => detail
113
+ Puppet.err "Reporting failed: %s" % detail
114
+ end
69
115
  end
70
116
 
71
117
  return transaction
@@ -92,21 +138,29 @@ class Puppet::Client::MasterClient < Puppet::Client
92
138
  @cachefile
93
139
  end
94
140
 
141
+ def clear
142
+ #@objects = nil
143
+ @objects.remove(true)
144
+ Puppet::Type.allclear
145
+ end
146
+
95
147
  # Disable running the configuration. This can be used from the command line, but
96
148
  # is also used to make sure only one client is running at a time.
97
149
  def disable(running = false)
98
- text = nil
99
- if running
100
- text = Process.pid
101
- else
102
- text = ""
103
- Puppet.notice "Disabling puppetd"
104
- end
105
- Puppet.config.use(:puppet)
106
- begin
107
- File.open(Puppet[:puppetdlockfile], "w") { |f| f.puts text }
108
- rescue => detail
109
- raise Puppet::Error, "Could not lock puppetd: %s" % detail
150
+ threadlock(:puppetd) do
151
+ text = nil
152
+ if running
153
+ text = Process.pid
154
+ else
155
+ text = ""
156
+ Puppet.notice "Disabling puppetd"
157
+ end
158
+ Puppet.config.use(:puppet)
159
+ begin
160
+ File.open(Puppet[:puppetdlockfile], "w") { |f| f.puts text }
161
+ rescue => detail
162
+ raise Puppet::Error, "Could not lock puppetd: %s" % detail
163
+ end
110
164
  end
111
165
  end
112
166
 
@@ -130,11 +184,13 @@ class Puppet::Client::MasterClient < Puppet::Client
130
184
  # Enable running again. This can be used from the command line, but
131
185
  # is also used to make sure only one client is running at a time.
132
186
  def enable(running = false)
133
- unless running
134
- Puppet.notice "Enabling puppetd"
135
- end
136
- if FileTest.exists? Puppet[:puppetdlockfile]
137
- File.unlink(Puppet[:puppetdlockfile])
187
+ threadlock(:puppetd) do
188
+ unless running
189
+ Puppet.debug "Enabling puppetd"
190
+ end
191
+ if FileTest.exists? Puppet[:puppetdlockfile]
192
+ File.unlink(Puppet[:puppetdlockfile])
193
+ end
138
194
  end
139
195
  end
140
196
 
@@ -170,6 +226,11 @@ class Puppet::Client::MasterClient < Puppet::Client
170
226
  )
171
227
  end
172
228
 
229
+ # Retrieve the plugins.
230
+ if Puppet[:pluginsync]
231
+ getplugins()
232
+ end
233
+
173
234
  objects = nil
174
235
  if @local
175
236
  # If we're local, we don't have to do any of the conversion
@@ -243,6 +304,9 @@ class Puppet::Client::MasterClient < Puppet::Client
243
304
  # Clear all existing objects, so we can recreate our stack.
244
305
  if defined? @objects
245
306
  Puppet::Type.allclear
307
+
308
+ # Make sure all of the objects are really gone.
309
+ @objects.remove(true)
246
310
  end
247
311
  @objects = nil
248
312
 
@@ -255,7 +319,6 @@ class Puppet::Client::MasterClient < Puppet::Client
255
319
  if @objects.nil?
256
320
  raise Puppet::Error, "Configuration could not be processed"
257
321
  end
258
- #@objects = objects
259
322
 
260
323
  # and perform any necessary final actions before we evaluate.
261
324
  @objects.finalize
@@ -263,6 +326,16 @@ class Puppet::Client::MasterClient < Puppet::Client
263
326
  return @objects
264
327
  end
265
328
 
329
+ # Just so we can specify that we are "the" instance.
330
+ def initialize(*args)
331
+ super
332
+
333
+ @configtime = Time.now
334
+
335
+ self.class.instance = self
336
+ @running = false
337
+ end
338
+
266
339
  # Make sure only one client runs at a time, and make sure only one thread
267
340
  # runs at a time. However, this does not lock local clients -- you could have
268
341
  # as many separate puppet scripts running as you want.
@@ -270,27 +343,48 @@ class Puppet::Client::MasterClient < Puppet::Client
270
343
  if @local
271
344
  yield
272
345
  else
273
- @@sync.synchronize(Sync::EX) do
346
+ #@@sync.synchronize(Sync::EX) do
274
347
  disable(true)
275
348
  begin
276
349
  yield
277
350
  ensure
278
351
  enable(true)
279
352
  end
280
- end
353
+ #end
281
354
  end
282
355
  end
283
356
 
284
357
  def locked?
358
+ return(FileTest.exists? Puppet[:puppetdlockfile])
359
+ end
360
+
361
+ def lockpid
285
362
  if FileTest.exists? Puppet[:puppetdlockfile]
286
363
  text = File.read(Puppet[:puppetdlockfile]).chomp
287
364
  if text =~ /\d+/
288
- return text
365
+ return text.to_i
289
366
  else
290
- return true
367
+ return 0
291
368
  end
292
369
  else
293
- return false
370
+ return 0
371
+ end
372
+ end
373
+
374
+ # Mark that we should restart. The Puppet module checks whether we're running,
375
+ # so this only gets called if we're in the middle of a run.
376
+ def restart
377
+ # If we're currently running, then just mark for later
378
+ Puppet.notice "Received signal to restart; waiting until run is complete"
379
+ @restart = true
380
+ end
381
+
382
+ # Should we restart?
383
+ def restart?
384
+ if defined? @restart
385
+ @restart
386
+ else
387
+ false
294
388
  end
295
389
  end
296
390
 
@@ -304,30 +398,59 @@ class Puppet::Client::MasterClient < Puppet::Client
304
398
  end
305
399
 
306
400
  # The code that actually runs the configuration.
307
- def run
308
- if pid = locked?
309
- t = ""
310
- if pid == true
311
- Puppet.notice "Locked by process %s" % pid
401
+ def run(tags = nil, ignoreschedules = false)
402
+ # Check if the lock is stale, so we can clear it
403
+ if locked?
404
+ pid = lockpid
405
+
406
+ if pid != 0
407
+ begin
408
+ Process.kill(0, pid)
409
+ rescue Errno::ESRCH
410
+ # No process with the given PID exists; stale lockfile
411
+ File.unlink(Puppet[:puppetdlockfile])
412
+ Puppet.notice("Stale lockfile %s left by process %i; removing" %
413
+ [Puppet[:puppetdlockfile], pid])
414
+ lockpid = false
415
+ else
416
+ Puppet.notice "Locked by process %s" % pid
417
+ end
312
418
  end
419
+ end
420
+
421
+ if locked?
313
422
  Puppet.notice "Lock file %s exists; skipping configuration run" %
314
423
  Puppet[:puppetdlockfile]
315
424
  else
316
425
  lock do
317
- self.getconfig
426
+ @running = true
427
+ @configtime = thinmark do
428
+ self.getconfig
429
+ end
318
430
 
319
431
  if defined? @objects and @objects
320
432
  unless @local
321
433
  Puppet.notice "Starting configuration run"
322
434
  end
323
435
  benchmark(:notice, "Finished configuration run") do
324
- self.apply
436
+ self.apply(tags, ignoreschedules)
325
437
  end
326
438
  end
439
+ @running = false
440
+ end
441
+
442
+ # Did we get HUPped during the run? If so, then restart now that we're
443
+ # done with the run.
444
+ if self.restart?
445
+ Process.kill(:HUP, $$)
327
446
  end
328
447
  end
329
448
  end
330
449
 
450
+ def running?
451
+ @running
452
+ end
453
+
331
454
  # Store the classes in the classfile, but only if we're not local.
332
455
  def setclasses(ary)
333
456
  if @local
@@ -346,6 +469,63 @@ class Puppet::Client::MasterClient < Puppet::Client
346
469
  [Puppet[:classfile], detail]
347
470
  end
348
471
  end
472
+
473
+ private
474
+ # Retrieve the plugins from the central server.
475
+ def getplugins
476
+ plugins = Puppet::Type.type(:component).create(
477
+ :name => "plugin_collector"
478
+ )
479
+ plugins.push Puppet::Type.type(:file).create(
480
+ :path => Puppet[:plugindest],
481
+ :recurse => true,
482
+ :source => Puppet[:pluginsource],
483
+ :ignore => Puppet[:pluginsignore].split(/\s+/),
484
+ :tag => "plugins",
485
+ :owner => "root"
486
+ )
487
+
488
+ Puppet.info "Retrieving plugins"
489
+
490
+
491
+ begin
492
+ trans = plugins.evaluate
493
+ trans.evaluate
494
+ rescue Puppet::Error => detail
495
+ if Puppet[:debug]
496
+ puts detail.backtrace
497
+ end
498
+ Puppet.err "Could not retrieve plugins: %s" % detail
499
+ end
500
+
501
+ # Now source all of the changed objects, but only source those
502
+ # that are top-level.
503
+ trans.changed?.find_all { |object|
504
+ File.dirname(object[:path]) == Puppet[:pluginpath]
505
+ }.each do |object|
506
+ begin
507
+ Puppet.info "Loading plugin %s" %
508
+ File.basename(object[:path]).sub(".rb",'')
509
+ load object[:path]
510
+ rescue => detail
511
+ Puppet.warning "Could not load %s: %s" %
512
+ [object[:path], detail]
513
+ end
514
+ end
515
+
516
+ # Now clean up after ourselves
517
+ plugins.remove
518
+ end
519
+
520
+ def reportclient
521
+ unless defined? @reportclient
522
+ @reportclient = Puppet::Client::Reporter.new(
523
+ :Server => Puppet[:reportserver]
524
+ )
525
+ end
526
+
527
+ @reportclient
528
+ end
349
529
  end
350
530
 
351
- # $Id: master.rb 1129 2006-04-21 19:14:59Z luke $
531
+ # $Id: master.rb 1422 2006-07-22 03:32:56Z luke $