puppet 2.7.23 → 2.7.24

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 (43) hide show
  1. data/Gemfile +23 -7
  2. data/ext/packaging/LICENSE +17 -0
  3. data/ext/packaging/README.md +92 -18
  4. data/ext/packaging/spec/tasks/00_utils_spec.rb +28 -21
  5. data/ext/packaging/spec/tasks/build_object_spec.rb +6 -4
  6. data/ext/packaging/static_artifacts/PackageInfo.plist +3 -0
  7. data/ext/packaging/tasks/00_utils.rake +91 -15
  8. data/ext/packaging/tasks/10_setupvars.rake +39 -24
  9. data/ext/packaging/tasks/20_setupextravars.rake +1 -5
  10. data/ext/packaging/tasks/30_metrics.rake +29 -37
  11. data/ext/packaging/tasks/apple.rake +8 -6
  12. data/ext/packaging/tasks/build.rake +6 -0
  13. data/ext/packaging/tasks/deb.rake +1 -4
  14. data/ext/packaging/tasks/fetch.rake +22 -12
  15. data/ext/packaging/tasks/gem.rake +88 -35
  16. data/ext/packaging/tasks/jenkins.rake +25 -1
  17. data/ext/packaging/tasks/jenkins_dynamic.rake +10 -1
  18. data/ext/packaging/tasks/mock.rake +37 -19
  19. data/ext/packaging/tasks/pe_ship.rake +108 -10
  20. data/ext/packaging/tasks/pe_sign.rake +3 -3
  21. data/ext/packaging/tasks/retrieve.rake +12 -0
  22. data/ext/packaging/tasks/rpm_repos.rake +2 -2
  23. data/ext/packaging/tasks/ship.rake +51 -12
  24. data/ext/packaging/tasks/sign.rake +42 -12
  25. data/ext/packaging/tasks/tar.rake +1 -1
  26. data/ext/packaging/tasks/template.rake +17 -3
  27. data/ext/packaging/tasks/vendor_gems.rake +1 -1
  28. data/ext/packaging/templates/downstream.xml.erb +15 -2
  29. data/ext/packaging/templates/packaging.xml.erb +143 -1
  30. data/ext/packaging/templates/repo.xml.erb +35 -24
  31. data/lib/puppet/transaction.rb +1 -1
  32. data/lib/puppet/type/file.rb +12 -23
  33. data/lib/puppet/type/file/source.rb +2 -2
  34. data/lib/puppet/type/service.rb +3 -2
  35. data/lib/puppet/util.rb +22 -41
  36. data/lib/puppet/version.rb +1 -1
  37. data/spec/integration/type/file_spec.rb +22 -35
  38. data/spec/spec_helper.rb +12 -0
  39. data/spec/unit/application/kick_spec.rb +9 -4
  40. data/spec/unit/indirector/catalog/static_compiler_spec.rb +1 -1
  41. data/spec/unit/type/file/source_spec.rb +8 -7
  42. data/spec/unit/type/file_spec.rb +0 -29
  43. metadata +64 -39
@@ -101,7 +101,7 @@ module Puppet
101
101
  return @content if @content
102
102
  raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source
103
103
 
104
- unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)
104
+ unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source, :links => resource[:links])
105
105
  fail "Could not find any content at %s" % metadata.source
106
106
  end
107
107
  @content = tmp.content
@@ -154,7 +154,7 @@ module Puppet
154
154
  return nil unless value
155
155
  value.each do |source|
156
156
  begin
157
- if data = Puppet::FileServing::Metadata.indirection.find(source)
157
+ if data = Puppet::FileServing::Metadata.indirection.find(source, :links => resource[:links])
158
158
  @metadata = data
159
159
  @metadata.source = source
160
160
  break
@@ -198,8 +198,9 @@ module Puppet
198
198
  newparam :hasrestart do
199
199
  desc "Specify that an init script has a `restart` command. If this is
200
200
  false and you do not specify a command in the `restart` attribute,
201
- the init script's `stop` and `start` commands will be used. Defaults
202
- to true; note that this is a change from earlier versions of Puppet."
201
+ the init script's `stop` and `start` commands will be used.
202
+
203
+ Defaults to false."
203
204
  newvalues(:true, :false)
204
205
  end
205
206
 
data/lib/puppet/util.rb CHANGED
@@ -554,16 +554,21 @@ module Util
554
554
  # and specifically handle the platform, which has all sorts of magic.
555
555
  # So, unlike Unix, we don't pre-prep security; we use the default "quite
