puppet 0.24.2 → 0.24.3

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.

data/CHANGELOG CHANGED
@@ -1,3 +1,44 @@
1
+ 0.24.3
2
+ Modified the ldap node terminus to also use the facts version
3
+ as the version for a node, which should similarly encourage the
4
+ use of the yaml cache. (Related to #1130)
5
+
6
+ Caching node information in yaml (I figured caching in memory will
7
+ cause ever-larger memory growth), and changing the external node
8
+ terminus to use the version of the facts as their version. This
9
+ will usually result in the cached node information being used,
10
+ instead of always hitting the external node app during file
11
+ serving. Note that if the facts aren't changed by the client,
12
+ then this will result in the cached node being used, but at this
13
+ point, the client always updates its facts. (#1130)
14
+
15
+ Fixing #1132 -- host names can now have dashes anywhere.
16
+ (Patch by freiheit.)
17
+
18
+ Fixing #1118 -- downloading plugins and facts now ignores noop.
19
+ Note that this changes the behaviour a bit -- the resource's
20
+ noop setting always beats the global setting (previously,
21
+ whichever was true would win).
22
+
23
+ The change in checksums from 'timestamp' to 'mtime' no longer
24
+ result in updates on every run (#1116).
25
+
26
+ Aliases again work in relationships (#1094).
27
+
28
+ The CA serial file will no longer ever be owned by
29
+ root (#1041).
30
+
31
+ Fixing the rest of #1113: External node commands can specify
32
+ an environment and Puppet will now use it.
33
+
34
+ Partially fixing #1113: LDAP nodes now support environments,
35
+ and the schema has been updated accordingly.
36
+
37
+ Always duplicating resource defaults in the parser, so that
38
+ stacked metaparameter values do not result in all resources
39
+ that receive a given default also getting those stacked
40
+ values.
41
+
1
42
  0.24.2
2
43
  Fixing #1062 by moving the yamldir setting to its own yaml
3
44
  section. This should keep the yamldir from being created
@@ -1,29 +1,29 @@
1
- [main]
2
- # Where Puppet stores dynamic and growing data.
3
- # The default value is '/var/puppet'.
4
- vardir = /var/lib/puppet
5
-
6
- # The Puppet log directory.
7
- # The default value is '$vardir/log'.
8
- logdir = /var/log/puppet
9
-
10
- # Where Puppet PID files are kept.
11
- # The default value is '$vardir/run'.
12
- rundir = /var/run/puppet
13
-
14
- # Where SSL certificates are kept.
15
- # The default value is '$confdir/ssl'.
16
- ssldir = $vardir/ssl
17
-
18
- [puppetd]
19
- # The file in which puppetd stores a list of the classes
20
- # associated with the retrieved configuratiion. Can be loaded in
21
- # the separate ``puppet`` executable using the ``--loadclasses``
22
- # option.
23
- # The default value is '$confdir/classes.txt'.
24
- classfile = $vardir/classes.txt
25
-
26
- # Where puppetd caches the local configuration. An
27
- # extension indicating the cache format is added automatically.
28
- # The default value is '$confdir/localconfig'.
29
- localconfig = $vardir/localconfig
1
+ [main]
2
+ # Where Puppet stores dynamic and growing data.
3
+ # The default value is '/var/puppet'.
4
+ vardir = /var/lib/puppet
5
+
6
+ # The Puppet log directory.
7
+ # The default value is '$vardir/log'.
8
+ logdir = /var/log/puppet
9
+
10
+ # Where Puppet PID files are kept.
11
+ # The default value is '$vardir/run'.
12
+ rundir = /var/run/puppet
13
+
14
+ # Where SSL certificates are kept.
15
+ # The default value is '$confdir/ssl'.
16
+ ssldir = $vardir/ssl
17
+
18
+ [puppetd]
19
+ # The file in which puppetd stores a list of the classes
20
+ # associated with the retrieved configuratiion. Can be loaded in
21
+ # the separate ``puppet`` executable using the ``--loadclasses``
22
+ # option.
23
+ # The default value is '$confdir/classes.txt'.
24
+ classfile = $vardir/classes.txt
25
+
26
+ # Where puppetd caches the local configuration. An
27
+ # extension indicating the cache format is added automatically.
28
+ # The default value is '$confdir/localconfig'.
29
+ localconfig = $vardir/localconfig
@@ -7,7 +7,7 @@
7
7
 
8
8
  Summary: A network tool for managing many disparate systems
9
9
  Name: puppet
10
- Version: 0.24.2
10
+ Version: 0.24.3
11
11
  Release: 1%{?dist}
12
12
  License: GPLv2+
13
13
  Group: System Environment/Base
@@ -12,6 +12,11 @@ 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
+ attributetype ( 1.1.3.9 NAME 'environment'
16
+ DESC 'Puppet Node Environment'
17
+ EQUALITY caseIgnoreIA5Match
18
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
19
+
15
20
  objectclass ( 1.1.1.2 NAME 'puppetClient' SUP top AUXILIARY
16
21
  DESC 'Puppet Client objectclass'
17
- MAY ( puppetclass $ parentnode ))
22
+ MAY ( puppetclass $ parentnode $ environment ))
@@ -143,10 +143,6 @@ class Suite
143
143
  instance_eval(&block)
144
144
  end
145
145
 
146
- def prepare
147
- raise "Test %s did not override 'prepare'" % @name
148
- end
149
-
150
146
  # Define a new type of test on this suite.
151
147
  def newtest(name, doc, &block)
152
148
  @tests[name] = doc
@@ -166,7 +162,8 @@ class Suite
166
162
  raise "Suite %s only supports tests %s; not %s" % [@name, @tests.keys.collect { |k| k.to_s }.join(","), test]
167
163
  end
168
164
  puts "Running %s %s test" % [@name, test]
169
- prepare()
165
+
166
+ prepare() if respond_to?(:prepare)
170
167
 
171
168
  if $options[:pause]
172
169
  puts "Hit any key to continue"
@@ -210,9 +207,6 @@ class Suite
210
207
  end
211
208
 
212
209
  Suite.new :parser, "Manifest parsing" do
213
- def prepare
214
- end
215
-
216
210
  newtest :parse, "Parsed files" do
217
211
  @parser = Puppet::Parser::Parser.new(:environment => Puppet[:environment])
218
212
  @parser.file = Puppet[:manifest]
@@ -220,7 +214,16 @@ Suite.new :parser, "Manifest parsing" do
220
214
  end
221
215
  end
222
216
 
223
- Suite.new :catalog, "Catalog handling" do
217
+ Suite.new :local_catalog, "Local catalog handling" do
218
+ def prepare
219
+ end
220
+
221
+ newtest :compile, "Compiled catalog" do
222
+ Puppet::Node::Catalog.find(Puppet[:certname])
223
+ end
224
+ end
225
+
226
+ Suite.new :remote_catalog, "Remote catalog handling" do
224
227
  def prepare
225
228
  $args[:cache] = false
226
229
  # Create a config client and pull the config down
@@ -232,10 +235,12 @@ Suite.new :catalog, "Catalog handling" do
232
235
  # Use the facts from the cache, to skip the time it takes
233
236
  # to load them.
234
237
  @client.dostorage
235
- @facts = Puppet::Util::Storage.cache(:configuration)[:facts]
238
+ @facts = Puppet::Util::Storage.cache(:configuration)[:facts] || {}
236
239
 
237
240
  if @facts.empty?
238
- @facts = @client.master.getfacts
241
+ if tmp = Puppet::Node::Facts.find("me")
242
+ @facts = tmp.values
243
+ end
239
244
  end
240
245
 
241
246
  if host = $options[:fqdn]
@@ -247,7 +252,7 @@ Suite.new :catalog, "Catalog handling" do
247
252
  @facts = YAML.dump(@facts)
248
253
  end
249
254
 
250
- newtest :compile, "Compiled catalog" do
255
+ newtest :getconfig, "Compiled catalog" do
251
256
  @client.driver.getconfig(@facts, "yaml")
252
257
  end
253
258
 
@@ -277,6 +282,21 @@ Suite.new :file, "File interactions" do
277
282
  end
278
283
  end
279
284
 
285
+ Suite.new :filebucket, "Filebucket interactions" do
286
+ def prepare
287
+ require 'tempfile'
288
+ @client = Puppet::Network::Client.dipper.new($args)
289
+ end
290
+
291
+ newtest :backup, "Backed up file" do
292
+ Tempfile.open("bucket_testing") do |f|
293
+ f.print rand(1024)
294
+ f.close
295
+ @client.backup(f.path)
296
+ end
297
+ end
298
+ end
299
+
280
300
  # Note that this uses an env variable to determine how many resources per
281
301
  # host to create (with a default of 10). 'repeat' determines how
282
302
  # many hosts to create. You probably will get mad failures if you
@@ -445,8 +465,8 @@ Puppet.parse_config
445
465
  $args[:Server] = Puppet[:server]
446
466
 
447
467
  unless $options[:test]
448
- $options[:suite] = :configuration
449
- $options[:test] = :compile
468
+ $options[:suite] = :remote_catalog
469
+ $options[:test] = :getconfig
450
470
  end
451
471
 
452
472
  unless $options[:test]
@@ -25,7 +25,7 @@ require 'puppet/util/suidmanager'
25
25
  # it's also a place to find top-level commands like 'debug'
26
26
 
27
27
  module Puppet
28
- PUPPETVERSION = '0.24.2'
28
+ PUPPETVERSION = '0.24.3'
29
29
 
30
30
  def Puppet.version
31
31
  return PUPPETVERSION
@@ -258,6 +258,7 @@ module Puppet
258
258
  :serial => { :default => "$cadir/serial",
259
259
  :owner => "$user",
260
260
  :group => "$group",
261
+ :mode => 0600,
261
262
  :desc => "Where the serial number for certificates is stored."
262
263
  },
263
264
  :autosign => { :default => "$confdir/autosign.conf",
@@ -326,8 +327,8 @@ module Puppet
326
327
  :masterport => [8140, "Which port puppetmasterd listens on."],
327
328
  :parseonly => [false, "Just check the syntax of the manifests."],
328
329
  :node_name => ["cert", "How the puppetmaster determines the client's identity
329
- and sets the 'hostname' fact for use in the manifest, in particular
330
- for determining which 'node' statement applies to the client.
330
+ and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest,
331
+ in particular for determining which 'node' statement applies to the client.
331
332
  Possible values are 'cert' (use the subject's CN in the client's
332
333
  certificate) and 'facter' (use the hostname that the client
333
334
  reported in its facts)"],
@@ -162,7 +162,7 @@ class Puppet::Indirector::Indirection
162
162
 
163
163
  # See if our instance is in the cache and up to date.
164
164
  if cache? and cache.has_most_recent?(key, terminus(terminus_name).version(key))
165
- Puppet.info "Using cached %s %s" % [self.name, key]
165
+ Puppet.debug "Using cached %s %s" % [self.name, key]
166
166
  return cache.find(key, *args)
167
167
  end
168
168
 
@@ -24,13 +24,20 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
24
24
  return create_node(name, result)
25
25
  end
26
26
 
27
+ # Use the version of the facts, since we assume that's the main thing
28
+ # that changes. If someone wants their own way of defining version,
29
+ # they can easily provide their own, um, version of this class.
30
+ def version(name)
31
+ Puppet::Node::Facts.version(name)
32
+ end
33
+
27
34
  private
28
35
 
29
36
  # Turn our outputted objects into a Puppet::Node instance.
30
37
  def create_node(name, result)
31
38
  node = Puppet::Node.new(name)
32
39
  set = false
33
- [:parameters, :classes].each do |param|
40
+ [:parameters, :classes, :environment].each do |param|
34
41
  if value = result[param]
35
42
  node.send(param.to_s + "=", value)
36
43
  set = true
@@ -36,11 +36,14 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
36
36
  information[:parameters][param] = value unless information[:parameters].include?(param)
37
37
  end
38
38
 
39
+ information[:environment] ||= parent_info[:environment]
40
+
39
41
  parent = parent_info[:parent]
40
42
  end
41
43
 
42
44
  node.classes = information[:classes].uniq unless information[:classes].empty?
43
45
  node.parameters = information[:parameters] unless information[:parameters].empty?
46
+ node.environment = information[:environment] if information[:environment]
44
47
  node.fact_merge
45
48
 
46
49
  return node
@@ -87,6 +90,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
87
90
  hash
88
91
  end
89
92
 
93
+ result[:environment] = result[:parameters]["environment"] if result[:parameters]["environment"]
94
+
90
95
  return result
91
96
  end
92
97
 
@@ -117,4 +122,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
117
122
  end
118
123
  filter
119
124
  end
125
+
126
+ def version(name)
127
+ Puppet::Node::Facts.version(name)
128
+ end
120
129
  end
@@ -40,6 +40,11 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
40
40
  end
41
41
  end
42
42
 
43
+ def version(name)
44
+ return nil unless FileTest.exist?(path(name))
45
+ return File.stat(path(name)).mtime
46
+ end
47
+
43
48
  private
44
49
 
45
50
  def from_yaml(text)
@@ -108,7 +108,11 @@ class Puppet::Type
108
108
 
109
109
  # Are we running in noop mode?
110
110
  def noop?
111
- @noop || Puppet[:noop]
111
+ if defined?(@noop)
112
+ @noop
113
+ else
114
+ Puppet[:noop]
115
+ end
112
116
  end
113
117
 
114
118
  def noop
@@ -320,7 +320,8 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
320
320
  :group => Process.gid,
321
321
  :purge => true,
322
322
  :force => true,
323
- :backup => false
323
+ :backup => false,
324
+ :noop => false
324
325
  }
325
326
 
326
327
  if args[:ignore]
@@ -331,9 +332,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
331
332
 
332
333
  Puppet.info "Retrieving #{args[:name]}s"
333
334
 
334
- noop = Puppet[:noop]
335
- Puppet[:noop] = false
336
-
337
335
  files = []
338
336
  begin
339
337
  Timeout::timeout(self.timeout) do
@@ -355,14 +353,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
355
353
  downconfig.clear
356
354
 
357
355
  return files
358
- ensure
359
- # I can't imagine why this is necessary, but apparently at last one person has had problems with noop
360
- # being nil here.
361
- if noop.nil?
362
- Puppet[:noop] = false
363
- else
364
- Puppet[:noop] = noop
365
- end
366
356
  end
367
357
 
368
358
  # Retrieve facts from the central server.
@@ -81,6 +81,8 @@ class Puppet::Network::Handler
81
81
  clientip = facts["ipaddress"]
82
82
  if Puppet[:node_name] == 'cert'
83
83
  if name
84
+ facts["fqdn"] = client
85
+ facts["hostname"], facts["domain"] = client.split('.', 2)
84
86
  client = name
85
87
  end
86
88
  if ip
@@ -10,7 +10,7 @@ class Puppet::Node
10
10
  extend Puppet::Indirector
11
11
 
12
12
  # Use the node source as the indirection terminus.
13
- indirects :node, :terminus_setting => :node_terminus, :doc => "Where to find node information.
13
+ indirects :node, :terminus_setting => :node_terminus, :cache_class => :yaml, :doc => "Where to find node information.
14
14
  A node is composed of its name, its facts, and its environment."
15
15
 
16
16
  # Retrieve a node from the node source, with some additional munging
@@ -84,6 +84,7 @@ class Puppet::Node::Catalog < Puppet::PGraph
84
84
 
85
85
  # Create an alias for a resource.
86
86
  def alias(resource, name)
87
+ #set $1
87
88
  resource.ref =~ /^(.+)\[/
88
89
 
89
90
  newref = "%s[%s]" % [$1 || resource.class.name, name]
@@ -475,6 +476,15 @@ class Puppet::Node::Catalog < Puppet::PGraph
475
476
  vertices.each do |resource|
476
477
  next if resource.respond_to?(:virtual?) and resource.virtual?
477
478
 
479
+ #This is hackity hack for 1094
480
+ #Aliases aren't working in the ral catalog because the current instance of the resource
481
+ #has a reference to the catalog being converted. . . So, give it a reference to the new one
482
+ #problem solved. . .
483
+ if resource.is_a?(Puppet::TransObject)
484
+ resource = resource.dup
485
+ resource.catalog = result
486
+ end
487
+
478
488
  newres = resource.send(convert)
479
489
 
480
490
  # We can't guarantee that resources don't munge their names
@@ -366,7 +366,6 @@ class Puppet::Parser::Compiler
366
366
  # Make sure all of our resources and such have done any last work
367
367
  # necessary.
368
368
  def finish
369
- #@catalog.resources.each do |name|
370
369
  @catalog.vertices.each do |resource|
371
370
  # Add in any resource overrides.
372
371
  if overrides = resource_overrides(resource)
@@ -233,6 +233,20 @@ class Puppet::Parser::Resource
233
233
  @ref.to_s
234
234
  end
235
235
 
236
+ # Define a parameter in our resource.
237
+ def set_parameter(param, value = nil)
238
+ if value
239
+ param = Puppet::Parser::Resource::Param.new(
240
+ :name => param, :value => value, :source => self.source
241
+ )
242
+ elsif ! param.is_a?(Puppet::Parser::Resource::Param)
243
+ raise ArgumentError, "Must pass a parameter or all necessary values"
244
+ end
245
+
246
+ # And store it in our parameter hash.
247
+ @params[param.name] = param
248
+ end
249
+
236
250
  def to_hash
237
251
  @params.inject({}) do |hash, ary|
238
252
  param = ary[1]
@@ -331,7 +345,7 @@ class Puppet::Parser::Resource
331
345
  unless @params.include?(name)
332
346
  self.debug "Adding default for %s" % name
333
347
 
334
- @params[name] = param
348
+ @params[name] = param.dup
335
349
  end
336
350
  end
337
351
  end
@@ -370,11 +384,8 @@ class Puppet::Parser::Resource
370
384
 
371
385
  # The parameter is already set. Fail if they're not allowed to override it.
372
386
  unless param.source.child_of?(current.source)
373
- if Puppet[:trace]
374
- puts caller
375
- end
376
- msg = "Parameter '%s' is already set on %s" %
377
- [param.name, self.to_s]
387
+ puts caller if Puppet[:trace]
388
+ msg = "Parameter '%s' is already set on %s" % [param.name, self.to_s]
378
389
  if current.source.to_s != ""
379
390
  msg += " by %s" % current.source
380
391
  end
@@ -426,20 +437,6 @@ class Puppet::Parser::Resource
426
437
  end
427
438
  end
428
439
 
429
- # Define a parameter in our resource.
430
- def set_parameter(param, value = nil)
431
- if value
432
- param = Puppet::Parser::Resource::Param.new(
433
- :name => param, :value => value, :source => self.source
434
- )
435
- elsif ! param.is_a?(Puppet::Parser::Resource::Param)
436
- raise ArgumentError, "Must pass a parameter or all necessary values"
437
- end
438
-
439
- # And store it in our parameter hash.
440
- @params[param.name] = param
441
- end
442
-
443
440
  # Make sure the resource's parameters are all valid for the type.
444
441
  def validate
445
442
  @params.each do |name, param|
@@ -10,8 +10,8 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
10
10
  defaultfor :operatingsystem => :gentoo
11
11
 
12
12
  def self.instances
13
- result_format = /(\S+) (\S+) \[([^\[]*)(\[[^\]]*\])?\] \[[^0-9]*([^\s:\[]*)(\[[^\]]*\])?(:\S*)?\] ([\S]*) (.*)/
14
- result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :overlay, :slot, :vendor, :description]
13
+ result_format = /(\S+) (\S+) \[(?:([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\([^\)]+\))?(?:\[([^\]]+)\])?[ ]*)*\] \[(?:(?:\{M\})?(?:\([~*]+\))?([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\(([^\)]+)\))?(?:![mf])*(?:\[([^\]]+)\])?)?\] ([\S]*) (.*)/
14
+ result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :slot, :overlay, :vendor, :description]
15
15
 
16
16
  search_format = "{installedversionsshort}<category> <name> [<installedversionsshort>] [<best>] <homepage> <description>{}"
17
17
 
@@ -67,8 +67,8 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
67
67
  end
68
68
 
69
69
  def query
70
- result_format = /(\S+) (\S+) \[([^\[]*)(\[[^\]]*\])?\] \[[^0-9]*([^\s:\[]*)(\[[^\]]*\])?(:\S*)?\] ([\S]*) (.*)/
71
- result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :overlay, :slot, :vendor, :description]
70
+ result_format = /(\S+) (\S+) \[(?:([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\([^\)]+\))?(?:\[([^\]]+)\])?[ ]*)*\] \[(?:(?:\{M\})?(?:\([~*]+\))?([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\(([^\)]+)\))?(?:![mf])*(?:\[([^\]]+)\])?)?\] ([\S]*) (.*)/
71
+ result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :slot, :overlay, :vendor, :description]
72
72
 
