puppet 6.25.1-x64-mingw32 → 6.26.0-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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +24 -17
  4. data/lib/puppet/application/lookup.rb +78 -24
  5. data/lib/puppet/concurrent/thread_local_singleton.rb +5 -3
  6. data/lib/puppet/configurer.rb +2 -12
  7. data/lib/puppet/defaults.rb +14 -3
  8. data/lib/puppet/face/generate.rb +2 -0
  9. data/lib/puppet/file_serving/metadata.rb +3 -0
  10. data/lib/puppet/file_system/file_impl.rb +7 -7
  11. data/lib/puppet/file_system/jruby.rb +1 -1
  12. data/lib/puppet/file_system/windows.rb +4 -4
  13. data/lib/puppet/file_system.rb +1 -1
  14. data/lib/puppet/functions/versioncmp.rb +6 -2
  15. data/lib/puppet/generate/type.rb +9 -0
  16. data/lib/puppet/node.rb +1 -1
  17. data/lib/puppet/pops/parser/code_merger.rb +4 -4
  18. data/lib/puppet/pops/parser/egrammar.ra +2 -0
  19. data/lib/puppet/pops/parser/eparser.rb +813 -794
  20. data/lib/puppet/pops/serialization/to_data_converter.rb +6 -18
  21. data/lib/puppet/provider/service/init.rb +5 -4
  22. data/lib/puppet/ssl/verifier.rb +6 -0
  23. data/lib/puppet/transaction/persistence.rb +22 -12
  24. data/lib/puppet/type/file/data_sync.rb +1 -1
  25. data/lib/puppet/type/user.rb +40 -38
  26. data/lib/puppet/util/json.rb +17 -0
  27. data/lib/puppet/util/log.rb +7 -2
  28. data/lib/puppet/util/monkey_patches.rb +6 -0
  29. data/lib/puppet/util/package.rb +25 -16
  30. data/lib/puppet/util/yaml.rb +21 -2
  31. data/lib/puppet/version.rb +1 -1
  32. data/lib/puppet.rb +1 -0
  33. data/locales/puppet.pot +5 -10454
  34. data/man/man5/puppet.conf.5 +21 -2
  35. data/man/man8/puppet-agent.8 +1 -1
  36. data/man/man8/puppet-apply.8 +1 -1
  37. data/man/man8/puppet-catalog.8 +1 -1
  38. data/man/man8/puppet-config.8 +1 -1
  39. data/man/man8/puppet-describe.8 +1 -1
  40. data/man/man8/puppet-device.8 +1 -1
  41. data/man/man8/puppet-doc.8 +1 -1
  42. data/man/man8/puppet-epp.8 +1 -1
  43. data/man/man8/puppet-facts.8 +1 -1
  44. data/man/man8/puppet-filebucket.8 +1 -1
  45. data/man/man8/puppet-generate.8 +1 -1
  46. data/man/man8/puppet-help.8 +1 -1
  47. data/man/man8/puppet-key.8 +1 -1
  48. data/man/man8/puppet-lookup.8 +9 -6
  49. data/man/man8/puppet-man.8 +1 -1
  50. data/man/man8/puppet-module.8 +1 -1
  51. data/man/man8/puppet-node.8 +1 -1
  52. data/man/man8/puppet-parser.8 +1 -1
  53. data/man/man8/puppet-plugin.8 +1 -1
  54. data/man/man8/puppet-report.8 +1 -1
  55. data/man/man8/puppet-resource.8 +1 -1
  56. data/man/man8/puppet-script.8 +1 -1
  57. data/man/man8/puppet-ssl.8 +1 -1
  58. data/man/man8/puppet-status.8 +1 -1
  59. data/man/man8/puppet.8 +2 -2
  60. data/spec/fixtures/unit/forge/bacula.json +1 -1
  61. data/spec/integration/application/lookup_spec.rb +32 -6
  62. data/spec/shared_contexts/l10n.rb +5 -0
  63. data/spec/unit/application/lookup_spec.rb +131 -10
  64. data/spec/unit/concurrent/thread_local_singleton_spec.rb +39 -0
  65. data/spec/unit/configurer_spec.rb +90 -58
  66. data/spec/unit/face/generate_spec.rb +64 -0
  67. data/spec/unit/file_system_spec.rb +34 -4
  68. data/spec/unit/forge/module_release_spec.rb +3 -3
  69. data/spec/unit/functions/versioncmp_spec.rb +40 -4
  70. data/spec/unit/node_spec.rb +6 -0
  71. data/spec/unit/pops/parser/parse_containers_spec.rb +2 -2
  72. data/spec/unit/pops/serialization/to_from_hr_spec.rb +0 -58
  73. data/spec/unit/pops/validator/validator_spec.rb +5 -0
  74. data/spec/unit/provider/service/gentoo_spec.rb +6 -5
  75. data/spec/unit/provider/service/init_spec.rb +15 -9
  76. data/spec/unit/provider/service/openwrt_spec.rb +21 -29
  77. data/spec/unit/provider/service/redhat_spec.rb +3 -2
  78. data/spec/unit/transaction/persistence_spec.rb +51 -0
  79. data/spec/unit/type/user_spec.rb +0 -45
  80. data/spec/unit/util/json_spec.rb +126 -0
  81. data/spec/unit/util/yaml_spec.rb +54 -29
  82. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 463e52e38eca39df09657d8d3a4ad1812c056b1e38733bc7d1fb4ff0a6d02376