556
556
  # secure" tempfile permissions instead. Magic happens later.
557
- unless Puppet.features.microsoft_windows?
557
+ if !Puppet.features.microsoft_windows?
558
558
  # Grab the current file mode, and fall back to the defaults.
559
- stat = file.lstat rescue OpenStruct.new(:mode => default_mode,
560
- :uid => Process.euid,
561
- :gid => Process.egid)
559
+ if file.exist?
560
+ stat = file.lstat
561
+ tempfile.chown(stat.uid, stat.gid)
562
+ effective_mode = stat.mode
563
+ else
564
+ effective_mode = default_mode
565
+ end
562
566
 
563
- # We only care about the bottom four slots, which make the real mode,
564
- # and not the rest of the platform stat call fluff and stuff.
565
- tempfile.chmod(stat.mode & 07777)
566
- tempfile.chown(stat.uid, stat.gid)
567
+ if effective_mode
568
+ # We only care about the bottom four slots, which make the real mode,
569
+ # and not the rest of the platform stat call fluff and stuff.
570
+ tempfile.chmod(effective_mode & 07777)
571
+ end
567
572
  end
568
573
 
569
574
  # OK, now allow the caller to write the content of the file.
@@ -586,41 +591,17 @@ module Util
586
591
  tempfile.close
587
592
 
588
593
  if Puppet.features.microsoft_windows?
589
- # This will appropriately clone the file, but only if the file we are
590
- # replacing exists. Which is kind of annoying; thanks Microsoft.
591
- #
592
- # So, to avoid getting into an infinite loop we will retry once if the
593
- # file doesn't exist, but only the once...
594
- have_retried = false
595
-
596
- begin
597
- # Yes, the arguments are reversed compared to the rename in the rest
598
- # of the world.
599
- Puppet::Util::Windows::File.replace_file(file, tempfile.path)
600
- rescue Puppet::Util::Windows::Error => e
601
- # This might race, but there are enough possible cases that there
602
- # isn't a good, solid "better" way to do this, and the next call
603
- # should fail in the same way anyhow.
604
- raise if have_retried or File.exist?(file)
605
- have_retried = true
606
-
607
- # OK, so, we can't replace a file that doesn't exist, so let us put
608
- # one in place and set the permissions. Then we can retry and the
609
- # magic makes this all work.
610
- #
611
- # This is the least-worst option for handling Windows, as far as we
612
- # can determine.
613
- File.open(file, 'a') do |fh|
614
- # this space deliberately left empty for auto-close behaviour,
615
- # append mode, and not actually changing any of the content.
594
+ # Windows ReplaceFile needs a file to exist, so touch handles this
595
+ if !file.exist?
596
+ FileUtils.touch(file.to_s)
597
+ if default_mode
598
+ Puppet::Util::Windows::Security.set_mode(default_mode, file.to_s)
616
599
  end
617
-
618
- # Set the permissions to what we want.
619
- Puppet::Util::Windows::Security.set_mode(default_mode, file.to_s)
620
-
621
- # ...and finally retry the operation.
622
- retry
623
600
  end
601
+ # Yes, the arguments are reversed compared to the rename in the rest
602
+ # of the world.
603
+ Puppet::Util::Windows::File.replace_file(file, tempfile.path)
604
+
624
605
  else
625
606
  File.rename(tempfile.path, file)
626
607
  end
@@ -6,7 +6,7 @@
6
6
  # Raketasks and such to set the version based on the output of `git describe`
7
7
  #
8
8
  module Puppet
9
- PUPPETVERSION = '2.7.23'
9
+ PUPPETVERSION = '2.7.24'
10
10
 
11
11
  def self.version
12
12
  @puppet_version || PUPPETVERSION
@@ -272,22 +272,20 @@ describe Puppet::Type.type(:file) do
272
272
 
273
273
  describe "that is readable" do
274
274
  it "should set the executable bits when creating the destination (#10315)" do
275
- pending "bug #10315"
276
-
277
275
  catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
278
276
  catalog.apply
279
277
 
278
+ File.should be_directory(path)
280
279
  (get_mode(path) & 07777).should == 0777
281
280
  end
282
281
 
283
282
  it "should set the executable bits when overwriting the destination (#10315)" do
284
- pending "bug #10315"
285
-
286
283
  FileUtils.touch(path)
287
284
 
288
- catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
285
+ catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow, :backup => false)
289
286
  catalog.apply
290
287
 
288
+ File.should be_directory(path)
291
289
  (get_mode(path) & 07777).should == 0777