73
73
  search_field = @resource[:category] ? "--category-name" : "--name"
74
74
  search_value = package_name
@@ -14,7 +14,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
14
14
  # Remove the symlinks
15
15
  def disable
16
16
  update "-f", @resource[:name], "remove"
17
- update @resource[:name], "stop 1 2 3 4 5 6 ."
17
+ update @resource[:name], "stop", "00", "1", "2", "3", "4", "5", "6", "."
18
18
  end
19
19
 
20
20
  def enabled?
@@ -34,4 +34,3 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
34
34
  update @resource[:name], "defaults"
35
35
  end
36
36
  end
37
-
@@ -35,8 +35,6 @@ Puppet::Reports.register_report(:tagmail) do
35
35
  "
36
36
 
37
37
 
38
- Puppet.settings.use(:tagmail)
39
-
40
38
  # Find all matching messages.
41
39
  def match(taglists)
42
40
  reports = []
@@ -238,33 +238,6 @@ class Puppet::SSLCertificates::CA
238
238
  }
239
239
  end
240
240
 
241
- # Create an exclusive lock for reading and writing, and do the
242
- # writing in a tmp file.
243
- def readwritelock(file, mode = 0600)
244
- tmpfile = file + ".tmp"
245
- sync = Sync.new
246
- unless FileTest.directory?(File.dirname(tmpfile))
247
- raise Puppet::DevError, "Cannot create %s; directory %s does not exist" %
248
- [file, File.dirname(file)]
249
- end
250
- sync.synchronize(Sync::EX) do
251
- File.open(file, "r+", mode) do |rf|
252
- rf.lock_exclusive do
253
- File.open(tmpfile, "w", mode) do |tf|
254
- yield tf
255
- end
256
- begin
257
- File.rename(tmpfile, file)
258
- rescue => detail
259
- Puppet.err "Could not rename %s to %s: %s" %
260
- [file, tmpfile, detail]
261
- end
262
- end
263
- end
264
- end
265
- end
266
-
267
-
268
241
  # Sign a given certificate request.
