puppet 0.23.0 → 0.23.1

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 (125) hide show
  1. data/CHANGELOG +58 -0
  2. data/Rakefile +1 -1
  3. data/bin/filebucket +6 -6
  4. data/bin/puppetca +11 -1
  5. data/bin/puppetmasterd +7 -6
  6. data/conf/redhat/client.init +1 -0
  7. data/conf/redhat/{puppetd.conf → puppet.conf} +1 -1
  8. data/conf/redhat/puppet.spec +43 -31
  9. data/conf/redhat/server.init +1 -0
  10. data/lib/puppet.rb +3 -3
  11. data/lib/puppet/configuration.rb +16 -5
  12. data/lib/puppet/metatype/attributes.rb +12 -19
  13. data/lib/puppet/metatype/evaluation.rb +10 -1
  14. data/lib/puppet/metatype/instances.rb +39 -15
  15. data/lib/puppet/metatype/manager.rb +1 -28
  16. data/lib/puppet/metatype/metaparams.rb +20 -16
  17. data/lib/puppet/metatype/providers.rb +8 -2
  18. data/lib/puppet/metatype/schedules.rb +14 -19
  19. data/lib/puppet/{modules.rb → module.rb} +2 -0
  20. data/lib/puppet/network/authstore.rb +5 -1
  21. data/lib/puppet/network/client/dipper.rb +2 -2
  22. data/lib/puppet/network/client/master.rb +18 -9
  23. data/lib/puppet/network/handler/fileserver.rb +3 -6
  24. data/lib/puppet/network/handler/report.rb +2 -1
  25. data/lib/puppet/network/server/mongrel.rb +4 -2
  26. data/lib/puppet/network/xmlrpc/client.rb +10 -3
  27. data/lib/puppet/parameter.rb +11 -4
  28. data/lib/puppet/parser/ast/collexpr.rb +10 -10
  29. data/lib/puppet/parser/ast/hostclass.rb +2 -2
  30. data/lib/puppet/parser/ast/resourceparam.rb +4 -3
  31. data/lib/puppet/parser/ast/resourceref.rb +16 -2
  32. data/lib/puppet/parser/collector.rb +8 -4
  33. data/lib/puppet/parser/functions.rb +5 -2
  34. data/lib/puppet/parser/interpreter.rb +48 -9
  35. data/lib/puppet/parser/lexer.rb +2 -1
  36. data/lib/puppet/parser/parser.rb +669 -589
  37. data/lib/puppet/parser/resource.rb +20 -11
  38. data/lib/puppet/parser/resource/param.rb +21 -10
  39. data/lib/puppet/parser/resource/reference.rb +2 -2
  40. data/lib/puppet/parser/scope.rb +22 -10
  41. data/lib/puppet/{type/property.rb → property.rb} +48 -15
  42. data/lib/puppet/propertychange.rb +3 -3
  43. data/lib/puppet/provider/cron/crontab.rb +38 -36
  44. data/lib/puppet/provider/host/netinfo.rb +1 -2
  45. data/lib/puppet/provider/mailalias/aliases.rb +31 -0
  46. data/lib/puppet/provider/maillist/mailman.rb +113 -0
  47. data/lib/puppet/provider/mount.rb +5 -11
  48. data/lib/puppet/provider/mount/parsed.rb +2 -2
  49. data/lib/puppet/provider/package/appdmg.rb +1 -2
  50. data/lib/puppet/provider/package/apt.rb +3 -1
  51. data/lib/puppet/provider/package/aptrpm.rb +14 -4
  52. data/lib/puppet/provider/package/blastwave.rb +6 -4
  53. data/lib/puppet/provider/package/dpkg.rb +12 -4
  54. data/lib/puppet/provider/package/pkgdmg.rb +2 -2
  55. data/lib/puppet/provider/package/rpm.rb +11 -1
  56. data/lib/puppet/provider/package/rug.rb +1 -0
  57. data/lib/puppet/provider/package/urpmi.rb +11 -1
  58. data/lib/puppet/provider/package/yum.rb +12 -2
  59. data/lib/puppet/provider/parsedfile.rb +36 -6
  60. data/lib/puppet/rails.rb +9 -2
  61. data/lib/puppet/rails/param_name.rb +2 -3
  62. data/lib/puppet/rails/param_value.rb +20 -1
  63. data/lib/puppet/rails/resource.rb +8 -2
  64. data/lib/puppet/reference/configuration.rb +14 -16
  65. data/lib/puppet/reference/type.rb +4 -4
  66. data/lib/puppet/transaction.rb +4 -4
  67. data/lib/puppet/type.rb +19 -6
  68. data/lib/puppet/type/component.rb +9 -3
  69. data/lib/puppet/type/cron.rb +10 -4
  70. data/lib/puppet/type/exec.rb +9 -5
  71. data/lib/puppet/type/group.rb +2 -3
  72. data/lib/puppet/type/mailalias.rb +50 -0
  73. data/lib/puppet/type/maillist.rb +57 -0
  74. data/lib/puppet/type/mount.rb +25 -11
  75. data/lib/puppet/type/package.rb +6 -27
  76. data/lib/puppet/type/pfile.rb +5 -6
  77. data/lib/puppet/type/pfile/source.rb +8 -2
  78. data/lib/puppet/type/pfilebucket.rb +4 -3
  79. data/lib/puppet/type/resources.rb +1 -3
  80. data/lib/puppet/type/schedule.rb +16 -16
  81. data/lib/puppet/type/service.rb +4 -1
  82. data/lib/puppet/type/tidy.rb +1 -2
  83. data/lib/puppet/type/user.rb +2 -3
  84. data/lib/puppet/type/yumrepo.rb +2 -2
  85. data/lib/puppet/util.rb +29 -4
  86. data/lib/puppet/util/autoload.rb +45 -16
  87. data/lib/puppet/util/fileparsing.rb +23 -6
  88. data/lib/puppet/util/filetype.rb +12 -1
  89. data/lib/puppet/util/log.rb +2 -2
  90. data/lib/puppet/util/log_paths.rb +16 -0
  91. data/lib/puppet/util/reference.rb +2 -2
  92. data/test/language/ast/hostclass.rb +21 -4
  93. data/test/language/ast/resourceref.rb +95 -0
  94. data/test/language/functions.rb +5 -5
  95. data/test/language/interpreter.rb +129 -1
  96. data/test/language/node.rb +13 -2
  97. data/test/language/resource.rb +26 -1
  98. data/test/language/scope.rb +25 -5
  99. data/test/lib/puppettest/support/collection.rb +2 -2
  100. data/test/network/client/master.rb +28 -42
  101. data/test/network/server/mongrel_test.rb +7 -1
  102. data/test/other/propertychange.rb +2 -2
  103. data/test/other/transactions.rb +44 -5
  104. data/test/puppet/modules.rb +2 -1
  105. data/test/rails/ast.rb +7 -8
  106. data/test/rails/collection.rb +2 -2
  107. data/test/rails/railsresource.rb +21 -5
  108. data/test/ral/manager/attributes.rb +33 -1
  109. data/test/ral/manager/instances.rb +33 -6
  110. data/test/ral/manager/type.rb +29 -49
  111. data/test/ral/providers/cron/crontab.rb +61 -13
  112. data/test/ral/providers/mailalias/aliases.rb +57 -0
  113. data/test/ral/providers/mount/parsed.rb +4 -4
  114. data/test/ral/providers/package/apt.rb +13 -1
  115. data/test/ral/providers/parsedfile.rb +20 -7
  116. data/test/ral/types/cron.rb +17 -1
  117. data/test/ral/types/mailalias.rb +50 -0
  118. data/test/ral/types/mount.rb +35 -2
  119. data/test/ral/types/package.rb +10 -2
  120. data/test/ral/types/parameter.rb +4 -4
  121. data/test/ral/types/property.rb +39 -1
  122. data/test/util/autoload.rb +33 -18
  123. data/test/util/filetype.rb +49 -3
  124. metadata +13 -6
  125. data/lib/puppet/element.rb +0 -52
@@ -207,9 +207,9 @@ class Puppet::Parser::Resource
207
207
  db_resource.ar_hash_merge(db_resource.get_tag_hash(),
208
208
  updated_tags,
209
209
  :create => Proc.new { |name, tag|
210
- db_resource.add_resource_tag(tag)
211
- }, :delete => Proc.new { |rt|
212
- rt.each { |tag| db_resource.resource_tags.delete(tag) }
210
+ db_resource.add_resource_tag(name)
211
+ }, :delete => Proc.new { |tag|
212
+ db_resource.resource_tags.delete(tag)
213
213
  }, :modify => Proc.new { |db, mem|
214
214
  # nothing here
215
215
  })
@@ -263,8 +263,14 @@ class Puppet::Parser::Resource
263
263
  paramcheck(param.name)
264
264
 
265
265
  if current = @params[param.name]
266
- # XXX Should we ignore any settings that have the same values?
266
+ # This is where we'd ignore any equivalent values if we wanted to,
267
+ # but that would introduce a lot of really bad ordering issues.
267
268
  if param.source.child_of?(current.source)
269
+ if param.add
270
+ # Merge with previous value.
271
+ param.value = [ current.value, param.value ].flatten
272
+ end
273
+
268
274
  # Replace it, keeping all of its info.
269
275
  @params[param.name] = param
270
276
  else
@@ -273,17 +279,20 @@ class Puppet::Parser::Resource
273
279
  end
274
280
  msg = "Parameter '%s' is already set on %s" %
275
281
  [param.name, self.to_s]
276
- if param.source.to_s != ""
277
- msg += " by %s" % param.source
282
+ if current.source.to_s != ""
283
+ msg += " by %s" % current.source
278
284
  end
279
- if param.file or param.line
285
+ if current.file or current.line
280
286
  fields = []
281
- fields << param.file if param.file
282
- fields << param.line.to_s if param.line
287
+ fields << current.file if current.file
288
+ fields << current.line.to_s if current.line
283
289
  msg += " at %s" % fields.join(":")
284
290
  end
285
291
  msg += "; cannot redefine"
286
- fail Puppet::ParseError, msg
292
+ error = Puppet::ParseError.new(msg)
293
+ error.file = param.file if param.file
294
+ error.line = param.line if param.line
295
+ raise error
287
296
  end
288
297
  else
289
298
  if self.source == param.source or param.source.child_of?(self.source)
@@ -393,4 +402,4 @@ class Puppet::Parser::Resource
393
402
  end
394
403
  end
395
404
 
396
- # $Id: resource.rb 2597 2007-06-17 21:41:50Z luke $
405
+ # $Id: resource.rb 2693 2007-07-14 17:46:37Z luke $
@@ -1,6 +1,6 @@
1
1
  # The parameters we stick in Resources.
2
2
  class Puppet::Parser::Resource::Param
3
- attr_accessor :name, :value, :source, :line, :file
3
+ attr_accessor :name, :value, :source, :line, :file, :add
4
4
  include Puppet::Util
5
5
  include Puppet::Util::Errors
6
6
  include Puppet::Util::MethodHelper
@@ -18,17 +18,30 @@ class Puppet::Parser::Resource::Param
18
18
  def line_to_i
19
19
  return line ? Integer(line) : nil
20
20
  end
21
+
22
+ # Make sure an array (or possibly not an array) of values is correctly
23
+ # set up for Rails. The main thing is that Resource::Reference objects
24
+ # should stay objects, so they just get serialized.
25
+ def munge_for_rails(values)
26
+ values = value.is_a?(Array) ? value : [value]
27
+ values.map do |v|
28
+ if v.is_a?(Puppet::Parser::Resource::Reference)
29
+ v
30
+ else
31
+ v.to_s
32
+ end
33
+ end
34
+ end
21
35
 
22
36
  # Store a new parameter in a Rails db.
23
37
  def to_rails(db_resource)
24
- values = value.is_a?(Array) ? value : [value]
25
- values = values.map { |v| v.to_s }
38
+ values = munge_for_rails(value)
26
39
 
27
40
  param_name = Puppet::Rails::ParamName.find_or_create_by_name(self.name.to_s)
28
41
  line_number = line_to_i()
29
42
 