292
290
  end
293
291
  end
@@ -302,37 +300,41 @@ describe Puppet::Type.type(:file) do
302
300
  set_mode(0700, target)
303
301
  end
304
302
 
305
- it "should not set executable bits when creating the destination (#10315)" do
306
- pending "bug #10315"
307
-
303
+ it "should set executable bits when creating the destination (#10315)" do
308
304
  catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
309
305
  catalog.apply
310
306
 
311
- (get_mode(path) & 07777).should == 0666
307
+ File.should be_directory(path)
308
+ (get_mode(path) & 07777).should == 0777
312
309
  end
313
310
 
314
- it "should not set executable bits when overwriting the destination" do
311
+ it "should set executable bits when overwriting the destination" do
315
312
  FileUtils.touch(path)
316
313
 
317
- catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow)
314
+ catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0666, :links => :follow, :backup => false)
318
315
  catalog.apply
319
316
 
320
- (get_mode(path) & 07777).should == 0666
317
+ File.should be_directory(path)
318
+ (get_mode(path) & 07777).should == 0777
321
319
  end
322
320
  end
323
321
  end
324
322
 
325
323
  describe "to a file" do
326
- let(:target) { tmpfile('file_target') }
324
+ let(:link_target) { tmpfile('file_target') }
327
325
 
328
- it "should create the file, not a symlink (#2817, #10315)" do
329
- pending "bug #2817, #10315"
326
+ before :each do
327
+ FileUtils.touch(link_target)
328
+
329
+ File.symlink(link_target, link)
330
+ end
330
331
 
332
+ it "should create the file, not a symlink (#2817, #10315)" do
331
333
  catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
332
334
  catalog.apply
333
335
 
334
336
  File.should be_file(path)
335
- (get_mode(path) & 07777) == 0600
337
+ (get_mode(path) & 07777).should == 0600
336
338
  end
337
339
 
338
340
  it "should overwrite the file" do
@@ -342,7 +344,7 @@ describe Puppet::Type.type(:file) do
342
344
  catalog.apply
343
345
 
344
346
  File.should be_file(path)
345
- (get_mode(path) & 07777) == 0600
347
+ (get_mode(path) & 07777).should == 0600
346
348
  end
347
349
  end
348
350
 
@@ -364,13 +366,11 @@ describe Puppet::Type.type(:file) do
364
366
 
365
367
  describe "when following all links" do
366
368
  it "should create the destination and apply executable bits (#10315)" do
367
- pending "bug #10315"
368
-
369
369
  catalog.add_resource described_class.new(:path => path, :source => link, :mode => 0600, :links => :follow)
370
370
  catalog.apply
371
371
 
372
372
  File.should be_directory(path)
373
- (get_mode(path) & 07777) == 0777
373
+ (get_mode(path) & 07777).should == 0700
374
374
  end
375
375
 
376
376
  it "should overwrite the destination and apply executable bits" do
@@ -380,7 +380,7 @@ describe Puppet::Type.type(:file) do
380
380
  catalog.apply
381
381
 
382
382
  File.should be_directory(path)
383
- (get_mode(path) & 07777) == 0777
383
+ (get_mode(path) & 0111).should == 0100
384
384
  end
385
385
  end
386
386
  end
@@ -494,20 +494,6 @@ describe Puppet::Type.type(:file) do
494
494
  bucket.bucket.getfile(foomd5).should == "fooyay"
495
495
  bucket.bucket.getfile(barmd5).should == "baryay"
496
496
  end
497
-
498
- it "should propagate failures encountered when renaming the temporary file" do
499
- file = described_class.new :path => path, :content => "foo"
500
- file.stubs(:perform_backup).returns(true)
501
-
502
- catalog.add_resource file
503
-
504
- File.open(path, "w") { |f| f.print "bar" }
505
-
506
- File.expects(:rename).raises ArgumentError
507
-
508
- expect { file.write(:content) }.to raise_error(Puppet::Error, /Could not rename temporary file/)
509
- File.read(path).should == "bar"
510
- end
511
497
  end
512
498
 
513
499
  describe "when recursing" do
@@ -1034,6 +1020,7 @@ describe Puppet::Type.type(:file) do
1034
1020
  describe "on Windows systems", :if => Puppet.features.microsoft_windows? do
1035
1021
  it "should provide valid default values when ACLs are not supported" do
1036
1022
  Puppet::Util::Windows::Security.stubs(:supports_acl?).with(source).returns false
1023
+ Puppet::Util::Windows::Security.stubs(:supports_acl?).with(path).returns true
1037
1024
 
