puppet 5.5.21-x64-mingw32 → 5.5.22-x64-mingw32

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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +13 -14
  4. data/lib/puppet/configurer.rb +20 -3
  5. data/lib/puppet/configurer/downloader.rb +31 -10
  6. data/lib/puppet/defaults.rb +7 -1
  7. data/lib/puppet/file_serving/mount/locales.rb +1 -2
  8. data/lib/puppet/file_serving/mount/pluginfacts.rb +1 -2
  9. data/lib/puppet/file_serving/mount/plugins.rb +1 -2
  10. data/lib/puppet/functions/new.rb +8 -3
  11. data/lib/puppet/functions/reverse_each.rb +1 -1
  12. data/lib/puppet/functions/step.rb +1 -1
  13. data/lib/puppet/indirector/hiera.rb +4 -0
  14. data/lib/puppet/node/environment.rb +7 -1
  15. data/lib/puppet/parser/functions.rb +13 -9
  16. data/lib/puppet/pops/adaptable.rb +7 -13
  17. data/lib/puppet/pops/adapters.rb +8 -4
  18. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -3
  19. data/lib/puppet/pops/types/iterable.rb +34 -8
  20. data/lib/puppet/pops/types/p_meta_type.rb +1 -1
  21. data/lib/puppet/pops/types/p_type_set_type.rb +4 -0
  22. data/lib/puppet/pops/validation/checker4_0.rb +19 -15
  23. data/lib/puppet/provider/package/gem.rb +4 -2
  24. data/lib/puppet/provider/package/puppet_gem.rb +5 -0
  25. data/lib/puppet/provider/package/yum.rb +1 -0
  26. data/lib/puppet/resource/type.rb +2 -1
  27. data/lib/puppet/test/test_helper.rb +5 -2
  28. data/lib/puppet/util.rb +13 -12
  29. data/lib/puppet/util/autoload.rb +9 -7
  30. data/lib/puppet/version.rb +1 -1
  31. data/locales/puppet.pot +33 -29
  32. data/man/man5/puppet.conf.5 +10 -2
  33. data/man/man8/puppet-agent.8 +1 -1
  34. data/man/man8/puppet-apply.8 +1 -1
  35. data/man/man8/puppet-ca.8 +1 -1
  36. data/man/man8/puppet-catalog.8 +1 -1
  37. data/man/man8/puppet-cert.8 +1 -1
  38. data/man/man8/puppet-certificate.8 +1 -1
  39. data/man/man8/puppet-certificate_request.8 +1 -1
  40. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  41. data/man/man8/puppet-config.8 +1 -1
  42. data/man/man8/puppet-describe.8 +1 -1
  43. data/man/man8/puppet-device.8 +1 -1
  44. data/man/man8/puppet-doc.8 +1 -1
  45. data/man/man8/puppet-epp.8 +1 -1
  46. data/man/man8/puppet-facts.8 +1 -1
  47. data/man/man8/puppet-filebucket.8 +1 -1
  48. data/man/man8/puppet-generate.8 +1 -1
  49. data/man/man8/puppet-help.8 +1 -1
  50. data/man/man8/puppet-key.8 +1 -1
  51. data/man/man8/puppet-lookup.8 +1 -1
  52. data/man/man8/puppet-man.8 +1 -1
  53. data/man/man8/puppet-master.8 +1 -1
  54. data/man/man8/puppet-module.8 +1 -1
  55. data/man/man8/puppet-node.8 +1 -1
  56. data/man/man8/puppet-parser.8 +1 -1
  57. data/man/man8/puppet-plugin.8 +1 -1
  58. data/man/man8/puppet-report.8 +1 -1
  59. data/man/man8/puppet-resource.8 +1 -1
  60. data/man/man8/puppet-script.8 +1 -1
  61. data/man/man8/puppet-status.8 +1 -1
  62. data/man/man8/puppet.8 +2 -2
  63. data/spec/integration/configurer_spec.rb +14 -0
  64. data/spec/integration/data_binding_spec.rb +1 -0
  65. data/spec/integration/faces/plugin_spec.rb +29 -47
  66. data/spec/shared_contexts/types_setup.rb +2 -0
  67. data/spec/unit/configurer/downloader_spec.rb +10 -0
  68. data/spec/unit/configurer_spec.rb +65 -30
  69. data/spec/unit/file_serving/mount/locales_spec.rb +2 -2
  70. data/spec/unit/file_serving/mount/pluginfacts_spec.rb +2 -2
  71. data/spec/unit/file_serving/mount/plugins_spec.rb +2 -2
  72. data/spec/unit/provider/package/puppet_gem_spec.rb +4 -1
  73. data/spec/unit/provider/package/yum_spec.rb +31 -0
  74. data/spec/unit/ssl/host_spec.rb +2 -0
  75. metadata +2 -2
