puppet 0.24.3 → 0.24.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 (58) hide show
  1. data/CHANGELOG +66 -0
  2. data/Rakefile +8 -0
  3. data/bin/puppetd +20 -10
  4. data/bin/puppetmasterd +3 -0
  5. data/conf/redhat/puppet.spec +1 -1
  6. data/ext/emacs/puppet-mode.el +132 -70
  7. data/ext/puppet-test +2 -1
  8. data/install.rb +70 -0
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/defaults.rb +7 -8
  11. data/lib/puppet/file_serving/configuration/parser.rb +4 -2
  12. data/lib/puppet/indirector/facts/facter.rb +2 -1
  13. data/lib/puppet/indirector/node/ldap.rb +2 -1
  14. data/lib/puppet/indirector/node/plain.rb +7 -0
  15. data/lib/puppet/indirector/report/processor.rb +2 -1
  16. data/lib/puppet/indirector/yaml.rb +0 -5
  17. data/lib/puppet/metatype/evaluation.rb +13 -3
  18. data/lib/puppet/metatype/metaparams.rb +3 -3
  19. data/lib/puppet/metatype/providers.rb +2 -9
  20. data/lib/puppet/network/authstore.rb +2 -1
  21. data/lib/puppet/network/client.rb +3 -2
  22. data/lib/puppet/network/client/master.rb +4 -2
  23. data/lib/puppet/network/handler/fileserver.rb +0 -49
  24. data/lib/puppet/network/handler/master.rb +1 -1
  25. data/lib/puppet/network/handler/report.rb +2 -1
  26. data/lib/puppet/network/http/mongrel/rest.rb +4 -2
  27. data/lib/puppet/network/http/webrick/rest.rb +5 -3
  28. data/lib/puppet/network/http_pool.rb +18 -7
  29. data/lib/puppet/node.rb +1 -1
  30. data/lib/puppet/node/environment.rb +2 -1
  31. data/lib/puppet/parser/parser_support.rb +12 -9
  32. data/lib/puppet/provider/mailalias/aliases.rb +4 -1
  33. data/lib/puppet/provider/package/openbsd.rb +10 -2
  34. data/lib/puppet/provider/package/ports.rb +1 -2
  35. data/lib/puppet/provider/user/useradd.rb +1 -1
  36. data/lib/puppet/provider/zone/solaris.rb +2 -1
  37. data/lib/puppet/resource_reference.rb +2 -1
  38. data/lib/puppet/transportable.rb +28 -20
  39. data/lib/puppet/type/exec.rb +5 -0
  40. data/lib/puppet/type/host.rb +2 -1
  41. data/lib/puppet/type/service.rb +3 -1
  42. data/lib/puppet/util.rb +2 -1
  43. data/lib/puppet/util/constant_inflector.rb +2 -1
  44. data/lib/puppet/util/diff.rb +2 -2
  45. data/lib/puppet/util/fileparsing.rb +2 -1
  46. data/lib/puppet/util/settings.rb +26 -23
  47. data/lib/puppet/util/tagging.rb +2 -1
  48. data/test/language/parser.rb +1 -0
  49. data/test/lib/puppettest.rb +6 -1
  50. data/test/network/client/client.rb +0 -29
  51. data/test/network/client/master.rb +31 -0
  52. data/test/network/handler/master.rb +4 -0
  53. data/test/ral/manager/provider.rb +21 -5
  54. data/test/ral/providers/cron/crontab.rb +0 -1
  55. data/test/ral/providers/mailalias/aliases.rb +0 -1
  56. data/test/ral/providers/sshkey/parsed.rb +0 -1
  57. data/test/ral/type/tidy.rb +6 -7
  58. metadata +2 -2
@@ -10,7 +10,10 @@ Puppet::Type.type(:mailalias).provide(:aliases,
10
10
 
11
11
  record_line :aliases, :fields => %w{name recipient}, :separator => /\s*:\s*/, :block_eval => :instance do
12
12
  def post_parse(record)
13
- record[:recipient] = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') }
13
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
14
+ # It's not sufficient to assign to an existing hash.
15
+ recipient = record[:recipient].split(/\s*,\s*/).collect { |d| d.gsub(/^['"]|['"]$/, '') }
16
+ record[:recipient] = recipient
14
17
  record
15
18
  end
16
19
 
@@ -2,6 +2,7 @@ require 'puppet/provider/package'
2
2
 
3
3
  # Packaging on OpenBSD. Doesn't work anywhere else that I know of.
4
4
  Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Package do
5
+ include Puppet::Util::Execution
5
6
  desc "OpenBSD's form of ``pkg_add`` support."
6
7
 
7
8
  commands :pkginfo => "pkg_info", :pkgadd => "pkg_add", :pkgdelete => "pkg_delete"
@@ -58,7 +59,14 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
58
59
  "You must specify a package source for BSD packages"
59
60
  end
60
61
 
61
- pkgadd @resource[:source]
62
+ if @resource[:source] =~ /\/$/
63
+ withenv :PKG_PATH => @resource[:source] do
64
+ pkgadd @resource[:name]
65
+ end
66
+ else
67
+ pkgadd @resource[:source]
68
+ end
69
+
62
70
  end
63
71
 
64
72
  def query
@@ -67,7 +75,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
67
75
 
68
76
  # Search for the version info
69
77
  if info =~ /Information for (inst:)?#{@resource[:name]}-(\S+)/
70
- hash[:ensure] = $1
78
+ hash[:ensure] = $2
71
79
  else
72
80
  return nil
73
81
  end
@@ -1,6 +1,5 @@
1
1
  Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :freebsd do
2
- desc "Support for FreeBSD's ports. Again, this still mixes packages
3
- and ports."
2
+ desc "Support for FreeBSD's ports. Again, this still mixes packages and ports."
4
3
 
5
4
  commands :portupgrade => "/usr/local/sbin/portupgrade",
6
5
  :portversion => "/usr/local/sbin/portversion",
@@ -1,7 +1,7 @@
1
1
  require 'puppet/provider/nameservice/objectadd'
2
2
 
3
3
  Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameService::ObjectAdd do
4
- desc "User management via ``useradd`` and its ilk. Note that you'll have to install the ``Shadow Password`` library to manage user passwords."
4
+ desc "User management via ``useradd`` and its ilk. Note that you will need to install the ``Shadow Password`` Ruby library often known as ruby-libshadow to manage user passwords."
5
5
 
6
6
  commands :add => "useradd", :delete => "userdel", :modify => "usermod"
7
7
 
@@ -26,7 +26,8 @@ Puppet::Type.type(:zone).provide(:solaris) do
26
26
  end
27
27
 
28
28
  def self.instances
29
- adm(:list, "-cp").split("\n").collect do |line|
29
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
30
+ x = adm(:list, "-cp").split("\n").collect do |line|
30
31
  new(line2hash(line))
31
32
  end
32
33
  end
@@ -49,7 +49,8 @@ class Puppet::ResourceReference
49
49
  if value.nil? or value.to_s.downcase == "component"
50
50
  @type = "Class"
51
51
  else
52
- @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::")
52
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
53
+ x = @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::")
53
54
  end
54
55
  end
55
56
 
@@ -83,14 +83,11 @@ module Puppet
83
83
  end
84
84
 
85
85
  def to_type
86
- retobj = nil
87
86
  if typeklass = Puppet::Type.type(self.type)
88
87
  return typeklass.create(self)
89
88
  else
90
89
  return to_component
91
90
  end
92
-
93
- return retobj
94
91
  end
95
92
  end
96
93
 
@@ -179,28 +176,39 @@ module Puppet
179
176
  end
180
177
 
181
178
  # Create a resource graph from our structure.
182
- def to_catalog
183
- catalog = Puppet::Node::Catalog.new(Facter.value("hostname")) do |config|
184
- delver = proc do |obj|
185
- obj.catalog = config
186
- unless container = config.resource(obj.to_ref)
187
- container = obj.to_type
188
- config.add_resource container
179
+ def to_catalog(clear_on_failure = true)
180
+ catalog = Puppet::Node::Catalog.new(Facter.value("hostname"))
181
+
182
+ # This should really use the 'delve' method, but this
183
+ # whole class is going away relatively soon, hopefully,
184
+ # so it's not worth it.
185
+ delver = proc do |obj|
186
+ obj.catalog = catalog
187
+ unless container = catalog.resource(obj.to_ref)
188
+ container = obj.to_type
189
+ catalog.add_resource container
190
+ end
191
+ obj.each do |child|
192
+ child.catalog = catalog
193
+ unless resource = catalog.resource(child.to_ref)
194
+ resource = child.to_type
195
+ catalog.add_resource resource
189
196
  end
190
- obj.each do |child|
191
- child.catalog = config
192
- unless resource = config.resource(child.to_ref)
193
- next unless resource = child.to_type
194
- config.add_resource resource
195
- end
196
- config.add_edge(container, resource)
197
- if child.is_a?(self.class)
198
- delver.call(child)
199
- end
197
+
198
+ catalog.add_edge(container, resource)
199
+ if child.is_a?(self.class)
200
+ delver.call(child)
200
201
  end
201
202
  end
203
+ end
202
204
 
205
+ begin
203
206
  delver.call(self)
207
+ catalog.finalize
208
+ rescue => detail
209
+ # This is important until we lose the global resource references.
210
+ catalog.clear if (clear_on_failure)
211
+ raise
204
212
  end
205
213
 
206
214
  return catalog
@@ -390,6 +390,11 @@ module Puppet
390
390
 
391
391
  Note that this command follows the same rules as the main command,
392
392
  which is to say that it must be fully qualified if the path is not set.
393
+
394
+ Also note that onlyif can take an array as its value, eg:
395
+ onlyif => [\"test -f /tmp/file1\", \"test -f /tmp/file2\"]
396
+
397
+ This will only run the exec if /all/ conditions in the array return true.
393
398
  "
394
399
 
395
400
  validate do |cmds|
@@ -87,7 +87,8 @@ module Puppet
87
87
  isnamevar
88
88
 
89
89
  validate do |value|
90
- value.split('.').each do |hostpart|
90
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
91
+ x = value.split('.').each do |hostpart|
91
92
  unless hostpart =~ /^([\d\w]+|[\d\w][\d\w\-]+[\d\w])$/
92
93
  raise Puppet::Error, "Invalid host name"
93
94
  end
@@ -113,7 +113,9 @@ module Puppet
113
113
 
114
114
  munge do |value|
115
115
  value = [value] unless value.is_a?(Array)
116
- paths = value.flatten.collect { |p| p.split(":") }.flatten.find_all do |path|
116
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
117
+ # It affects stand-alone blocks, too.
118
+ paths = value.flatten.collect { |p| x = p.split(":") }.flatten.find_all do |path|
117
119
  if FileTest.directory?(path)
118
120
  true
119
121
  else
@@ -226,7 +226,8 @@ module Util
226
226
  return nil
227
227
  end
228
228
  else
229
- ENV['PATH'].split(":").each do |dir|
229
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
230
+ x = ENV['PATH'].split(":").each do |dir|
230
231
  if FileTest.exists? File.join(dir, bin)
231
232
  return File.join(dir, bin)
232
233
  end
@@ -5,7 +5,8 @@
5
5
  # file names.
6
6
  module Puppet::Util::ConstantInflector
7
7
  def file2constant(file)
8
- file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize }
8
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
9
+ x = file.split("/").collect { |name| name.capitalize }.join("::").gsub(/_+(.)/) { |term| $1.capitalize }
9
10
  end
10
11
 
11
12
  def constant2file(constant)
@@ -27,7 +27,7 @@ module Puppet::Util::Diff
27
27
 
28
28
  output = ""
29
29
 
30
- diffs = Diff::LCS.diff(data_old, data_new)
30
+ diffs = ::Diff::LCS.diff(data_old, data_new)
31
31
  return output if diffs.empty?
32
32
 
33
33
  oldhunk = hunk = nil
@@ -35,7 +35,7 @@ module Puppet::Util::Diff
35
35
 
36
36
  diffs.each do |piece|
37
37
  begin
38
- hunk = Diff::LCS::Hunk.new(data_old, data_new, piece,
38
+ hunk = ::Diff::LCS::Hunk.new(data_old, data_new, piece,
39
39
  context_lines,
40
40
  file_length_difference)
41
41
  file_length_difference = hunk.file_length_difference
@@ -223,7 +223,8 @@ module Puppet::Util::FileParsing
223
223
  # Split text into separate lines using the record separator.
224
224
  def lines(text)
225
225
  # Remove any trailing separators, and then split based on them
226
- text.sub(/#{self.line_separator}\Q/,'').split(self.line_separator)
226
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
227
+ x = text.sub(/#{self.line_separator}\Q/,'').split(self.line_separator)
227
228
  end
228
229
 
229
230
  # Split a bunch of text into lines and then parse them individually.
@@ -44,19 +44,6 @@ class Puppet::Util::Settings
44
44
  return value
45
45
  end
46
46
 
47
- # A simplified equality operator.
48
- # LAK: For some reason, this causes mocha to not be able to mock
49
- # the 'value' method, and it's not used anywhere.
50
- # def ==(other)
51
- # self.each { |myname, myobj|
52
- # unless other[myname] == value(myname)
53
- # return false
54
- # end
55
- # }
56
- #
57
- # return true
58
- # end
59
-
60
47
  # Generate the list of valid arguments, in a format that GetoptLong can
61
48
  # understand, and add them to the passed option list.
62
49
  def addargs(options)
@@ -225,6 +212,9 @@ class Puppet::Util::Settings
225
212
 
226
213
  # A central concept of a name.
227
214
  @name = nil
215
+
216
+ # The list of sections we've used.
217
+ @used = []
228
218
  end
229
219
 
230
220
  # Return a given object's file metadata.
@@ -663,23 +653,36 @@ Generated on #{Time.now}.
663
653
  # you can 'use' a section as many times as you want.
664
654
  def use(*sections)
665
655
  @@sync.synchronize do # yay, thread-safe
666
- unless defined? @used
667
- @used = []
668
- end
656
+ sections = sections.reject { |s| @used.include?(s.to_sym) }
657
+
658
+ return if sections.empty?
669
659
 
670
660
  bucket = to_transportable(*sections)
671
661
 
672
- config = bucket.to_catalog
673
- config.host_config = false
674
- config.apply do |transaction|
675
- if failures = transaction.any_failed?
676
- raise "Could not configure for running; got %s failure(s)" % failures
662
+ begin
663
+ catalog = bucket.to_catalog
664
+ rescue => detail
665
+ puts detail.backtrace if Puppet[:trace]
666
+ Puppet.err "Could not create resources for managing Puppet's files and directories: %s" % detail
667
+
668
+ # We need some way to get rid of any resources created during the catalog creation
669
+ # but not cleaned up.
670
+ return
671
+ end
672
+
673
+ begin
674
+ catalog.host_config = false
675
+ catalog.apply do |transaction|
676
+ if failures = transaction.any_failed?
677
+ raise "Could not configure for running; got %s failure(s)" % failures
678
+ end
677
679
  end
680
+ ensure
681
+ catalog.clear
678
682
  end
679
- config.clear
680
683
 
681
684
  sections.each { |s| @used << s }
682
- @used.uniq
685
+ @used.uniq!
683
686
  end
684
687
  end
685
688
 
@@ -16,7 +16,8 @@ module Puppet::Util::Tagging
16
16
  @tags << tag unless @tags.include?(tag)
17
17
  end
18
18
 
19
- qualified.collect { |name| name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
19
+ # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
20
+ qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
20
21
  end
21
22
 
22
23
  # Are we tagged with the provided tag?
@@ -1141,6 +1141,7 @@ file { "/tmp/yayness":
1141
1141
  name = "sub"
1142
1142
  mk_module(modname, :init => %w{separate}, :sub => %w{separate::sub})
1143
1143
 
1144
+ Puppet.err :yay
1144
1145
  # First try it with a namespace
1145
1146
  klass = parser.findclass("separate", name)
1146
1147
  assert_instance_of(AST::HostClass, klass, "Did not autoload sub class from separate file with a namespace")
@@ -43,6 +43,10 @@ class Class
43
43
  end
44
44
 
45
45
  module PuppetTest
46
+ # These need to be here for when rspec tests use these
47
+ # support methods.
48
+ @@tmpfiles = []
49
+
46
50
  # Munge cli arguments, so we can enable debugging if we want
47
51
  # and so we can run just specific methods.
48
52
  def self.munge_argv
@@ -189,7 +193,7 @@ module PuppetTest
189
193
  Dir.mkdir(@configpath)
190
194
  end
191
195
 
192
- @@tmpfiles = [@configpath, tmpdir()]
196
+ @@tmpfiles << @configpath << tmpdir()
193
197
  @@tmppids = []
194
198
 
195
199
  @@cleaners = []
@@ -293,6 +297,7 @@ module PuppetTest
293
297
  }
294
298
 
295
299
  @@tmppids.clear
300
+
296
301
  Puppet::Type.allclear
297
302
  Puppet::Util::Storage.clear
298
303
  Puppet.clear
@@ -140,35 +140,6 @@ class TestClient < Test::Unit::TestCase
140
140
  }
141
141
  end
142
142
 
143
- def test_classfile
144
- Puppet[:code] = "class yaytest {}\n class bootest {}\n include yaytest, bootest"
145
-
146
- Puppet::Node::Facts.indirection.stubs(:save)
147
-
148
- master = client = nil
149
- assert_nothing_raised() {
150
- master = Puppet::Network::Handler.master.new(
151
- :Local => false
152
- )
153
- }
154
- assert_nothing_raised() {
155
- client = Puppet::Network::Client.master.new(
156
- :Master => master
157
- )
158
- }
159
-
160
- # Fake that it's local, so it creates the class file
161
- client.local = false
162
-
163
- # We can't guarantee class ordering
164
- client.expects(:setclasses).with do |array|
165
- array.length == 2 and array.include?("yaytest") and array.include?("bootest")
166
- end
167
- assert_nothing_raised {
168
- client.getconfig
169
- }
170
- end
171
-
172
143
  def test_client_loading
173
144
  # Make sure we don't get a failure but that we also get nothing back
174
145
  assert_nothing_raised do
@@ -349,6 +349,8 @@ end
349
349
  File.open(source, "w") { |f| f.puts "something" }
350
350
  dest = tempfile
351
351
  Puppet[:noop] = true
352
+ node = stub 'node', :environment => "development"
353
+ Puppet::Node.stubs(:find).returns node
352
354
  assert_nothing_raised("Could not download in noop") do
353
355
  @master.download(:dest => dest, :source => source, :tag => "yay")
354
356
  end
@@ -574,4 +576,33 @@ end
574
576
  # Doesn't throw an exception, but definitely fails.
575
577
  client.run
576
578
  end
579
+
580
+ def test_classfile
581
+ Puppet[:code] = "class yaytest {}\n class bootest {}\n include yaytest, bootest"
582
+
583
+ Puppet::Node::Facts.indirection.stubs(:save)
584
+
585
+ master = client = nil
586
+ assert_nothing_raised() {
587
+ master = Puppet::Network::Handler.master.new(
588
+ :Local => false
589
+ )
590
+ }
591
+ assert_nothing_raised() {
592
+ client = Puppet::Network::Client.master.new(
593
+ :Master => master
594
+ )
595
+ }
596
+
597
+ # Fake that it's local, so it creates the class file
598
+ client.local = false
599
+
600
+ # We can't guarantee class ordering
601
+ client.expects(:setclasses).with do |array|
602
+ array.length == 2 and array.include?("yaytest") and array.include?("bootest")
603
+ end
604
+ assert_nothing_raised {
605
+ client.getconfig
606
+ }
607
+ end
577
608
  end