1038
1025
  file = described_class.new(
1039
1026
  :path => path,
data/spec/spec_helper.rb CHANGED
@@ -19,6 +19,7 @@ end
19
19
 
20
20
  require 'pathname'
21
21
  require 'tmpdir'
22
+ require 'fileutils'
22
23
 
23
24
  require 'puppet_spec/verbose'
24
25
  require 'puppet_spec/files'
@@ -42,6 +43,10 @@ RSpec.configure do |config|
42
43
 
43
44
  config.mock_with :mocha
44
45
 
46
+ tmpdir = Dir.mktmpdir("rspecrun")
47
+ oldtmpdir = Dir.tmpdir()
48
+ ENV['TMPDIR'] = tmpdir
49
+
45
50
  if Puppet::Util::Platform.windows?
46
51
  config.output_stream = $stdout
47
52
  config.error_stream = $stderr
@@ -105,4 +110,11 @@ RSpec.configure do |config|
105
110
  # just letting it run all the time.
106
111
  GC.enable
107
112
  end
113
+
114
+ config.after :suite do
115
+ # Clean up switch of TMPDIR, don't know if needed after this, so needs to reset it
116
+ # to old before removing it
117
+ ENV['TMPDIR'] = oldtmpdir
118
+ FileUtils.rm_rf(tmpdir) if File.exists?(tmpdir) && tmpdir.to_s.start_with?(oldtmpdir)
119
+ end
108
120
  end
@@ -2,11 +2,11 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  require 'puppet/application/kick'
5
+ require 'puppet/run'
6
+ require 'puppet/util/ldap/connection'
5
7
 
6
8
  describe Puppet::Application::Kick, :if => Puppet.features.posix? do
7
-
8
9
  before :each do
9
- require 'puppet/util/ldap/connection'
10
10
  Puppet::Util::Ldap::Connection.stubs(:new).returns(stub_everything)
11
11
  @kick = Puppet::Application[:kick]
12
12
  Puppet::Util::Log.stubs(:newdestination)
@@ -227,6 +227,9 @@ describe Puppet::Application::Kick, :if => Puppet.features.posix? do
227
227
  @kick.options.stubs(:[]).with(:ignoreschedules).returns(false)
228
228
  @kick.options.stubs(:[]).with(:foreground).returns(false)
229
229
  @kick.options.stubs(:[]).with(:debug).returns(false)
230
+ @kick.options.stubs(:[]).with(:verbose).returns(false) # needed when logging is initialized
231
+ @kick.options.stubs(:[]).with(:setdest).returns(false) # needed when logging is initialized
232
+
230
233
  @kick.stubs(:print)
231
234
  @kick.preinit
232
235
  @kick.stubs(:parse_options)
@@ -256,7 +259,6 @@ describe Puppet::Application::Kick, :if => Puppet.features.posix? do
256
259
 
257
260
  describe "during call of run_for_host" do
258
261
  before do
259
- require 'puppet/run'
260
262
  options = {
261
263
  :background => true, :ignoreschedules => false, :tags => []
262
264
  }
@@ -264,13 +266,16 @@ describe Puppet::Application::Kick, :if => Puppet.features.posix? do
264
266
  @agent_run = Puppet::Run.new( options.dup )
265
267
  @agent_run.stubs(:status).returns("success")
266
268
 
269
+ # ensure that we don't actually run the agent
270
+ @agent_run.stubs(:run).returns(@agent_run)
271
+
272
+ Puppet::Run.indirection.terminus_class = :local
267
273
  Puppet::Run.indirection.expects(:terminus_class=).with( :rest )
268
274
  Puppet::Run.expects(:new).with( options ).returns(@agent_run)
269
275
  end
270
276
 
271
277
  it "should call run on a Puppet::Run for the given host" do
272
278
  Puppet::Run.indirection.expects(:save).with(@agent_run, 'https://host:8139/production/run/host').returns(@agent_run)
273
-
274
279
  expect { @kick.run_for_host('host') }.to exit_with 0
275
280
  end
276
281
 
@@ -137,7 +137,7 @@ describe Puppet::Resource::Catalog::StaticCompiler do
137
137
  # a real fileserver initialized for testing.
138
138
  Puppet::FileServing::Metadata.
139
139
  indirection.stubs(:find).
140
- with(options[:source].sub('puppet:///','')).
140
+ with(options[:source].sub('puppet:///',''), :links => :manage).
141
141
  returns(fake_fileserver_metadata)
142
142
 
143
143
  # I want a resource that all the file resources require and another
@@ -92,6 +92,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
92
92
  describe "when returning the metadata" do
93
93
  before do
94
94
  @metadata = stub 'metadata', :source= => nil
95
+ @resource.stubs(:[]).with(:links).returns :manage
95
96
  end
96
97
 
97
98
  it "should return already-available metadata" do
@@ -107,22 +108,22 @@ describe Puppet::Type.type(:file).attrclass(:source) do
107
108
 
108
109
  it "should collect its metadata using the Metadata class if it is not already set" do
109
110
  @source = source.new(:resource => @resource, :value => @foobar)
110
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns @metadata
111
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri, :links => :manage).returns @metadata
111
112
  @source.metadata
112
113
  end
113
114
 
114
115
  it "should use the metadata from the first found source" do
115
116
  metadata = stub 'metadata', :source= => nil
116
117
  @source = source.new(:resource => @resource, :value => [@foobar, @feebooz])
117
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns nil
118
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz_uri).returns metadata
118
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri, :links => :manage).returns nil
119
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@feebooz_uri, :links => :manage).returns metadata
119
120
  @source.metadata.should equal(metadata)
120
121
  end
121
122
 
122
123
  it "should store the found source as the metadata's source" do
123
124
  metadata = mock 'metadata'
124
125
  @source = source.new(:resource => @resource, :value => @foobar)
125
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns metadata
126
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri, :links => :manage).returns metadata
126
127
 
127
128
  metadata.expects(:source=).with(@foobar_uri)
128
129
  @source.metadata
@@ -130,7 +131,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
130
131
 
131
132
  it "should fail intelligently if an exception is encountered while querying for metadata" do
132
133
  @source = source.new(:resource => @resource, :value => @foobar)
133
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).raises RuntimeError
134
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri, :links => :manage).raises RuntimeError
134
135
 
135
136
  @source.expects(:fail).raises ArgumentError
136
137
  lambda { @source.metadata }.should raise_error(ArgumentError)
@@ -138,7 +139,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
138
139
 
139
140
  it "should fail if no specified sources can be found" do
140
141
  @source = source.new(:resource => @resource, :value => @foobar)
141
- Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri).returns nil
142
+ Puppet::FileServing::Metadata.indirection.expects(:find).with(@foobar_uri, :links => :manage).returns nil
142
143
 
143
144
  @source.expects(:fail).raises RuntimeError
144
145
 
@@ -319,7 +320,7 @@ describe Puppet::Type.type(:file).attrclass(:source) do
319
320
  before(:each) do
320
321
  metadata = Puppet::FileServing::Metadata.new(path, :source => uri, 'type' => 'file')
321
322
  #metadata = stub('remote', :ftype => "file", :source => uri)
322
- Puppet::FileServing::Metadata.indirection.stubs(:find).with(uri).returns metadata
323
+ Puppet::FileServing::Metadata.indirection.stubs(:find).with(uri, :links => :manage).returns metadata
323
324
  resource[:source] = uri
324
325
  end
325
326
 
@@ -1121,35 +1121,6 @@ describe Puppet::Type.type(:file) do
1121
1121
  end
1122
1122
 
1123
1123
  describe "#write" do
1124
- it "should propagate failures encountered when renaming the temporary file" do
1125
- File.stubs(:open)
1126
- File.expects(:rename).raises ArgumentError
1127
-
1128
- file[:backup] = 'puppet'
1129
-
1130
- file.stubs(:validate_checksum?).returns(false)
1131
-
1132
- property = stub('content_property', :actual_content => "something", :length => "something".length)
1133
- file.stubs(:property).with(:content).returns(property)
1134
-
1135
- expect { file.write(:content) }.to raise_error(Puppet::Error)
1136
- end
1137
-
1138
- it "should delegate writing to the content property" do
1139
- filehandle = stub_everything 'fh'
1140
- File.stubs(:open).yields(filehandle)
1141
- File.stubs(:rename)
1142
- property = stub('content_property', :actual_content => "something", :length => "something".length)
1143
- file[:backup] = 'puppet'
1144
-
1145
- file.stubs(:validate_checksum?).returns(false)
1146
- file.stubs(:property).with(:content).returns(property)
1147
-
1148
- property.expects(:write).with(filehandle)
1149
-
1150
- file.write(:content)
1151
- end
1152
-
1153
1124
  describe "when validating the checksum" do
1154
1125
  before { file.stubs(:validate_checksum?).returns(true) }
1155
1126