4
- data.tar.gz: a493e7263abdfea352b4d50594048afb3b1b71dc3f5b50a561069ddcab2fc74a
3
+ metadata.gz: 5d5c7006fa02f3f45a2c0aada3f63623468858eeccda70db5ca0b0d08cc3c504
4
+ data.tar.gz: 71ab615ddcd0d04438079947ed0c69f49609c103c6e0c4768c0ce8f61588aab8
5
5
  SHA512:
6
- metadata.gz: af8011cfba30d0bfaff151aa366c677d1641bc0909f18f7ec570de1cb6eb075c9f76b3b027cb109bafb29a617e1a4704c083de2d5e1c7284f10d4bd010735c89
7
- data.tar.gz: b7490c75f35a1995c5b6cf8f547c3df219800f5dc72f98bdf49634e7535c98c2b804fd9c86671bf67b4ce197151c7f619ece2a2bc6b996fb5755f05af142f26c
6
+ metadata.gz: 3d6720cc5962bbc50129b510b7cbd4adbea2121cbbd42f062cde15a418c3cd74f81537bd8fdfa6f222b14ac5af5aefdc0dd18b4bfd15ab3db6ffb770abe15e5e
7
+ data.tar.gz: 99dcb372be188fece45cd50f3fe456991a6aacd789a52cf177fa648cf6af0fe4557a8add75a7718a57d8bf712f4200dc6f457b31ab386ecb7bae8ada404309cb
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  def location_for(place, fake_version = nil)
6
- if place.is_a?(String) && place =~ /^(git[:@][^#]*)#(.*)/
6
+ if place.is_a?(String) && place =~ /^((?:git[:@]|https:)[^#]*)#(.*)/
7
7
  [fake_version, { git: $1, branch: $2, require: false }].compact
8
8
  elsif place.is_a?(String) && place =~ /^file:\/\/(.*)/
9
9
  ['>= 0', { path: File.expand_path($1), require: false }]
@@ -29,7 +29,7 @@ group(:features) do
29
29
  #gem 'ruby-shadow', '~> 2.5', require: false, platforms: [:ruby]
30
30
  gem 'minitar', '~> 0.9', require: false
31
31
  gem 'msgpack', '~> 1.2', require: false
32
- gem 'rdoc', '~> 6.0', require: false, platforms: [:ruby]
32
+ gem 'rdoc', ['~> 6.0', '< 6.4.0'], require: false, platforms: [:ruby]
33
33
  # requires native augeas headers/libs
34
34
  # gem 'ruby-augeas', require: false, platforms: [:ruby]
35
35
  # requires native ldap headers/libs
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  GIT
2
- remote: git://github.com/puppetlabs/packaging
3
- revision: 4c5359786cad0d12877e10e98948065bfeb3e304
2
+ remote: https://github.com/puppetlabs/packaging
3
+ revision: 9d36e41d10ce14c66d9c3c35157788e63c1afef8
4
4
  branch: 1.0.x
5
5
  specs:
6
- packaging (0.103.0)
6
+ packaging (0.105.0)
7
+ apt_stage_artifacts
7
8
  artifactory (~> 2)
8
9
  csv (= 3.1.5)
9
10
  rake (>= 12.3)
@@ -12,7 +13,7 @@ GIT
12
13
  PATH
13
14
  remote: .
14
15
  specs:
15
- puppet (6.25.1)
16
+ puppet (6.26.0)
16
17
  CFPropertyList (~> 2.2)
17
18
  concurrent-ruby (~> 1.0)
18
19
  deep_merge (~> 1.0)
@@ -30,6 +31,8 @@ GEM
30
31
  CFPropertyList (2.3.6)
31
32
  addressable (2.8.0)
32
33
  public_suffix (>= 2.0.2, < 5.0)
34
+ apt_stage_artifacts (0.10.1)
35
+ docopt
33
36
  artifactory (2.8.2)
34
37
  ast (2.4.2)
35
38
  coderay (1.1.3)
@@ -37,14 +40,14 @@ GEM
37
40
  crack (0.4.5)
38
41
  rexml
39
42
  csv (3.1.5)
40
- deep_merge (1.2.1)
41
- diff-lcs (1.4.4)
43
+ deep_merge (1.2.2)
44
+ diff-lcs (1.5.0)
42
45
  docopt (0.6.1)
43
- facter (4.2.5)
46
+ facter (4.2.7)
44
47
  hocon (~> 1.3)
45
48
  thor (>= 1.0.1, < 2.0)
46
49
  fast_gettext (1.1.2)
47
- ffi (1.15.4)
50
+ ffi (1.15.5)
48
51
  gettext (3.2.9)
49
52
  locale (>= 2.0.5)
50
53
  text (>= 1.3.0)
@@ -53,7 +56,7 @@ GEM
53
56
  gettext (>= 3.0.2, < 3.3.0)
54
57
  locale
55
58
  hashdiff (1.0.1)
56
- hiera (3.7.0)
59
+ hiera (3.8.0)
57
60
  hiera-eyaml (3.2.2)
58
61
  highline
59
62
  optimist
@@ -88,7 +91,7 @@ GEM
88
91
  rake
89
92
  rake (12.3.3)
90
93
  rdiscount (2.2.0.2)
91
- rdoc (6.3.2)
94
+ rdoc (6.3.3)
92
95
  release-metrics (1.1.0)
93
96
  csv
94
97
  docopt
@@ -103,7 +106,7 @@ GEM
103
106
  rspec-mocks (~> 3.10.0)
104
107
  rspec-core (3.10.1)
105
108
  rspec-support (~> 3.10.0)
106
- rspec-expectations (3.10.1)
109
+ rspec-expectations (3.10.2)
107
110
  diff-lcs (>= 1.2.0, < 2.0)
108
111
  rspec-support (~> 3.10.0)
109
112
  rspec-its (1.3.0)
@@ -112,7 +115,7 @@ GEM
112
115
  rspec-mocks (3.10.2)
113
116
  diff-lcs (>= 1.2.0, < 2.0)
114
117
  rspec-support (~> 3.10.0)
115
- rspec-support (3.10.2)
118
+ rspec-support (3.10.3)
116
119
  rubocop (0.49.1)
117
120
  parallel (~> 1.10)
118
121
  parser (>= 2.3.3.1, < 3.0)
@@ -124,19 +127,22 @@ GEM
124
127
  rubocop (~> 0.49.0)
125
128
  ruby-prof (1.4.3)
126
129
  ruby-progressbar (1.11.0)
130
+ scanf (1.0.0)
127
131
  semantic_puppet (1.0.4)
128
132
  text (1.3.1)
129
- thor (1.1.0)
133
+ thor (1.2.1)
130
134
  unicode-display_width (1.8.0)
131
135
  vcr (5.1.0)
132
136
  webmock (3.14.0)
133
137
  addressable (>= 2.8.0)
134
138
  crack (>= 0.3.2)
135
139
  hashdiff (>= 0.4.0, < 2.0.0)
136
- yard (0.9.26)
140
+ webrick (1.7.0)
141
+ yard (0.9.27)
142
+ webrick (~> 1.7.0)
137
143
 
138
144
  PLATFORMS
139
- ruby
145
+ x86_64-linux
140
146
 
141
147
  DEPENDENCIES
142
148
  diff-lcs (~> 1.3)
@@ -155,7 +161,7 @@ DEPENDENCIES
155
161
  puppetserver-ca (~> 1.1)
156
162
  racc (= 1.5.2)
157
163
  rake (~> 12.2)
158
- rdoc (~> 6.0)
164
+ rdoc (~> 6.0, < 6.4.0)
159
165
  ronn (~> 0.7.3)
160
166
  rspec (~> 3.1)
161
167
  rspec-expectations (~> 3.9, != 3.9.3)
@@ -163,10 +169,11 @@ DEPENDENCIES
163
169
  rubocop (~> 0.49)
164
170
  rubocop-i18n (~> 1.2.0)
165
171
  ruby-prof (>= 0.16.0)
172
+ scanf
166
173
  semantic_puppet (~> 1.0)
167
174
  vcr (~> 5.0)
168
175
  webmock (~> 3.0)
169
176
  yard
170
177
 
171
178
  BUNDLED WITH
172
- 1.17.3
179
+ 2.2.6
@@ -7,6 +7,7 @@ class Puppet::Application::Lookup < Puppet::Application
7
7
 
8
8
  RUN_HELP = _("Run 'puppet lookup --help' for more details").freeze
9
9
  DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays'.freeze
10
+ TRUSTED_INFORMATION_FACTS = ["hostname", "domain", "fqdn", "clientcert"].freeze
10
11
 
11
12
  run_mode :server
12
13
 
@@ -54,11 +55,7 @@ class Puppet::Application::Lookup < Puppet::Application
54
55
  end
55
56
 
56
57
  option('--facts FACT_FILE') do |arg|
57
- if %w{.yaml .yml .json}.include?(arg.match(/\.[^.]*$/)[0])
58
- options[:fact_file] = arg
59
- else
60
- raise _("The --fact file only accepts yaml and json files.\n%{run_help}") % { run_help: RUN_HELP }
61
- end
58
+ options[:fact_file] = arg
62
59
  end
63
60
 
64
61
  def app_defaults
@@ -137,7 +134,9 @@ DESCRIPTION
137
134
  The lookup command is a CLI for Puppet's 'lookup()' function. It searches your
138
135
  Hiera data and returns a value for the requested lookup key, so you can test and
139
136
  explore your data. It is a modern replacement for the 'hiera' command.
140
-
137
+ Lookup uses the setting for global hiera.yaml from puppet's config,
138
+ and the environment to find the environment level hiera.yaml as well as the
139
+ resulting modulepath for the environment (for hiera.yaml files in modules).
141
140
  Hiera usually relies on a node's facts to locate the relevant data sources. By
142
141
  default, 'puppet lookup' uses facts from the node you run the command on, but
143
142
  you can get data for any other node with the '--node <NAME>' option. If
@@ -186,7 +185,8 @@ OPTIONS
186
185
  * --environment <ENV>
187
186
  Like with most Puppet commands, you can specify an environment on the command
188
187
  line. This is important for lookup because different environments can have
189
- different Hiera data.
188
+ different Hiera data. This environment will be always be the one used regardless
189
+ of any other factors.
190
190
 
191
191
  * --merge first|unique|hash|deep:
192
192
  Specify the merge behavior, overriding any merge behavior from the data's
@@ -237,6 +237,13 @@ EXAMPLE
237
237
  To look up 'key_name' using the Puppet Server node's facts:
238
238
  $ puppet lookup key_name
239
239
 
240
+ To look up 'key_name' using the Puppet Server node's arbitrary variables from a manifest, and
241
+ classify the node if applicable:
242
+ $ puppet lookup key_name --compile
243
+
244
+ To look up 'key_name' using the Puppet Server node's facts, overridden by facts given in a file:
245
+ $ puppet lookup key_name --facts fact_file.yaml
246
+
240
247
  To look up 'key_name' with agent.local's facts:
241
248
  $ puppet lookup --node agent.local key_name
242
249
 
@@ -341,31 +348,66 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
341
348
  Puppet.settings[:facts_terminus] = 'facter'
342
349
  end
343
350
 
344
- unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
345
- ni = Puppet::Node.indirection
346
- tc = ni.terminus_class
347
- if tc == :plain || options[:compile]
348
- node = ni.find(node)
349
- else
350
- ni.terminus_class = :plain
351
- node = ni.find(node)
352
- ni.terminus_class = tc
353
- end
354
- end
355
-
356
351
  fact_file = options[:fact_file]
357
352
 
358
353
  if fact_file
359
- if fact_file.end_with?("json")
360
- given_facts = Puppet::Util::Json.load(Puppet::FileSystem.read(fact_file, :encoding => 'utf-8'))
361
- else
354
+ if fact_file.end_with?('.json')
355
+ given_facts = Puppet::Util::Json.load_file(fact_file)
356
+ elsif fact_file.end_with?('.yml', '.yaml')
362
357
  given_facts = Puppet::Util::Yaml.safe_load_file(fact_file)
358
+ else
359
+ given_facts = Puppet::Util::Json.load_file_if_valid(fact_file)
360
+ given_facts = Puppet::Util::Yaml.safe_load_file_if_valid(fact_file) unless given_facts
363
361
  end
364
362
 
365
363
  unless given_facts.instance_of?(Hash)
366
- raise _("Incorrect formatted data in %{fact_file} given via the --facts flag") % { fact_file: fact_file }
364
+ raise _("Incorrectly formatted data in %{fact_file} given via the --facts flag (only accepts yaml and json files)") % { fact_file: fact_file }
365
+ end
366
+
367
+ if TRUSTED_INFORMATION_FACTS.any? { |key| given_facts.key? key }
368
+ unless TRUSTED_INFORMATION_FACTS.all? { |key| given_facts.key? key }
369
+ raise _("When overriding any of the %{trusted_facts_list} facts with %{fact_file} "\
370
+ "given via the --facts flag, they must all be overridden.") % { fact_file: fact_file ,trusted_facts_list: TRUSTED_INFORMATION_FACTS.join(',')}
371
+ end
367
372
  end
368
- node.add_extra_facts(given_facts)
373
+ end
374
+
375
+ unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
376
+ facts = retrieve_node_facts(node, given_facts)
377
+ if Puppet.settings.set_by_cli?('environment')
378
+ node = Puppet::Node.new(node, :classes => nil, :parameters => nil, :facts => facts, :environment => Puppet.settings.value('environment'))
379
+ else
380
+ ni = Puppet::Node.indirection
381
+ tc = ni.terminus_class
382
+ if options[:compile]
383
+ if tc == :plain
384
+ node = ni.find(node, facts: facts)
385
+ else
386
+ begin
387
+ service = Puppet.runtime[:http]
388
+ session = service.create_session
389
+ cert = session.route_to(:ca)
390
+
391
+ _, x509 = cert.get_certificate(node)
392
+ cert = OpenSSL::X509::Certificate.new(x509)
393
+ Puppet::SSL::Oids.register_puppet_oids
394
+ trusted = Puppet::Context::TrustedInformation.remote(true, facts.values['certname'] || node, Puppet::SSL::Certificate.from_instance(cert))
395
+ Puppet.override(trusted_information: trusted) do
396
+ node = ni.find(node, facts: facts)
397
+ end
398
+ rescue
399
+ Puppet.warning _("CA is not available, the operation will continue without using trusted facts.")
400
+ node = ni.find(node, facts: facts)
401
+ end
402
+ end
403
+ else
404
+ ni.terminus_class = :plain
405
+ node = ni.find(node, facts: facts)
406
+ ni.terminus_class = tc
407
+ end
408
+ end
409
+ else
410
+ node.add_extra_facts(given_facts) if given_facts
369
411
  end
370
412
 
371
413
  Puppet[:code] = 'undef' unless options[:compile]
@@ -378,4 +420,16 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
378
420
  compiler.compile { |catalog| yield(compiler.topscope); catalog }
379
421
  end
380
422
  end
423
+
424
+ def retrieve_node_facts(node, given_facts)
425
+ facts = Puppet::Node::Facts.indirection.find(node, :environment => Puppet.lookup(:current_environment))
426
+
427
+ facts = Puppet::Node::Facts.new(node, {}) if facts.nil?
428
+ facts.add_extra_values(given_facts) if given_facts
429
+
430
+ if facts.values.empty?
431
+ raise _("No facts available for target node: %{node}") % { node: node}
432
+ end
433
+ facts
434
+ end
381
435
  end
@@ -5,10 +5,12 @@ module Puppet
5
5
  def singleton
6
6
  key = (name + ".singleton").intern
7
7
  thread = Thread.current
8
- unless thread.thread_variable?(key)
9
- thread.thread_variable_set(key, new)
8
+ value = thread.thread_variable_get(key)
9
+ if value.nil?
10
+ value = new
11
+ thread.thread_variable_set(key, value)
10
12
  end
11
- thread.thread_variable_get(key)
13
+ value
12
14
  end
13
15
  end
14
16
  end
@@ -304,7 +304,7 @@ class Puppet::Configurer
304
304
  Puppet.debug(_("Environment not passed via CLI and no catalog was given, attempting to find out the last server-specified environment"))
305
305
  initial_environment, loaded_last_environment = last_server_specified_environment
306
306
 
307
- unless loaded_last_environment
307
+ unless Puppet[:use_last_environment] && loaded_last_environment
308
308
  Puppet.debug(_("Requesting environment from the server"))
309
309
  initial_environment = current_server_specified_environment(@environment, configured_environment, options)
310
310
  end
@@ -513,17 +513,7 @@ class Puppet::Configurer
513
513
  :transaction_uuid => @transaction_uuid,
514
514
  :fail_on_404 => true)
515
515
 
516
- # The :rest node terminus returns a node with an environment_name, but not an
517
- # environment instance. Attempting to get the environment instance will load
518
- # it from disk, which will likely fail. So create a remote environment.
519
- #
520
- # The :plain node terminus returns a node with an environment, but not an
521
- # environment_name.
522
- if !node.has_environment_instance? && node.environment_name
523
- node.environment = Puppet::Node::Environment.remote(node.environment_name)
524
- end
525
-
526
- @server_specified_environment = node.environment.to_s
516
+ @server_specified_environment = node.environment_name.to_s
527
517
 
528
518
  if @server_specified_environment != @environment
529
519
  Puppet.notice _("Local environment: '%{local_env}' doesn't match server specified node environment '%{node_env}', switching agent to '%{node_env}'.") % { local_env: @environment, node_env: @server_specified_environment }
@@ -442,6 +442,17 @@ module Puppet
442
442
  <https://puppet.com/docs/puppet/latest/environments_about.html>",
443
443
  :type => :path,
444
444
  },
445
+ :use_last_environment => {
446
+ :type => :boolean,
447
+ :default => true,
448
+ :desc => <<-'EOT'
449
+ Puppet saves both the initial and converged environment in the last_run_summary file.
450
+ If they differ, and this setting is set to true, we will use the last converged
451
+ environment and skip the node request.
452
+
453
+ When set to false, we will do the node request and ignore the environment data from the last_run_summary file.
454
+ EOT
455
+ },
445
456
  :always_retry_plugins => {
446
457
  :type => :boolean,
447
458
  :default => true,
@@ -2056,7 +2067,9 @@ EOT
2056
2067
  :call_hook => :on_initialize_and_write, # Call our hook with the default value, so we always get the value added to facter.
2057
2068
  :hook => proc do |value|
2058
2069
  paths = value.split(File::PATH_SEPARATOR)
2059
- Puppet.runtime[:facter].search(*paths)
2070
+ facter = Puppet.runtime[:facter]
2071
+ facter.reset
2072
+ facter.search(*paths)
2060
2073
  end
2061
2074
  }
2062
2075
  )
@@ -2197,8 +2210,6 @@ EOT
2197
2210
  # Call our hook with the default value, so we always get the libdir set.
2198
2211
  :call_hook => :on_initialize_and_write,
2199
2212
  :hook => proc do |value|
2200
- require 'puppet/node'
2201
- require 'puppet/node/facts'
2202
2213
  if value
2203
2214
  Puppet::Resource::Catalog.indirection.set_global_setting(:cache_class, :store_configs)
2204
2215
  settings.override_default(:catalog_cache_terminus, :store_configs)
@@ -58,6 +58,8 @@ Puppet::Face.define(:generate, '0.1.0') do
58
58
  Puppet::FileSystem::mkpath(outputdir)
59
59
 
60
60
  generator.generate(inputs, outputdir, options[:force])
61
+
62
+ exit(1) if generator.bad_input?
61
63
  nil
62
64
  end
63
65
  end
@@ -118,6 +118,9 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
118
118
  when "link"
119
119
  @destination = Puppet::FileSystem.readlink(real_path)
120
120
  @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s rescue nil
121
+ when "fifo", "socket"
122
+ @checksum_type = "none"
123
+ @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s
121
124
  else
122
125
  raise ArgumentError, _("Cannot manage files of type %{file_type}") % { file_type: stat.ftype }
123
126
  end
@@ -130,23 +130,23 @@ class Puppet::FileSystem::FileImpl
130
130
  end
131
131
 
132
132
  def symlink?(path)
133
- File.symlink?(path)
133
+ ::File.symlink?(path)
134
134
  end
135
135
 
136
136
  def readlink(path)
137
- File.readlink(path)
137
+ ::File.readlink(path)
138
138
  end
139
139
 
140
140
  def unlink(*paths)
141
- File.unlink(*paths)
141
+ ::File.unlink(*paths)
142
142
  end
143
143
 
144
144
  def stat(path)
145
- File.stat(path)
145
+ ::File.stat(path)
146
146
  end
147
147
 
148
148
  def lstat(path)
149
- File.lstat(path)
149
+ ::File.lstat(path)
150
150
  end
151
151
 
152
152
  def compare_stream(path, stream)
@@ -159,7 +159,7 @@ class Puppet::FileSystem::FileImpl
159
159
 
160
160
  def replace_file(path, mode = nil)
161
161
  begin
162
- stat = Puppet::FileSystem.lstat(path)
162
+ stat = lstat(path)
163
163
  gid = stat.gid
164
164
  uid = stat.uid
165
165
  mode ||= stat.mode & 07777
@@ -180,7 +180,7 @@ class Puppet::FileSystem::FileImpl
180
180
  tempfile_path = tempfile.path
181
181
  FileUtils.chown(uid, gid, tempfile_path) if uid && gid
182
182
  chmod(mode, tempfile_path)
183
- File.rename(tempfile_path, Puppet::FileSystem.path_string(path))
183
+ ::File.rename(tempfile_path, path_string(path))
184
184
  ensure
185
185
  tempfile.close!
186
186
  end
@@ -14,7 +14,7 @@ class Puppet::FileSystem::JRuby < Puppet::FileSystem::Posix
14
14
  def replace_file(path, mode = nil, &block)
15
15
  # MRI Ruby rename checks if destination is a directory and raises, while
16
16
  # JRuby removes the directory and replaces the file.
17
- if Puppet::FileSystem.directory?(path)
17
+ if directory?(path)
18
18
  raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
19
19
  end
20
20
 
@@ -123,7 +123,7 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
123
123
  LOCK_VIOLATION = 33
124
124
 
125
125
  def replace_file(path, mode = nil)
126
- if Puppet::FileSystem.directory?(path)
126
+ if directory?(path)
127
127
  raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
128
128
  end
129
129
 
@@ -159,14 +159,14 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
159
159
  end
160
160
 
161
161
  set_dacl(tempfile.path, dacl) if dacl
162
- File.rename(tempfile.path, Puppet::FileSystem.path_string(path))
162
+ ::File.rename(tempfile.path, path_string(path))
163
163
  ensure
164
164
  tempfile.close!
165
165
  end
166
166
  rescue Puppet::Util::Windows::Error => e
167
167
  case e.code
168
168
  when ACCESS_DENIED, SHARING_VIOLATION, LOCK_VIOLATION
169
- raise Errno::EACCES.new(Puppet::FileSystem.path_string(path), e)
169
+ raise Errno::EACCES.new(path_string(path), e)
170
170
  else
171
171
  raise SystemCallError.new(e.message)
172
172
  end
@@ -193,7 +193,7 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
193
193
  end
194
194
 
195
195
  def get_dacl_from_file(path)
196
- sd = Puppet::Util::Windows::Security.get_security_descriptor(Puppet::FileSystem.path_string(path))
196
+ sd = Puppet::Util::Windows::Security.get_security_descriptor(path_string(path))
197
197
  sd.dacl
198
198
  rescue Puppet::Util::Windows::Error => e
199
199
  raise e unless e.code == FILE_NOT_FOUND
@@ -396,7 +396,7 @@ module Puppet::FileSystem
396
396
  # @api public
397
397
  #
398
398
  def self.chmod(mode, path)
399
- @impl.chmod(mode, path)
399
+ @impl.chmod(mode, assert_path(path))
400
400
  end
401
401
 
402
402
  # Replace the contents of a file atomically, creating the file if necessary.
@@ -8,6 +8,9 @@ require 'puppet/util/package'
8
8
  #
9
9
  # Where a and b are arbitrary version strings.
10
10
  #
11
+ # Optional parameter ignore_trailing_zeroes is used to ignore unnecessary
12
+ # trailing version numbers like .0 or .0.00
13
+ #
11
14
  # This function returns:
12
15
  #
13
16
  # * `1` if version a is greater than version b
@@ -28,9 +31,10 @@ Puppet::Functions.create_function(:versioncmp) do
28
31
  dispatch :versioncmp do
29
32
  param 'String', :a
30
33
  param 'String', :b
34
+ optional_param 'Boolean', :ignore_trailing_zeroes
31
35
  end
32
36
 
33
- def versioncmp(a, b)
34
- Puppet::Util::Package.versioncmp(a, b)
37
+ def versioncmp(a, b, ignore_trailing_zeroes = false)
38
+ Puppet::Util::Package.versioncmp(a, b, ignore_trailing_zeroes)
35
39
  end
36
40
  end
@@ -134,6 +134,9 @@ module Puppet
134
134
  inputs.sort_by! { |input| input.path }
135
135
  end
136
136
 
137
+ def self.bad_input?
138
+ @bad_input
139
+ end
137
140
  # Generates files for the given inputs.
138
141
  # If a file is up to date (newer than input) it is kept.
139
142
  # If a file is out of date it is regenerated.
@@ -170,6 +173,8 @@ module Puppet
170
173
  }
171
174
 
172
175
  up_to_date = true
176
+ @bad_input = false
177
+
173
178
  Puppet.notice _('Generating Puppet resource types.')
174
179
  inputs.each do |input|
175
180
  if !force && input.up_to_date?(outputdir)
@@ -187,6 +192,7 @@ module Puppet
187
192
  raise
188
193
  rescue Exception => e
189
194
  # Log the exception and move on to the next input
195
+ @bad_input = true
190
196
  Puppet.log_exception(e, _("Failed to load custom type '%{type_name}' from '%{input}': %{message}") % { type_name: type_name, input: input, message: e.message })
191
197
  next
192
198
  end
@@ -205,6 +211,7 @@ module Puppet
205
211
  begin
206
212
  model = Models::Type::Type.new(type)
207
213
  rescue Exception => e
214
+ @bad_input = true
208
215
  # Move on to the next input
209
216
  Puppet.log_exception(e, "#{input}: #{e.message}")
210
217
  next
@@ -214,6 +221,7 @@ module Puppet
214
221
  begin
215
222
  result = model.render(templates[input.template_path])
216
223
  rescue Exception => e
224
+ @bad_input = true
217
225
  Puppet.log_exception(e)
218
226
  raise
219
227
  end
@@ -227,6 +235,7 @@ module Puppet
227
235
  file.write(result)
228
236
  end
229
237
  rescue Exception => e
238
+ @bad_input = true
230
239
  Puppet.log_exception(e, _("Failed to generate '%{effective_output_path}': %{message}") % { effective_output_path: effective_output_path, message: e.message })
231
240
  # Move on to the next input
232
241
  next
data/lib/puppet/node.rb CHANGED
@@ -89,7 +89,7 @@ class Puppet::Node
89
89
  unless @environment.nil?
90
90
  # always set the environment parameter. It becomes top scope $environment for a manifest during catalog compilation.
91
91
  @parameters[ENVIRONMENT] = @environment.name.to_s
92
- self.environment_name = @environment.name if instance_variable_defined?(:@environment_name)
92
+ self.environment_name = @environment.name
93
93
  end
94
94
  @environment
95
95
  end
@@ -11,17 +11,17 @@ class Puppet::Pops::Parser::CodeMerger
11
11
  # PUP-5299, some sites have thousands of entries, and run out of stack when evaluating - the logic
12
12
  # below maps the logic as flatly as possible.
13
13
  #
14
- children = parse_results.select {|x| !x.nil? && x.code}.reduce([]) do |memo, parsed_class|
14
+ children = parse_results.select {|x| !x.nil? && x.code}.flat_map do |parsed_class|
15
15
  case parsed_class.code
16
16
  when Puppet::Parser::AST::BlockExpression
17
17
  # the BlockExpression wraps a single 4x instruction that is most likely wrapped in a Factory
18
- memo + parsed_class.code.children.map {|c| c.is_a?(Puppet::Pops::Model::Factory) ? c.model : c }
18
+ parsed_class.code.children.map {|c| c.is_a?(Puppet::Pops::Model::Factory) ? c.model : c }
19
19
  when Puppet::Pops::Model::Factory
20
20
  # If it is a 4x instruction wrapped in a Factory
21
- memo + parsed_class.code.model
21
+ parsed_class.code.model
22
22
  else
23
23
  # It is the instruction directly
24
- memo << parsed_class.code
24
+ parsed_class.code
25
25
  end
26
26
  end
27
27
  Puppet::Parser::AST::BlockExpression.new(:children => children)
@@ -919,6 +919,8 @@ keyword
919
919
  | CONSUMES
920
920
  | PRODUCES
921
921
  | SITE
922
+ | PLAN
923
+ | APPLY
922
924
 
923
925
  nil
924
926
  : { result = nil}