@@ -187,6 +187,8 @@ shared_context 'types_setup' do
187
187
  result << Puppet::Pops::Types::PURIType
188
188
  result << Puppet::Pops::Types::PTupleType.new([tf.rich_data])
189
189
  result << Puppet::Pops::Types::PObjectType
190
+ result << Puppet::Pops::Types::PTypeType
191
+ result << Puppet::Pops::Types::PTypeSetType
190
192
  result
191
193
  end
192
194
  def rich_data_compatible_types
@@ -228,5 +228,15 @@ describe Puppet::Configurer::Downloader do
228
228
 
229
229
  expect { @dler.evaluate }.not_to raise_error
230
230
  end
231
+
232
+ it "raises an exception if catalog application fails" do
233
+ Puppet[:ignore_plugin_errors] = false
234
+
235
+ expect(@dler.file).to receive(:retrieve).and_raise(Puppet::Error, "testing")
236
+
237
+ expect {
238
+ @dler.evaluate
239
+ }.to raise_error(Puppet::Error, /testing/)
240
+ end
231
241
  end
232
242
  end
@@ -86,6 +86,44 @@ describe Puppet::Configurer do
86
86
  expect(configurer.run).to eq(0)
87
87
  end
88
88
 
89
+ it "fails the run if pluginsync fails when usecacheonfailure is false" do
90
+ Puppet[:ignore_plugin_errors] = false
91
+
92
+ # --test implies these, set them so we don't fall back to a cached catalog
93
+ Puppet[:use_cached_catalog] = false
94
+ Puppet[:usecacheonfailure] = false
95
+
96
+ body = "{\"message\":\"Not Found: Could not find environment 'fasdfad'\",\"issue_kind\":\"RUNTIME_ERROR\"}"
97
+ stub_request(:get, %r{/puppet/v3/file_metadatas/pluginfacts}).to_return(
98
+ status: 404, body: body, headers: {'Content-Type' => 'application/json'}
99
+ )
100
+ stub_request(:get, %r{/puppet/v3/file_metadata/pluginfacts}).to_return(
101
+ status: 404, body: body, headers: {'Content-Type' => 'application/json'}
102
+ )
103
+
104
+ configurer.run(pluginsync: true)
105
+
106
+ expect(@logs).to include(an_object_having_attributes(level: :err, message: %r{Failed to apply catalog: Failed to retrieve pluginfacts: Could not retrieve information from environment production source\(s\) puppet:///pluginfacts}))
107
+ end
108
+
109
+ it "applies a cached catalog if pluginsync fails when usecacheonfailure is true" do
110
+ Puppet[:ignore_plugin_errors] = false
111
+
112
+ Puppet[:use_cached_catalog] = false
113
+ Puppet[:usecacheonfailure] = true
114
+
115
+ body = "{\"message\":\"Not Found: Could not find environment 'fasdfad'\",\"issue_kind\":\"RUNTIME_ERROR\"}"
116
+ stub_request(:get, %r{/puppet/v3/file_metadatas/pluginfacts}).to_return(
117
+ status: 404, body: body, headers: {'Content-Type' => 'application/json'}
118
+ )
119
+ stub_request(:get, %r{/puppet/v3/file_metadata/pluginfacts}).to_return(
120
+ status: 404, body: body, headers: {'Content-Type' => 'application/json'}
121
+ )
122
+
123
+ expect(configurer.run(pluginsync: true, :report => report)).to eq(0)
124
+ expect(report.cached_catalog_status).to eq('on_failure')
125
+ end
126
+
89
127
  it "applies a cached catalog when it can't connect to the master" do
90
128
  error = Errno::ECONNREFUSED.new('Connection refused - connect(2)')
91
129
 
@@ -97,7 +135,8 @@ describe Puppet::Configurer do
97
135
  end
98
136
 
99
137
  it "should initialize a transaction report if one is not provided" do
100
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
138
+ # host and settings catalogs each create a report...
139
+ expect(Puppet::Transaction::Report).to receive(:new).and_return(report).twice
101
140
 
102
141
  configurer.run
103
142
  end
@@ -192,22 +231,21 @@ describe Puppet::Configurer do
192
231
  end
193
232
 
194
233
  it "should remove the report as a log destination when the run is finished" do
195
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
196
-
197
- configurer.run
234
+ configurer.run(report: report)
198
235
 
199
236
  expect(Puppet::Util::Log.destinations).not_to include(report)
200
237
  end
201
238
 
202
- it "should return the report exit_status as the result of the run" do
203
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
204
- expect(report).to receive(:exit_status).and_return(1234)
239
+ it "should return an exit status of 2 due to the notify resource 'changing'" do
240
+ cat = Puppet::Resource::Catalog.new("tester", Puppet::Node::Environment.remote(Puppet[:environment].to_sym))
241
+ cat.add_resource(Puppet::Type.type(:notify).new(:name => 'something changed'))
205
242
 
206
- expect(configurer.run).to eq(1234)
243
+ expect(configurer.run(catalog: cat, report: report)).to eq(2)
207
244
  end
208
245
 
209
246
  it "should return nil if catalog application fails" do
210
- expect_any_instance_of(Puppet::Resource::Catalog).to receive(:apply).and_raise(Puppet::Error, 'One or more resource dependency cycles detected in graph')
247
+ expect(catalog).to receive(:apply).and_raise(Puppet::Error, 'One or more resource dependency cycles detected in graph')
248
+
211
249
  expect(configurer.run(catalog: catalog, report: report)).to be_nil
212
250
  end
213
251
 
@@ -222,34 +260,28 @@ describe Puppet::Configurer do
222
260
  end
223
261
 
224
262
  it "should include the pre-run command failure in the report" do
225
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
226
-
227
263
  Puppet.settings[:prerun_command] = "/my/command"
228
264
  expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
229
265
 
230
- expect(configurer.run).to be_nil
266
+ expect(configurer.run(report: report)).to be_nil
231
267
  expect(report.logs.find { |x| x.message =~ /Could not run command from prerun_command/ }).to be
232
268
  end
233
269
 
234
270
  it "should send the transaction report even if the post-run command fails" do
235
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
236
-
237
271
  Puppet.settings[:postrun_command] = "/my/command"
238
272
  expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
239
273
  expect(configurer).to receive(:send_report).with(report)
240
274
 
241
- expect(configurer.run).to be_nil
275
+ expect(configurer.run(report: report)).to be_nil
242
276
  end
243
277
 
244
278
  it "should include the post-run command failure in the report" do
245
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
246
-
247
279
  Puppet.settings[:postrun_command] = "/my/command"
248
280
  expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
249
281
 
250
282
  expect(report).to receive(:<<) { |log, _| expect(log.message).to match(/Could not run command from postrun_command/) }.at_least(:once)
251
283
 
252
- expect(configurer.run).to be_nil
284
+ expect(configurer.run(report: report)).to be_nil
253
285
  end
254
286
 
255
287
  it "should execute post-run command even if the pre-run command fails" do
@@ -262,34 +294,28 @@ describe Puppet::Configurer do
262
294
  end
263
295
 
264
296
  it "should finalize the report" do
265
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
266
-
267
297
  expect(report).to receive(:finalize_report)
268
- configurer.run
298
+ configurer.run(report: report)
269
299
  end
270
300
 
271
301
  it "should not apply the catalog if the pre-run command fails" do
272
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
273
-
274
302
  Puppet.settings[:prerun_command] = "/my/command"
275
303
  expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
276
304
 
277
305
  expect_any_instance_of(Puppet::Resource::Catalog).not_to receive(:apply)
278
306
  expect(configurer).to receive(:send_report)
279
307
 
280
- expect(configurer.run).to be_nil
308
+ expect(configurer.run(report: report)).to be_nil
281
309
  end
282
310
 
283
311
  it "should apply the catalog, send the report, and return nil if the post-run command fails" do
284
- expect(Puppet::Transaction::Report).to receive(:new).and_return(report)
285
-
286
312
  Puppet.settings[:postrun_command] = "/my/command"
287
313
  expect(Puppet::Util::Execution).to receive(:execute).with(["/my/command"]).and_raise(Puppet::ExecutionFailure, "Failed")
288
314
 
289
315
  expect_any_instance_of(Puppet::Resource::Catalog).to receive(:apply)
290
316
  expect(configurer).to receive(:send_report)
291
317
 
292
- expect(configurer.run).to be_nil
318
+ expect(configurer.run(report: report)).to be_nil
293
319
  end
294
320
 
295
321
  it 'includes total time metrics in the report after successfully applying the catalog' do
@@ -542,6 +568,15 @@ describe Puppet::Configurer do
542
568
  end
543
569
  end
544
570
 
571
+ def expects_pluginsync
572
+ metadata = "[{\"path\":\"/etc/puppetlabs/code\",\"relative_path\":\".\",\"links\":\"follow\",\"owner\":0,\"group\":0,\"mode\":420,\"checksum\":{\"type\":\"ctime\",\"value\":\"{ctime}2020-07-10 14:00:00 -0700\"},\"type\":\"directory\",\"destination\":null}]"
573
+ stub_request(:get, %r{/puppet/v3/file_metadatas/(plugins|locales)}).to_return(status: 200, body: metadata, headers: {'Content-Type' => 'application/json'})
574
+
575
+ # response retains owner/group/mode due to source_permissions => use
576
+ facts_metadata = "[{\"path\":\"/etc/puppetlabs/code\",\"relative_path\":\".\",\"links\":\"follow\",\"owner\":500,\"group\":500,\"mode\":493,\"checksum\":{\"type\":\"ctime\",\"value\":\"{ctime}2020-07-10 14:00:00 -0700\"},\"type\":\"directory\",\"destination\":null}]"
577
+ stub_request(:get, %r{/puppet/v3/file_metadatas/pluginfacts}).to_return(status: 200, body: facts_metadata, headers: {'Content-Type' => 'application/json'})
578
+ end
579
+
545
580
  def expects_new_catalog_only(catalog)
546
581
  expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(catalog)
547
582
  expect(Puppet::Resource::Catalog.indirection).not_to receive(:find).with(anything, hash_including(ignore_terminus: true))
@@ -558,6 +593,7 @@ describe Puppet::Configurer do
558
593
  end
559
594
 
560
595
  def expects_fallback_to_new_catalog(catalog)
596
+ expects_pluginsync
561
597
  expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_terminus: true)).and_return(nil)
562
598
  expect(Puppet::Resource::Catalog.indirection).to receive(:find).with(anything, hash_including(ignore_cache: true)).and_return(catalog)
563
599
  end
@@ -594,7 +630,6 @@ describe Puppet::Configurer do
594
630
  it "should make a node request and pluginsync when a cached catalog cannot be retrieved" do
595
631
  expect(Puppet::Node.indirection).to receive(:find).and_return(nil)
596
632
  expects_fallback_to_new_catalog(catalog)
597
- expect(configurer).to receive(:download_plugins)
598
633
 
599
634
  configurer.run
600
635
  end
@@ -630,6 +665,7 @@ describe Puppet::Configurer do
630
665
  it "should not attempt to retrieve a cached catalog again if the first attempt failed" do
631
666
  expect(Puppet::Node.indirection).to receive(:find).and_return(nil)
632
667
  expects_neither_new_or_cached_catalog
668
+ expects_pluginsync
633
669
 
634
670
  configurer.run
635
671
  end
@@ -645,8 +681,7 @@ describe Puppet::Configurer do
645
681
  end
646
682
 
647
683
  it "applies the catalog passed as options when the catalog cache terminus is not set" do
648
- stub_request(:get, %r{/puppet/v3/file_metadatas?/plugins}).to_return(:status => 404)
649
- stub_request(:get, %r{/puppet/v3/file_metadatas?/pluginfacts}).to_return(:status => 404)
684
+ expects_pluginsync
650
685
 
651
686
  catalog.add_resource(Puppet::Resource.new('notify', 'from apply'))
652
687
  configurer.run(catalog: catalog.to_ral)
@@ -52,13 +52,13 @@ describe Puppet::FileServing::Mount::Locales do
52
52
  expect(@mount.search("foo/bar", @request)).to eq(["/"])
53
53
  end
54
54
 
55
- it "should return nil if no modules can be found that have locales and modulepath is invalid" do
55
+ it "should return the default search module path if no modules can be found that have locales and modulepath is invalid" do
56
56
  mod = double('module')
57
57
  allow(mod).to receive(:locales?).and_return(false)
58
58
 
59
59
  allow(@environment).to receive(:modules).and_return([])
60
60
  allow(@environment).to receive(:modulepath).and_return([])
61
- expect(@mount.search("foo/bar", @request)).to be_nil
61
+ expect(@mount.search("foo/bar", @request)).to eq([Puppet[:codedir]])
62
62
  end
63
63
 
64
64
  it "should return the locale paths for each module that has locales" do
@@ -52,13 +52,13 @@ describe Puppet::FileServing::Mount::PluginFacts do
52
52
  expect(@mount.search("foo/bar", @request)).to eq(["/"])
53
53
  end
54
54
 
55
- it "should return nil if no modules can be found that have plugins and modulepath is invalid" do
55
+ it "should return the default search module path if no modules can be found that have plugins and modulepath is invalid" do
56
56
  mod = double('module')
57
57
  allow(mod).to receive(:pluginfacts?).and_return(false)
58
58
 
59
59
  allow(@environment).to receive(:modules).and_return([])
60
60
  allow(@environment).to receive(:modulepath).and_return([])
61
- expect(@mount.search("foo/bar", @request)).to be_nil
61
+ expect(@mount.search("foo/bar", @request)).to eq([Puppet[:codedir]])
62
62
  end
63
63
 
64
64
  it "should return the plugin paths for each module that has plugins" do
@@ -52,13 +52,13 @@ describe Puppet::FileServing::Mount::Plugins do
52
52
  expect(@mount.search("foo/bar", @request)).to eq(["/"])
53
53
  end
54
54
 
55
- it "should return nil if no modules can be found that have plugins and modulepath is invalid" do
55
+ it "should return the default search module path if no modules can be found that have plugins and modulepath is invalid" do
56
56
  mod = double('module')
57
57
  allow(mod).to receive(:plugins?).and_return(false)
58
58
 
59
59
  allow(@environment).to receive(:modules).and_return([])
60
60
  allow(@environment).to receive(:modulepath).and_return([])
61
- expect(@mount.search("foo/bar", @request)).to be_nil
61
+ expect(@mount.search("foo/bar", @request)).to eq([Puppet[:codedir]])
62
62
  end
63
63
 
64
64
  it "should return the plugin paths for each module that has plugins" do
@@ -20,7 +20,10 @@ describe Puppet::Type.type(:package).provider(:puppet_gem) do
20
20
  let(:provider_gem_cmd) { '/opt/puppetlabs/puppet/bin/gem' }
21
21
  end
22
22
 
23
- let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => {"HOME"=>ENV["HOME"]}} }
23
+ custom_environment = {"HOME"=>ENV["HOME"]}
24
+ custom_environment['PKG_CONFIG_PATH'] = '/opt/puppetlabs/puppet/lib/pkgconfig' unless Puppet::Util::Platform.windows?
25
+
26
+ let(:execute_options) { {:failonfail => true, :combine => true, :custom_environment => custom_environment} }
24
27
 