269
242
  def sign(csr)
270
243
  unless csr.is_a?(OpenSSL::X509::Request)
@@ -278,9 +251,8 @@ class Puppet::SSLCertificates::CA
278
251
  end
279
252
 
280
253
  serial = nil
281
- readwritelock(@config[:serial]) { |f|
254
+ Puppet.settings.readwritelock(:serial) { |f|
282
255
  serial = File.read(@config[:serial]).chomp.hex
283
-
284
256
  # increment the serial
285
257
  f << "%04X" % (serial + 1)
286
258
  }
@@ -155,8 +155,6 @@ class Type
155
155
  @parameters = {}
156
156
  end
157
157
 
158
- # set defalts
159
- @noop = false
160
158
  # keeping stats for the total number of changes, and how many were
161
159
  # completely sync'ed
162
160
  # this isn't really sufficient either, because it adds lots of special
@@ -66,6 +66,9 @@ Puppet::Type.type(:file).newproperty(:checksum) do
66
66
  raise ArgumentError, "A type must be specified to cache a checksum"
67
67
  end
68
68
  type = symbolize(type)
69
+ type = :mtime if type == :timestamp
70
+ type = :ctime if type == :time
71
+
69
72
  unless state = @resource.cached(:checksums)
70
73
  self.debug "Initializing checksum hash"
71
74
  state = {}
@@ -87,8 +87,10 @@ module Puppet
87
87
  isnamevar
88
88
 
89
89
  validate do |value|
90
- unless value =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/
91
- raise Puppet::Error, "Invalid host name"
90
+ value.split('.').each do |hostpart|
91
+ unless hostpart =~ /^([\d\w]+|[\d\w][\d\w\-]+[\d\w])$/
92
+ raise Puppet::Error, "Invalid host name"
93
+ end
92
94
  end
93
95
  end
94
96
  end
@@ -1,5 +1,5 @@
1
1
  module Puppet
2
- newtype(:tidy, Puppet.type(:file)) do
2
+ newtype(:tidy, :parent => Puppet.type(:file)) do
3
3
  @doc = "Remove unwanted files based on specific criteria. Multiple
4
4
  criteria are OR'd together, so a file that is too large but is not
5
5
  old enough will still get tidied."
@@ -104,7 +104,11 @@ class Puppet::Util::FileType
104
104
  # Overwrite the file.
105
105
  def write(text)
106
106
  backup()
107
- File.open(@path, "w") { |f| f.print text; f.flush }
107
+ require "tempfile"
108
+ tf = Tempfile.new("puppet")
109
+ tf.print text; tf.flush
110
+ FileUtils.cp(tf.path, @path)
111
+ tf.close
108
112
  end
109
113
  end
110
114
 
@@ -243,14 +243,7 @@ class Puppet::Util::Settings
243
243
 
244
244
  # Make a directory with the appropriate user, group, and mode
245
245
  def mkdir(default)
246
- obj = nil
247
- unless obj = @config[default]
248
- raise ArgumentError, "Unknown default %s" % default
249
- end
250
-
251
- unless obj.is_a? CFile
252
- raise ArgumentError, "Default %s is not a file" % default
253
- end
246
+ obj = get_config_file_default(default)
254
247
 
255
248
  Puppet::Util::SUIDManager.asuser(obj.owner, obj.group) do
256
249
  mode = obj.mode || 0750
@@ -737,49 +730,15 @@ Generated on #{Time.now}.
737
730
  end
738
731
 
739
732
  # Open a file with the appropriate user, group, and mode
740
- def write(default, *args)
741
- obj = nil
742
- unless obj = @config[default]
743
- raise ArgumentError, "Unknown default %s" % default
744
- end
745
-
746
- unless obj.is_a? CFile
747
- raise ArgumentError, "Default %s is not a file" % default
748
- end
749
-
750
- chown = nil
751
- if Puppet::Util::SUIDManager.uid == 0
752
- chown = [obj.owner, obj.group]
753
- else
754
- chown = [nil, nil]
755
- end
756
- Puppet::Util::SUIDManager.asuser(*chown) do
757
- mode = obj.mode || 0640
758
-
759
- if args.empty?
760
- args << "w"
761
- end
762
-
763
- args << mode
764
-
765
- File.open(value(obj.name), *args) do |file|
766
- yield file
767
- end
768
- end
733
+ def write(default, *args, &bloc)
734
+ obj = get_config_file_default(default)
735
+ writesub(default, value(obj.name), *args, &bloc)
769
736
  end
770
737
 
771
738
  # Open a non-default file under a default dir with the appropriate user,
772
739
  # group, and mode
773
- def writesub(default, file, *args)
774
- obj = nil
775
- unless obj = @config[default]
776
- raise ArgumentError, "Unknown default %s" % default
777
- end
778
-
779
- unless obj.is_a? CFile
780
- raise ArgumentError, "Default %s is not a file" % default
781
- end
782
-
740
+ def writesub(default, file, *args, &bloc)
741
+ obj = get_config_file_default(default)
783
742
  chown = nil
784
743
  if Puppet::Util::SUIDManager.uid == 0
785
744
  chown = [obj.owner, obj.group]
@@ -804,8 +763,51 @@ Generated on #{Time.now}.
804
763
  end
805
764
  end
806
765
 
766
+ def readwritelock(default, *args, &bloc)
767
+ file = value(get_config_file_default(default).name)
768
+ tmpfile = file + ".tmp"
769
+ sync = Sync.new
770
+ unless FileTest.directory?(File.dirname(tmpfile))
771
+ raise Puppet::DevError, "Cannot create %s; directory %s does not exist" %
772
+ [file, File.dirname(file)]
773
+ end
774
+
775
+ sync.synchronize(Sync::EX) do
776
+ File.open(file, "r+", 0600) do |rf|
777
+ rf.lock_exclusive do
778
+ if File.exist?(tmpfile)
779
+ raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" %
780
+ [file]
781
+ end
782
+
783
+ writesub(default, tmpfile, *args, &bloc)
784
+
785
+ begin
786
+ File.rename(tmpfile, file)
787
+ rescue => detail
788
+ Puppet.err "Could not rename %s to %s: %s" %
789
+ [file, tmpfile, detail]
790
+ end
791
+ end
792
+ end
793
+ end
794
+ end
795
+
807
796
  private
808
797
 
798
+ def get_config_file_default(default)
799
+ obj = nil
800
+ unless obj = @config[default]
801
+ raise ArgumentError, "Unknown default %s" % default
802
+ end
803
+
804
+ unless obj.is_a? CFile
805
+ raise ArgumentError, "Default %s is not a file" % default
806
+ end
807
+
808
+ return obj
809
+ end
810
+
809
811
  # Create the transportable objects for users and groups.
810
812
  def add_user_resources(section, obj, done)
811
813
  resources = []
@@ -23,95 +23,6 @@ class TestResource < PuppetTest::TestCase
23
23
  mocha_verify
24
24
  end
25
25
 
26
- def test_initialize
27
- args = {:type => "resource", :title => "testing",
28
- :scope => mkscope}
29
- # Check our arg requirements
30
- args.each do |name, value|
31
- try = args.dup
32
- try.delete(name)
33
- assert_raise(ArgumentError, "Did not fail when %s was missing" % name) do
34
- Parser::Resource.new(try)
35
- end
36
- end
37
-
38
- res = nil
39
- assert_nothing_raised do
40
- res = Parser::Resource.new(args)
41
- end
42
-
43
- ref = res.instance_variable_get("@ref")
44
- assert_equal("Resource", ref.type, "did not set resource type")
45
- assert_equal("testing", ref.title, "did not set resource title")
46
- end
47
-
48
- def test_merge
49
- res = mkresource
50
- other = mkresource
51
-
52
- # First try the case where the resource is not allowed to override
53
- res.source = "source1"
54
- other.source = "source2"
55
- other.source.expects(:child_of?).with("source1").returns(false)
56
- assert_raise(Puppet::ParseError, "Allowed unrelated resources to override") do
57
- res.merge(other)
58
- end
59
-
60
- # Next try it when the sources are equal.
61
- res.source = "source3"
62
- other.source = res.source
63
- other.source.expects(:child_of?).with("source3").never
64
- params = {:a => :b, :c => :d}
65
- other.expects(:params).returns(params)
66
- res.expects(:override_parameter).with(:b)
67
- res.expects(:override_parameter).with(:d)
68
- res.merge(other)
69
-
70
- # And then parentage is involved
71
- other = mkresource
72
- res.source = "source3"
73
- other.source = "source4"
74
- other.source.expects(:child_of?).with("source3").returns(true)
75
- params = {:a => :b, :c => :d}
76
- other.expects(:params).returns(params)
77
- res.expects(:override_parameter).with(:b)
78
- res.expects(:override_parameter).with(:d)
79
- res.merge(other)
80
- end
81
-
82
- # the [] method
83
- def test_array_accessors
84
- res = mkresource
85
- params = res.instance_variable_get("@params")
86
- assert_nil(res[:missing], "Found a missing parameter somehow")
87
- params[:something] = stub(:value => "yay")
88
- assert_equal("yay", res[:something], "Did not correctly call value on the parameter")
89
-
90
- res.expects(:title).returns(:mytitle)
91
- assert_equal(:mytitle, res[:title], "Did not call title when asked for it as a param")
92
- end
93
-
94
- # Make sure any defaults stored in the scope get added to our resource.
95
- def test_add_defaults
96
- res = mkresource
97
- params = res.instance_variable_get("@params")
98
- params[:a] = :b
99
- res.scope.expects(:lookupdefaults).with(res.type).returns(:a => :replaced, :c => :d)
100
- res.expects(:debug)
101
-
102
- res.send(:add_defaults)
103
- assert_equal(:d, params[:c], "Did not set default")
104
- assert_equal(:b, params[:a], "Replaced parameter with default")
105
- end
106
-
107
- def test_finish
108
- res = mkresource
109
- res.expects(:add_defaults)
110
- res.expects(:add_metaparams)
111
- res.expects(:validate)
112
- res.finish
113
- end
114
-
115
26
  # Make sure we paramcheck our params
116
27
  def test_validate
117
28
  res = mkresource
@@ -123,43 +34,6 @@ class TestResource < PuppetTest::TestCase
123
34
  res.send(:validate)
124
35
  end
125
36
 
126
- def test_override_parameter
127
- res = mkresource
128
- params = res.instance_variable_get("@params")
129
-
130
- # There are three cases, with the second having two options:
131
-
132
- # No existing parameter.
133
- param = stub(:name => "myparam")
134
- res.send(:override_parameter, param)
135
- assert_equal(param, params["myparam"], "Override was not added to param list")
136
-
137
- # An existing parameter that we can override.
138
- source = stub(:child_of? => true)
139
- # Start out without addition
140
- params["param2"] = stub(:source => :whatever)
141
- param = stub(:name => "param2", :source => source, :add => false)
142
- res.send(:override_parameter, param)
143
- assert_equal(param, params["param2"], "Override was not added to param list")
144
-
145
- # Try with addition.
146
- params["param2"] = stub(:value => :a, :source => :whatever)
147
- param = stub(:name => "param2", :source => source, :add => true, :value => :b)
148
- param.expects(:value=).with([:a, :b])
149
- res.send(:override_parameter, param)
150
- assert_equal(param, params["param2"], "Override was not added to param list")
151
-
152
- # And finally, make sure we throw an exception when the sources aren't related
153
- source = stub(:child_of? => false)
154
- params["param2"] = stub(:source => :whatever, :file => :f, :line => :l)
155
- old = params["param2"]
156
- param = stub(:name => "param2", :source => source, :file => :f, :line => :l)
157
- assert_raise(Puppet::ParseError, "Did not fail when params conflicted") do
158
- res.send(:override_parameter, param)
159
- end
160
- assert_equal(old, params["param2"], "Param was replaced irrespective of conflict")
161
- end
162
-
163
37
  def test_set_parameter
164
38
  res = mkresource
165
39
  params = res.instance_variable_get("@params")
@@ -420,37 +294,4 @@ class TestResource < PuppetTest::TestCase
420
294
  assert(newres.exported?, "Exported defined resource generated non-exported resources")
421
295
  assert(newres.virtual?, "Exported defined resource generated non-virtual resources")
422
296
  end
423
-
424
- # Make sure tags behave appropriately.
425
- def test_tags
426
- scope_resource = stub 'scope_resource', :tags => %w{srone srtwo}
427
- scope = stub 'scope', :resource => scope_resource
428
- resource = Puppet::Parser::Resource.new(:type => "file", :title => "yay", :scope => scope, :source => mock('source'))
429
-
430
- # Make sure we get the type and title
431
- %w{yay file}.each do |tag|
432
- assert(resource.tags.include?(tag), "Did not tag resource with %s" % tag)
433
- end
434
-
435
- # make sure we can only set legal tags
436
- ["an invalid tag", "-anotherinvalid", "bad*tag"].each do |tag|
437
- assert_raise(Puppet::ParseError, "Tag #{tag} was considered valid") do
438
- resource.tag tag
439
- end
440
- end
441
-
442
- # make sure good tags make it through.
443
- tags = %w{good-tag yaytag GoodTag another_tag a ab A}
444
- tags.each do |tag|
445
- assert_nothing_raised("Tag #{tag} was considered invalid") do
446
- resource.tag tag
447
- end
448
- end
449
-
450
- # make sure we get each of them.
451
- ptags = resource.tags
452
- tags.each do |tag|
453
- assert(ptags.include?(tag.downcase), "missing #{tag}")
454
- end
455
- end
456
297
  end
@@ -76,8 +76,15 @@ class TestMaster < Test::Unit::TestCase
76
76
  Puppet[:node_name] = "cert"
77
77
 
78
78
  # Make sure we get the fact data back when nothing is set
79
- facts = {"hostname" => "fact_hostname", "ipaddress" => "fact_ip"}
80
- certname = "cert_hostname"
79
+ facts = {
80
+ "hostname" => "fact_hostname",
81
+ "domain" => "fact_domain",
82
+ "fqdn" => "fact_hostname.fact_domain",
83
+ "ipaddress" => "fact_ip"
84
+ }
85
+ certhostname = "cert_hostname"
86
+ certdomain = "cert_domain"
87
+ certname = certhostname + "." + certdomain
81
88
  certip = "cert_ip"
82
89
 
83
90
  resname, resip = master.send(:clientname, nil, nil, facts)
@@ -678,22 +678,6 @@ class TestType < Test::Unit::TestCase
678
678
  assert_equal("Exec[yay]", exec.ref)
679
679
  end
680
680
 
681
- def test_noop_metaparam
682
- file = Puppet::Type.newfile :path => tempfile
683
- assert(!file.noop, "file incorrectly in noop")
684
-
685
- assert_nothing_raised do
686
- file[:noop] = true
687
- end
688
- assert(file.noop, "file should be in noop")
689
-
690
- # Now set the main one
691
- Puppet[:noop] = true
692
- assert(file.noop, "file should be in noop")
693
- file[:noop] = false
694
- assert(file.noop, "file should be in noop")
695
- end
696
-
697
681
  def test_path
698
682
  config = mk_catalog
699
683
 
@@ -153,6 +153,50 @@ class TestHost < Test::Unit::TestCase
153
153
  assert_raise(Puppet::Error) {
154
154
  host[:name] = "!invalid.hostname.$$$"
155
155
  }
156
+
157
+ assert_raise(Puppet::Error) {
158
+ host[:name] = "-boo"
159
+ }
160
+
161
+ assert_raise(Puppet::Error) {
162
+ host[:name] = "boo-.ness"
163
+ }
164
+
165
+ assert_raise(Puppet::Error) {
166
+ host[:name] = "boo..ness"
167
+ }
168
+ end
169
+
170
+ def test_valid_hostname
171
+ host = mkhost()
172
+
173
+ assert_nothing_raised {
174
+ host[:name] = "yayness"
175
+ }
176
+
177
+ assert_nothing_raised {
178
+ host[:name] = "yay-ness"
179
+ }
180
+
181
+ assert_nothing_raised {
182
+ host[:name] = "yay.ness"
183
+ }
184
+
185
+ assert_nothing_raised {
186
+ host[:name] = "yay.ne-ss"
187
+ }
188
+
189
+ assert_nothing_raised {
190
+ host[:name] = "y.ay-ne-ss.com"
191
+ }
192
+
193
+ assert_nothing_raised {
194
+ host[:name] = "y4y.n3-ss"
195
+ }
196
+
197
+ assert_nothing_raised {
198
+ host[:name] = "y"
199
+ }
156
200
  end
157
201
 
158
202
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: puppet
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.24.2
7
- date: 2008-03-03 00:00:00 +01:00
6
+ version: 0.24.3
7
+ date: 2008-03-17 00:00:00 +01:00
8
8
  summary: System Automation and Configuration Management Software
9
9
  require_paths:
10
10
  - lib