30
43
  return values.collect do |v|
31
- db_resource.param_values.create(:value => v.to_s,
44
+ db_resource.param_values.create(:value => v,
32
45
  :line => line_number,
33
46
  :param_name => param_name)
34
47
  end
@@ -44,7 +57,7 @@ class Puppet::Parser::Resource::Param
44
57
  values_to_add(db_values).each { |add_me|
45
58
  db_resource = db_values[0].resource
46
59
  db_param_name = db_values[0].param_name
47
- db_resource.param_values.create(:value => add_me.to_s,
60
+ db_resource.param_values.create(:value => add_me,
48
61
  :line => line_number,
49
62
  :param_name => db_param_name)
50
63
  }
@@ -55,8 +68,7 @@ class Puppet::Parser::Resource::Param
55
68
  end
56
69
 
57
70
  def values_to_remove(db_values)
58
- values = value.is_a?(Array) ? value : [value]
59
- values = values.map { |v| v.to_s }
71
+ values = munge_for_rails(value)
60
72
  line_number = line_to_i()
61
73
  db_values.collect do |db|
62
74
  db unless (db.line == line_number &&
@@ -67,8 +79,7 @@ class Puppet::Parser::Resource::Param
67
79
  end
68
80
 
69
81
  def values_to_add(db_values)
70
- values = value.is_a?(Array) ? value : [value]
71
- values = values.map { |v| v.to_s }
82
+ values = munge_for_rails(value)
72
83
  line_number = line_to_i()
73
84
  values.collect do |v|
74
85
  v unless db_values.find { |db| (v == db.value &&
@@ -77,4 +88,4 @@ class Puppet::Parser::Resource::Param
77
88
  end
78
89
  end
79
90
 
80
- # $Id: param.rb 2597 2007-06-17 21:41:50Z luke $
91
+ # $Id: param.rb 2706 2007-07-18 19:47:09Z luke $
@@ -32,7 +32,7 @@ class Puppet::Parser::Resource::Reference
32
32
  if tmp = @scope.finddefine(self.type)
33
33
  @definedtype = tmp
34
34
  else
35
- fail Puppet::ParseError, "Could not find definition %s" % self.type
35
+ fail Puppet::ParseError, "Could not find resource type '%s'" % self.type
36
36
  end
37
37
  end
38
38
 
@@ -68,4 +68,4 @@ class Puppet::Parser::Resource::Reference
68
68
  end
69
69
  end
70
70
 
71
- # $Id: reference.rb 1967 2006-12-23 06:26:39Z luke $
71
+ # $Id: reference.rb 2664 2007-07-09 20:54:35Z luke $
@@ -115,11 +115,19 @@ class Puppet::Parser::Scope
115
115
  # that subclasses can set their parent scopes to be the scope of
116
116
  # their parent class.
117
117
  def class_scope(klass)
118
- if klass.respond_to?(:classname)
118
+ scope = if klass.respond_to?(:classname)
119
119
  @classtable[klass.classname]
120
120
  else
121
121
  @classtable[klass]
122
122
  end
123
+
124
+ return nil unless scope
125
+
126
+ if scope.nodescope? and ! klass.is_a?(AST::Node)
127
+ raise Puppet::ParseError, "Node %s has already been evaluated; cannot evaluate class with same name" % [klass.classname]
128
+ end
129
+
130
+ scope
123
131
  end
124
132
 
125
133
  # Return the list of collections.
@@ -442,6 +450,14 @@ class Puppet::Parser::Scope
442
450
  return Puppet::Parser::Scope.new(hash)
443
451
  end
444
452
 
453
+ # Is this class for a node? This is used to make sure that
454
+ # nodes and classes with the same name conflict (#620), which
455
+ # is required because of how often the names are used throughout
456
+ # the system, including on the client.
457
+ def nodescope?
458
+ defined?(@nodescope) and @nodescope
459
+ end
460
+
445
461
  # Return the list of remaining overrides.
446
462
  def overrides
447
463
  #@overridetable.collect { |name, overs| overs }.flatten
@@ -452,14 +468,6 @@ class Puppet::Parser::Scope
452
468
  @definedtable.values
453
469
  end
454
470
 
455
- def setclass?(obj)
456
- if obj.respond_to?(:classname)
457
- @classtable.has_key?(obj.classname)
458
- else
459
- @classtable[obj]
460
- end
461
- end
462
-
463
471
  # Store the fact that we've evaluated a given class. We use a hash
464
472
  # that gets inherited from the top scope down, rather than a global
465
473
  # hash. We store the object ID, not class name, so that we
@@ -474,6 +482,10 @@ class Puppet::Parser::Scope
474
482
  else
475
483
  raise Puppet::DevError, "Invalid class %s" % obj.inspect
476
484
  end
485
+ if obj.is_a?(AST::Node)
486
+ @nodescope = true
487
+ end
488
+ nil
477
489
  end
478
490
 
479
491
  # Set all of our facts in the top-level scope.
@@ -728,4 +740,4 @@ class Puppet::Parser::Scope
728
740
  end
729
741
  end
730
742
 
731
- # $Id: scope.rb 2562 2007-06-11 21:54:37Z luke $
743
+ # $Id: scope.rb 2646 2007-07-04 21:06:26Z luke $
@@ -2,7 +2,6 @@
2
2
  # blocks for actually doing work on the system.
3
3
 
4
4
  require 'puppet'
5
- require 'puppet/element'
6
5
  require 'puppet/propertychange'
7
6
  require 'puppet/parameter'
8
7
 
@@ -14,10 +13,30 @@ class Property < Puppet::Parameter
14
13
  # they can be retrieved and compared later when merging.
15
14
  attr_reader :shouldorig
16
15
 
16
+ attr_writer :noop
17
+
17
18
  class << self
18
19
  attr_accessor :unmanaged
19
20
  attr_reader :name
20
21
 
22
+ # Return array matching info, defaulting to just matching
23
+ # the first value.
24
+ def array_matching
25
+ unless defined?(@array_matching)
26
+ @array_matching = :first
27
+ end
28
+ @array_matching
29
+ end
30
+
31
+ # Set whether properties should match all values or just the first one.
32
+ def array_matching=(value)
33
+ value = value.intern if value.is_a?(String)
34
+ unless [:first, :all].include?(value)
35
+ raise ArgumentError, "Supported values for Property#array_matching are 'first' and 'all'"
36
+ end
37
+ @array_matching = value
38
+ end
39
+
21
40
  def checkable
22
41
  @checkable = true
23
42
  end
@@ -254,11 +273,15 @@ class Property < Puppet::Parameter
254
273
  end
255
274
 
256
275
  # Look for a matching value
257
- @should.each { |val|
258
- if is == val or is == val.to_s
259
- return true
260
- end
261
- }
276
+ if match_all?
277
+ return (is == @should or is == @should.collect { |v| v.to_s })
278
+ else
279
+ @should.each { |val|
280
+ if is == val or is == val.to_s
281
+ return true
282
+ end
283
+ }
284
+ end
262
285
 
263
286
  # otherwise, return false
264
287
  return false
@@ -285,6 +308,11 @@ class Property < Puppet::Parameter
285
308
  )
286
309
  end
287
310
 
311
+ # Should we match all values, or just the first?
312
+ def match_all?
313
+ self.class.array_matching == :all
314
+ end
315
+
288
316
  # each property class must define the name() method, and property instances
289
317
  # do not change that name
290
318
  # this implicitly means that a given object can only have one property
@@ -295,15 +323,16 @@ class Property < Puppet::Parameter
295
323
 
296
324
  # for testing whether we should actually do anything
297
325
  def noop
298
- unless defined? @noop
299
- @noop = false
300
- end
301
- if self.resource.respond_to?(:noop)
302
- tmp = @noop || self.resource.noop || Puppet[:noop] || false
326
+ # This is only here to make testing easier.
327
+ if @resource.respond_to?(:noop?)
328
+ @resource.noop?
303
329
  else
304
- tmp = @noop || Puppet[:noop] || false
330
+ if defined?(@noop)
331
+ @noop
332
+ else
333
+ Puppet[:noop]
334
+ end
305
335
  end
306
- return tmp
307
336
  end
308
337
 
309
338
  # By default, call the method associated with the property name on our
@@ -351,7 +380,11 @@ class Property < Puppet::Parameter
351
380
  self.devfail "should for %s on %s is not an array" %
352
381
  [self.class.name, @resource.name]
353
382
  end
354
- return @should[0]
383
+ if match_all?
384
+ return @should
385
+ else
386
+ return @should[0]
387
+ end
355
388
  else
356
389
  return nil
357
390
  end
@@ -524,4 +557,4 @@ class Property < Puppet::Parameter
524
557
  end
525
558
  end
526
559
 
527
- # $Id: property.rb 2500 2007-05-09 22:05:32Z luke $
560
+ # $Id: property.rb 2678 2007-07-11 19:30:42Z luke $
@@ -40,7 +40,7 @@ module Puppet
40
40
  # default to a simple event type
41
41
  unless name.is_a?(Symbol)
42
42
  @property.warning("Property '%s' returned invalid event '%s'; resetting to default" %
43
- [@property.class,event])
43
+ [@property.class, name])
44
44
 
45
45
  event = @property.resource.class.name.id2name + "_changed"
46
46
  end
@@ -53,7 +53,7 @@ module Puppet
53
53
  end
54
54
 
55
55
  def initialize(property, currentvalue)
56
- unless property.is_a?(Puppet::Type::Property)
56
+ unless property.is_a?(Puppet::Property)
57
57
  raise Puppet::DevError, "Got a %s instead of a property" %
58
58
  property.class
59
59
  end
@@ -140,4 +140,4 @@ module Puppet
140
140
  end
141
141
  end
142
142
 
143
- # $Id: propertychange.rb 2500 2007-05-09 22:05:32Z luke $
143
+ # $Id: propertychange.rb 2678 2007-07-11 19:30:42Z luke $
@@ -14,9 +14,9 @@ Puppet::Type.type(:cron).provide(:crontab,
14
14
  ) do
15
15
  commands :crontab => "crontab"
16
16
 
17
- text_line :comment, :match => %r{^#}, :post_parse => proc { |hash|
18
- if hash[:line] =~ /Puppet Name: (.+)\s*$/
19
- hash[:name] = $1
17
+ text_line :comment, :match => %r{^#}, :post_parse => proc { |record|
18
+ if record[:line] =~ /Puppet Name: (.+)\s*$/
19
+ record[:name] = $1
20
20
  end
21
21
  }
22
22
 
@@ -25,11 +25,12 @@ Puppet::Type.type(:cron).provide(:crontab,
25
25
  text_line :environment, :match => %r{^\w+=}
26
26
 
27
27
  record_line :freebsd_special, :fields => %w{special command},
28
- :match => %r{^@(\w+)\s+(.+)$}, :pre_gen => proc { |hash|
29
- hash[:special] = "@" + hash[:special]
28
+ :match => %r{^@(\w+)\s+(.+)$}, :pre_gen => proc { |record|
29
+ record[:special] = "@" + record[:special]
30
30
  }
31
31
 
32
32
  crontab = record_line :crontab, :fields => %w{minute hour monthday month weekday command},
33
+ :match => %r{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$},
33
34
  :optional => %w{minute hour weekday month monthday}, :absent => "*"
34
35
 
35
36
  class << crontab
@@ -38,37 +39,37 @@ Puppet::Type.type(:cron).provide(:crontab,
38
39
  end
39
40
  # Do some post-processing of the parsed record. Basically just
40
41
  # split the numeric fields on ','.
41
- def post_parse(details)
42
+ def post_parse(record)
42
43
  numeric_fields.each do |field|
43
- if val = details[field] and val != :absent
44
- details[field] = details[field].split(",")
44
+ if val = record[field] and val != :absent
45
+ record[field] = record[field].split(",")
45
46
  end
46
47
  end
47
48
  end
48
49
 
49
50
  # Join the fields back up based on ','.
50
- def pre_gen(details)
51
+ def pre_gen(record)
51
52
  numeric_fields.each do |field|
52
- if vals = details[field] and vals.is_a?(Array)
53
- details[field] = vals.join(",")
53
+ if vals = record[field] and vals.is_a?(Array)
54
+ record[field] = vals.join(",")
54
55
  end
55
56
  end
56
57
  end
57
58
 
58
59
 
59
60
  # Add name and environments as necessary.
60
- def to_line(details)
61
+ def to_line(record)
61
62
  str = ""
62
- if details[:name]
63
- str = "# Puppet Name: %s\n" % details[:name]
63
+ if record[:name]
64
+ str = "# Puppet Name: %s\n" % record[:name]
64
65
  end
65
- if details[:environment] and details[:environment] != :absent and details[:environment] != [:absent]
66
- details[:environment].each do |env|
66
+ if record[:environment] and record[:environment] != :absent and record[:environment] != [:absent]
67
+ record[:environment].each do |env|
67
68
  str += env + "\n"
68
69
  end
69
70
  end
70
71
 
71
- str += join(details)
72
+ str += join(record)
72
73
  str
73
74
  end
74
75
  end
@@ -83,47 +84,48 @@ Puppet::Type.type(:cron).provide(:crontab,
83
84
  # HEADER not be deleted, as doing so could cause duplicate cron jobs.\n}
84
85
  end
85
86
 
86
- # See if we can match the hash against an existing cron job.
87
- def self.match(hash, resources)
88
- resources.each do |name, obj|
89
- # we now have a cron job whose command exactly matches
90
- # let's see if the other fields match
87
+ # See if we can match the record against an existing cron job.
88
+ def self.match(record, resources)
89
+ resources.each do |name, resource|
90
+ # Match the command first, since it's the most important one.
91
+ next unless record[:target] == resource.value(:target)
92
+ next unless record[:command] == resource.value(:command)
91
93
 
92
- # First check the @special stuff
93
- if hash[:special]
94
- next unless obj.value(:special) == hash[:special]
94
+ # Then check the @special stuff
95
+ if record[:special]
96
+ next unless resource.value(:special) == record[:special]
95
97
  end
96
98
 
97
99
  # Then the normal fields.
98
100
  matched = true
99
- record_type(hash[:record_type]).fields().each do |field|
101
+ record_type(record[:record_type]).fields().each do |field|
100
102
  next if field == :command
101
- if hash[field] and ! obj.value(field)
103
+ next if field == :special
104
+ if record[field] and ! resource.value(field)
102
105
  Puppet.info "Cron is missing %s: %s and %s" %
103
- [field, hash[field].inspect, obj.value(field).inspect]
106
+ [field, record[field].inspect, resource.value(field).inspect]
104
107
  matched = false
105
108
  break
106
109
  end
107
110
 
108
- if ! hash[field] and obj.value(field)
111
+ if ! record[field] and resource.value(field)
109
112
  Puppet.info "Hash is missing %s: %s and %s" %
110
- [field, obj.value(field).inspect, hash[field].inspect]
113
+ [field, resource.value(field).inspect, record[field].inspect]
111
114
  matched = false
112
115
  break
113
116
  end
114
117
 
115
118
  # Yay differing definitions of absent.
116
- next if (hash[field] == :absent and obj.value(field) == "*")
119
+ next if (record[field] == :absent and resource.value(field) == "*")
117
120
 
118
121
  # Everything should be in the form of arrays, not the normal text.
119
- next if (hash[field] == obj.value(field))
122
+ next if (record[field] == resource.value(field))
120
123
  Puppet.info "Did not match %s: %s vs %s" %
121
- [field, obj.value(field).inspect, hash[field].inspect]
124
+ [field, resource.value(field).inspect, record[field].inspect]
122
125
  matched = false
123
126
  break
124
127
  end
125
- next unless matched
126
- return obj
128
+ return resource if matched
127
129
  end
128
130
 
129
131
  return false
@@ -183,4 +185,4 @@ Puppet::Type.type(:cron).provide(:crontab,
183
185
  end
184
186
  end
185
187
 
186
- # $Id: crontab.rb 2624 2007-06-19 01:49:19Z luke $
188
+ # $Id: crontab.rb 2697 2007-07-14 21:13:04Z luke $