25
28
  before :each do
26
29
  resource.provider = provider
@@ -106,6 +106,37 @@ describe Puppet::Type.type(:package).provider(:yum) do
106
106
  end
107
107
  end
108
108
 
109
+ context "latest" do
110
+ let(:name) { 'baz' }
111
+
112
+ let(:resource) do
113
+ Puppet::Type.type(:package).new(
114
+ :name => name,
115
+ :provider => 'yum',
116
+ )
117
+ end
118
+
119
+ let(:provider) do
120
+ provider = described_class.new
121
+ provider.resource = resource
122
+ provider
123
+ end
124
+
125
+ before {
126
+ allow(described_class).to receive(:command).with(:cmd).and_return("/usr/bin/yum")
127
+ Puppet[:log_level] = 'debug'
128
+ }
129
+
130
+ it "should print a debug message with the current version if newer package is not available" do
131
+ expect(provider).to receive(:query).and_return({:ensure => "1.2.3"})
132
+ expect(described_class).to receive(:latest_package_version).and_return(nil)
133
+ resource[:ensure] = :present
134
+
135
+ provider.latest
136
+ expect(@logs).to include(an_object_having_attributes(level: :debug, message: "Yum didn't find updates, current version (1.2.3) is the latest"))
137
+ end
138
+ end
139
+
109
140
  context "parsing the output of check-update" do
110
141
  context "with no multiline entries" do
111
142
  let(:check_update) { File.read(my_fixture("yum-check-update-simple.txt")) }
@@ -158,6 +158,7 @@ describe Puppet::SSL::Host do
158
158
 
159
159
  it "should not include defaults if we can't resolve our fqdn" do
160
160
  allow(Puppet::SSL::CertificateAuthority).to receive(:ca?).and_return(true)
161
+ allow(Facter).to receive(:value).and_call_original
161
162
  allow(Facter).to receive(:value).with(:fqdn).and_return(nil)
162
163
 
163
164
  expect(@cr).to receive(:generate).with(@key, {})
@@ -167,6 +168,7 @@ describe Puppet::SSL::Host do
167
168
 
168
169
  it "should provide defaults if we're bootstrapping the local master" do
169
170
  allow(Puppet::SSL::CertificateAuthority).to receive(:ca?).and_return(true)
171
+ allow(Facter).to receive(:value).and_call_original
170
172
  allow(Facter).to receive(:value).with(:fqdn).and_return('web.foo.com')
171
173
  allow(Facter).to receive(:value).with(:domain).and_return('foo.com')
172
174
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.21
4
+ version: 5.5.22
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter