puppet 7.10.0 → 7.11.0

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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +9 -9
  4. data/lib/puppet/application/agent.rb +4 -0
  5. data/lib/puppet/application/apply.rb +20 -2
  6. data/lib/puppet/application/resource.rb +15 -13
  7. data/lib/puppet/concurrent/thread_local_singleton.rb +1 -0
  8. data/lib/puppet/configurer.rb +14 -4
  9. data/lib/puppet/confine/variable.rb +1 -1
  10. data/lib/puppet/defaults.rb +9 -3
  11. data/lib/puppet/facter_impl.rb +96 -0
  12. data/lib/puppet/file_serving/mount/file.rb +4 -4
  13. data/lib/puppet/file_system/file_impl.rb +3 -1
  14. data/lib/puppet/forge.rb +1 -1
  15. data/lib/puppet/indirector/catalog/compiler.rb +3 -3
  16. data/lib/puppet/indirector/facts/facter.rb +6 -6
  17. data/lib/puppet/indirector/indirection.rb +1 -1
  18. data/lib/puppet/module_tool/applications/uninstaller.rb +1 -1
  19. data/lib/puppet/module_tool/applications/upgrader.rb +1 -1
  20. data/lib/puppet/pal/pal_impl.rb +1 -1
  21. data/lib/puppet/parser/scope.rb +8 -7
  22. data/lib/puppet/parser/templatewrapper.rb +1 -0
  23. data/lib/puppet/pops/lookup/lookup_adapter.rb +3 -2
  24. data/lib/puppet/pops/model/ast.rb +1 -0
  25. data/lib/puppet/pops/model/factory.rb +14 -13
  26. data/lib/puppet/pops/parser/egrammar.ra +2 -2
  27. data/lib/puppet/pops/parser/eparser.rb +752 -753
  28. data/lib/puppet/pops/parser/lexer2.rb +69 -68
  29. data/lib/puppet/pops/parser/slurp_support.rb +1 -0
  30. data/lib/puppet/pops/serialization/to_stringified_converter.rb +1 -1
  31. data/lib/puppet/pops/types/type_formatter.rb +7 -6
  32. data/lib/puppet/pops/types/types.rb +1 -1
  33. data/lib/puppet/provider/aix_object.rb +1 -1
  34. data/lib/puppet/provider/group/groupadd.rb +5 -2
  35. data/lib/puppet/provider/package/pkg.rb +1 -1
  36. data/lib/puppet/provider/package/puppet_gem.rb +1 -1
  37. data/lib/puppet/provider/package/puppetserver_gem.rb +1 -1
  38. data/lib/puppet/provider/package/yum.rb +1 -1
  39. data/lib/puppet/provider/service/base.rb +1 -1
  40. data/lib/puppet/provider/service/init.rb +5 -5
  41. data/lib/puppet/provider/service/launchd.rb +1 -1
  42. data/lib/puppet/provider/service/redhat.rb +1 -1
  43. data/lib/puppet/provider/service/smf.rb +3 -3
  44. data/lib/puppet/provider/service/systemd.rb +1 -1
  45. data/lib/puppet/provider/service/upstart.rb +5 -5
  46. data/lib/puppet/provider/user/aix.rb +44 -1
  47. data/lib/puppet/provider/user/directoryservice.rb +1 -1
  48. data/lib/puppet/provider/user/useradd.rb +10 -7
  49. data/lib/puppet/provider.rb +1 -1
  50. data/lib/puppet/reference/providers.rb +2 -2
  51. data/lib/puppet/resource/type_collection.rb +2 -1
  52. data/lib/puppet/runtime.rb +11 -1
  53. data/lib/puppet/settings/file_setting.rb +3 -8
  54. data/lib/puppet/settings.rb +2 -2
  55. data/lib/puppet/test/test_helper.rb +4 -1
  56. data/lib/puppet/type/exec.rb +9 -1
  57. data/lib/puppet/type/group.rb +0 -1
  58. data/lib/puppet/type/resources.rb +1 -1
  59. data/lib/puppet/type/user.rb +0 -1
  60. data/lib/puppet/util/command_line.rb +1 -1
  61. data/lib/puppet/util/filetype.rb +2 -2
  62. data/lib/puppet/util/log.rb +1 -2
  63. data/lib/puppet/util/logging.rb +1 -25
  64. data/lib/puppet/util/pidlock.rb +1 -1
  65. data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
  66. data/lib/puppet/util/suidmanager.rb +1 -2
  67. data/lib/puppet/util/tagging.rb +1 -0
  68. data/lib/puppet/util/windows/user.rb +0 -1
  69. data/lib/puppet/util.rb +4 -3
  70. data/lib/puppet/version.rb +1 -1
  71. data/lib/puppet.rb +2 -6
  72. data/man/man5/puppet.conf.5 +10 -2
  73. data/man/man8/puppet-agent.8 +4 -1
  74. data/man/man8/puppet-apply.8 +1 -1
  75. data/man/man8/puppet-catalog.8 +1 -1
  76. data/man/man8/puppet-config.8 +1 -1
  77. data/man/man8/puppet-describe.8 +1 -1
  78. data/man/man8/puppet-device.8 +1 -1
  79. data/man/man8/puppet-doc.8 +1 -1
  80. data/man/man8/puppet-epp.8 +1 -1
  81. data/man/man8/puppet-facts.8 +1 -1
  82. data/man/man8/puppet-filebucket.8 +1 -1
  83. data/man/man8/puppet-generate.8 +1 -1
  84. data/man/man8/puppet-help.8 +1 -1
  85. data/man/man8/puppet-lookup.8 +1 -1
  86. data/man/man8/puppet-module.8 +1 -1
  87. data/man/man8/puppet-node.8 +1 -1
  88. data/man/man8/puppet-parser.8 +1 -1
  89. data/man/man8/puppet-plugin.8 +1 -1
  90. data/man/man8/puppet-report.8 +1 -1
  91. data/man/man8/puppet-resource.8 +1 -1
  92. data/man/man8/puppet-script.8 +1 -1
  93. data/man/man8/puppet-ssl.8 +1 -1
  94. data/man/man8/puppet.8 +2 -2
  95. data/spec/integration/application/agent_spec.rb +16 -0
  96. data/spec/integration/configurer_spec.rb +1 -1
  97. data/spec/integration/indirector/facts/facter_spec.rb +3 -3
  98. data/spec/integration/transaction/report_spec.rb +1 -1
  99. data/spec/integration/type/file_spec.rb +2 -2
  100. data/spec/integration/type/package_spec.rb +6 -6
  101. data/spec/integration/util/rdoc/parser_spec.rb +1 -1
  102. data/spec/integration/util/windows/process_spec.rb +1 -9
  103. data/spec/unit/application/apply_spec.rb +76 -56
  104. data/spec/unit/application/resource_spec.rb +29 -0
  105. data/spec/unit/configurer_spec.rb +13 -3
  106. data/spec/unit/facter_impl_spec.rb +31 -0
  107. data/spec/unit/file_bucket/dipper_spec.rb +2 -2
  108. data/spec/unit/file_system_spec.rb +7 -0
  109. data/spec/unit/functions/lookup_spec.rb +64 -0
  110. data/spec/unit/indirector/indirection_spec.rb +10 -3
  111. data/spec/unit/pops/serialization/to_stringified_spec.rb +5 -0
  112. data/spec/unit/pops/types/type_calculator_spec.rb +6 -0
  113. data/spec/unit/provider/package/gem_spec.rb +1 -1
  114. data/spec/unit/provider/package/pip2_spec.rb +1 -1
  115. data/spec/unit/provider/package/pip3_spec.rb +1 -1
  116. data/spec/unit/provider/package/pip_spec.rb +1 -1
  117. data/spec/unit/provider/package/puppet_gem_spec.rb +1 -1
  118. data/spec/unit/provider/package/puppetserver_gem_spec.rb +1 -1
  119. data/spec/unit/provider/user/aix_spec.rb +100 -0
  120. data/spec/unit/provider/user/directoryservice_spec.rb +1 -1
  121. data/spec/unit/provider_spec.rb +4 -4
  122. data/spec/unit/puppet_spec.rb +12 -4
  123. data/spec/unit/settings/file_setting_spec.rb +10 -7
  124. data/spec/unit/type_spec.rb +2 -2
  125. data/spec/unit/util/logging_spec.rb +2 -0
  126. data/tasks/parallel.rake +3 -3
  127. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb14045c978960e4e7b09aed6c3520ec4de726569117031ae3ba5bd96c2e077a
4
- data.tar.gz: 47e721bc33f5564e98fc4b7bb6a4127e209b64efcb921cd5be3e5becd99ae76b
3
+ metadata.gz: 8f537f678f34da6971073332b82eb39b545d5be1a86349f227ecb3f281aca064
4
+ data.tar.gz: bf52e1b8ab1ed145523617db66df66770d7422e9b4f3518bac16bab9861356af
5
5
  SHA512:
6
- metadata.gz: b655140a24ba14e21ab4ae9b4587d450058e147cad7bf3670fb3a518359b8a5d1457ffe1d5adc1e655ffff3d1a89a0b2687a4713f07844f3110b5114f6969b2a
7
- data.tar.gz: '02850db07816869af5f43502f101f6fbcc7d395522721f3181f4a0b75c5729edbe75a880e324de5079e4a5ae38d221439e6557adda107d99b17c5a0870f64ca7'
6
+ metadata.gz: 591cea7ddbaa9236cc0c3719e16c23693f29c7480b93207a4b2bac1be1bd86029899d34455d14603bec2e252d13ce41fa975e6041ca079667550c46797aff794
7
+ data.tar.gz: 04db4ad4c55cfbc3d3521e0af62090213c656455f2121470eda5cb47c77262f292f11b65394e5b7cc7ec84b27a9f6df5ab9c94b54c37e8f722b4641204d9918b
data/Gemfile CHANGED
@@ -53,7 +53,7 @@ end
53
53
  group(:development, optional: true) do
54
54
  gem 'memory_profiler', require: false, platforms: [:mri]
55
55
  gem 'pry', require: false, platforms: [:ruby]
56
- gem "racc", "1.4.9", require: false, platforms: [:ruby]
56
+ gem "racc", "1.5.2", require: false, platforms: [:ruby]
57
57
  if RUBY_PLATFORM != 'java'
58
58
  gem 'ruby-prof', '>= 0.16.0', require: false
59
59
  end
@@ -63,7 +63,7 @@ group(:packaging) do
63
63
  gem 'packaging', *location_for(ENV['PACKAGING_LOCATION'] || '~> 0.99')
64
64
  end
65
65
 
66
- group(:documentation) do
66
+ group(:documentation, optional: true) do
67
67
  gem 'gettext-setup', '~> 0.28', require: false, platforms: [:ruby]
68
68
  gem 'ronn', '~> 0.7.3', require: false, platforms: [:ruby]
69
69
  end
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  GIT
2
2
  remote: git://github.com/puppetlabs/packaging
3
- revision: 804ad19a32455079917eaabd73fcec65078e8cee
3
+ revision: 734cbd7a585d76fb359222d4d5ee6bf239956432
4
4
  branch: 1.0.x
5
5
  specs:
6
- packaging (0.99.79.2.g804ad19)
6
+ packaging (0.99.80.6.g734cbd7)
7
7
  artifactory (~> 2)
8
8
  csv (= 3.1.5)
9
9
  rake (>= 12.3)
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- puppet (7.10.0)
15
+ puppet (7.11.0)
16
16
  CFPropertyList (~> 2.2)
17
17
  concurrent-ruby (~> 1.0)
18
18
  deep_merge (~> 1.0)
@@ -40,11 +40,11 @@ GEM
40
40
  deep_merge (1.2.1)
41
41
  diff-lcs (1.4.4)
42
42
  docopt (0.6.1)
43
- facter (4.2.2)
43
+ facter (4.2.3)
44
44
  hocon (~> 1.3)
45
45
  thor (>= 1.0.1, < 2.0)
46
46
  fast_gettext (1.1.2)
47
- ffi (1.15.3)
47
+ ffi (1.15.4)
48
48
  gettext (3.2.9)
49
49
  locale (>= 2.0.5)
50
50
  text (>= 1.3.0)
@@ -70,7 +70,7 @@ GEM
70
70
  multi_json (1.15.0)
71
71
  mustache (1.1.1)
72
72
  optimist (3.0.1)
73
- parallel (1.20.1)
73
+ parallel (1.21.0)
74
74
  parser (2.7.2.0)
75
75
  ast (~> 2.4.1)
76
76
  powerpack (0.1.3)
@@ -80,9 +80,9 @@ GEM
80
80
  public_suffix (4.0.6)
81
81
  puppet-resource_api (1.8.14)
82
82
  hocon (>= 1.0)
83
- puppetserver-ca (2.3.1)
83
+ puppetserver-ca (2.3.5)
84
84
  facter (>= 2.0.1, < 5)
85
- racc (1.4.9)
85
+ racc (1.5.2)
86
86
  rainbow (2.2.2)
87
87
  rake
88
88
  rake (13.0.6)
@@ -153,7 +153,7 @@ DEPENDENCIES
153
153
  puppet!
154
154
  puppet-resource_api (~> 1.5)
155
155
  puppetserver-ca (~> 2.0)
156
- racc (= 1.4.9)
156
+ racc (= 1.5.2)
157
157
  rake (~> 13.0)
158
158
  rdoc (~> 6.0)
159
159
  ronn (~> 0.7.3)
@@ -334,6 +334,10 @@ generated by running puppet agent with '--genconfig'.
334
334
  specifying a time of 0.
335
335
  (This is a Puppet setting, and can go in puppet.conf.)
336
336
 
337
+ * --write_catalog_summary
338
+ After compiling the catalog saves the resource list and classes list to the node
339
+ in the state directory named classes.txt and resources.txt
340
+ (This is a Puppet setting, and can go in puppet.conf.)
337
341
 
338
342
  EXAMPLE
339
343
  -------
@@ -16,7 +16,9 @@ class Puppet::Application::Apply < Puppet::Application
16
16
  option("--use-nodes")
17
17
  option("--detailed-exitcodes")
18
18
 
19
- option("--write-catalog-summary")
19
+ option("--write-catalog-summary") do |arg|
20
+ Puppet[:write_catalog_summary] = arg
21
+ end
20
22
 
21
23
  option("--catalog catalog", "-c catalog") do |arg|
22
24
  options[:catalog] = arg
@@ -169,6 +171,7 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
169
171
  def app_defaults
170
172
  super.merge({
171
173
  :default_file_terminus => :file_server,
174
+ :write_catalog_summary => false
172
175
  })
173
176
  end
174
177
 
@@ -247,7 +250,22 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
247
250
 
248
251
  catalog.retrieval_duration = Time.now - starttime
249
252
 
250
- if options[:write_catalog_summary]
253
+ # We accept either the global option `--write_catalog_summary`
254
+ # corresponding to the new setting, or the application option
255
+ # `--write-catalog-summary`. The latter is needed to maintain backwards
256
+ # compatibility.
257
+ #
258
+ # Puppet settings parse global options using PuppetOptionParser, but it
259
+ # only recognizes underscores, not dashes.
260
+ # The base application parses app specific options using ruby's builtin
261
+ # OptionParser. As of ruby 2.4, it will accept either underscores or
262
+ # dashes, but prefer dashes.
263
+ #
264
+ # So if underscores are used, the PuppetOptionParser will parse it and
265
+ # store that in Puppet[:write_catalog_summary]. If dashes are used,
266
+ # OptionParser will parse it, and set Puppet[:write_catalog_summary]. In
267
+ # either case, settings will contain the correct value.
268
+ if Puppet[:write_catalog_summary]
251
269
  catalog.write_class_file
252
270
  catalog.write_resource_file
253
271
  end
@@ -225,21 +225,23 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
225
225
  def find_or_save_resources(type, name, params)
226
226
  key = local_key(type, name)
227
227
 
228
- if name
229
- if params.empty?
230
- [ Puppet::Resource.indirection.find( key ) ]
228
+ Puppet.override(stringify_rich: true) do
229
+ if name
230
+ if params.empty?
231
+ [ Puppet::Resource.indirection.find( key ) ]
232
+ else
233
+ resource = Puppet::Resource.new( type, name, :parameters => params )
234
+
235
+ # save returns [resource that was saved, transaction log from applying the resource]
236
+ save_result = Puppet::Resource.indirection.save(resource, key)
237
+ [ save_result.first ]
238
+ end
231
239
  else
232
- resource = Puppet::Resource.new( type, name, :parameters => params )
233
-
234
- # save returns [resource that was saved, transaction log from applying the resource]
235
- save_result = Puppet::Resource.indirection.save(resource, key)
236
- [ save_result.first ]
237
- end
238
- else
239
- if type == "file"
240
- raise _("Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc")
240
+ if type == "file"
241
+ raise _("Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc")
242
+ end
243
+ Puppet::Resource.indirection.search( key, {} )
241
244
  end
242
- Puppet::Resource.indirection.search( key, {} )
243
245
  end
244
246
  end
245
247
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Puppet
2
3
  module Concurrent
3
4
  module ThreadLocalSingleton
@@ -118,8 +118,11 @@ class Puppet::Configurer
118
118
  catalog = result.to_ral
119
119
  catalog.finalize
120
120
  catalog.retrieval_duration = duration
121
- catalog.write_class_file
122
- catalog.write_resource_file
121
+
122
+ if Puppet[:write_catalog_summary]
123
+ catalog.write_class_file
124
+ catalog.write_resource_file
125
+ end
123
126
  end
124
127
  options[:report].add_times(:convert_catalog, catalog_conversion_time) if options[:report]
125
128
 
@@ -581,7 +584,14 @@ class Puppet::Configurer
581
584
  def send_report(report)
582
585
  puts report.summary if Puppet[:summarize]
583
586
  save_last_run_summary(report)
584
- Puppet::Transaction::Report.indirection.save(report, nil, :environment => Puppet::Node::Environment.remote(@environment)) if Puppet[:report]
587
+ if Puppet[:report]
588
+ remote = Puppet::Node::Environment.remote(@environment)
589
+ begin
590
+ Puppet::Transaction::Report.indirection.save(report, nil, ignore_cache: true, environment: remote)
591
+ ensure
592
+ Puppet::Transaction::Report.indirection.save(report, nil, ignore_terminus: true, environment: remote)
593
+ end
594
+ end
585
595
  rescue => detail
586
596
  Puppet.log_exception(detail, _("Could not send report: %{detail}") % { detail: detail })
587
597
  end
@@ -604,7 +614,7 @@ class Puppet::Configurer
604
614
  # @return [false] If an exception is raised during fact generation or
605
615
  # submission.
606
616
  def resubmit_facts
607
- ::Facter.clear
617
+ Puppet.runtime[:facter].clear
608
618
  facts = find_facts
609
619
 
610
620
  client = Puppet.runtime[:http]
@@ -18,7 +18,7 @@ class Puppet::Confine::Variable < Puppet::Confine
18
18
 
19
19
  # Retrieve the value from facter
20
20
  def facter_value
21
- @facter_value ||= ::Facter.value(name).to_s.downcase
21
+ @facter_value ||= Puppet.runtime[:facter].value(name).to_s.downcase
22
22
  end
23
23
 
24
24
  def initialize(values)
@@ -3,7 +3,7 @@ require_relative '../puppet/util/platform'
3
3
  module Puppet
4
4
 
5
5
  def self.default_diffargs
6
- if (Facter.value(:kernel) == "AIX" && Facter.value(:kernelmajversion) == "5300")
6
+ if (Puppet.runtime[:facter].value(:kernel) == "AIX" && Puppet.runtime[:facter].value(:kernelmajversion) == "5300")
7
7
  ""
8
8
  else
9
9
  "-u"
@@ -243,7 +243,7 @@ module Puppet
243
243
  internal Ruby stack trace interleaved with Puppet function frames.",
244
244
  :hook => proc do |value|
245
245
  # Enable or disable Facter's trace option too
246
- Facter.trace(value) if Facter.respond_to? :trace
246
+ Puppet.runtime[:facter].trace(value)
247
247
  end
248
248
  },
249
249
  :puppet_trace => {
@@ -1532,6 +1532,12 @@ EOT
1532
1532
  :mode => "0750",
1533
1533
  :desc => "The directory in which serialized data is stored on the client."
1534
1534
  },
1535
+ :write_catalog_summary => {
1536
+ :default => true,
1537
+ :type => :boolean,
1538
+ :desc => "Whether to write the `classfile` and `resourcefile` after applying
1539
+ the catalog. It is enabled by default, except when running `puppet apply`.",
1540
+ },
1535
1541
  :classfile => {
1536
1542
  :default => "$statedir/classes.txt",
1537
1543
  :type => :file,
@@ -1971,7 +1977,7 @@ EOT
1971
1977
  :call_hook => :on_initialize_and_write, # Call our hook with the default value, so we always get the value added to facter.
1972
1978
  :hook => proc do |value|
1973
1979
  paths = value.split(File::PATH_SEPARATOR)
1974
- Facter.search(*paths)
1980
+ Puppet.runtime[:facter].search(*paths)
1975
1981
  end
1976
1982
  }
1977
1983
  )
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # @api private
5
+ # Default Facter implementation that delegates to Facter API
6
+ #
7
+
8
+ module Puppet
9
+ class FacterImpl
10
+ def initialize
11
+ require 'facter'
12
+
13
+ setup_logging
14
+ end
15
+
16
+ def value(fact_name)
17
+ ::Facter.value(fact_name)
18
+ end
19
+
20
+ def add(name, &block)
21
+ ::Facter.add(name, &block)
22
+ end
23
+
24
+ def to_hash
25
+ ::Facter.to_hash
26
+ end
27
+
28
+ def clear
29
+ ::Facter.clear
30
+ end
31
+
32
+ def reset
33
+ ::Facter.reset
34
+ end
35
+
36
+ def resolve(options)
37
+ ::Facter.resolve(options)
38
+ end
39
+
40
+ def search_external(dirs)
41
+ ::Facter.search_external(dirs)
42
+ end
43
+
44
+ def search(*dirs)
45
+ ::Facter.search(*dirs)
46
+ end
47
+
48
+ def trace(value)
49
+ ::Facter.trace(value) if ::Facter.respond_to? :trace
50
+ end
51
+
52
+ def debugging(value)
53
+ ::Facter.debugging(value) if ::Facter.respond_to?(:debugging)
54
+ end
55
+
56
+ def load_external?
57
+ ::Facter.respond_to?(:load_external)
58
+ end
59
+
60
+ def load_external(value)
61
+ ::Facter.load_external(value) if self.load_external?
62
+ end
63
+
64
+ private
65
+
66
+ def setup_logging
67
+ return unless ::Facter.respond_to? :on_message
68
+
69
+ ::Facter.on_message do |level, message|
70
+ case level
71
+ when :trace, :debug
72
+ level = :debug
73
+ when :info
74
+ # Same as Puppet
75
+ when :warn
76
+ level = :warning
77
+ when :error
78
+ level = :err
79
+ when :fatal
80
+ level = :crit
81
+ else
82
+ next
83
+ end
84
+
85
+ Puppet::Util::Log.create(
86
+ {
87
+ :level => level,
88
+ :source => 'Facter',
89
+ :message => message
90
+ }
91
+ )
92
+ nil
93
+ end
94
+ end
95
+ end
96
+ end
@@ -3,12 +3,12 @@ require_relative '../../../puppet/file_serving/mount'
3
3
  class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount
4
4
  def self.localmap
5
5
  @localmap ||= {
6
- "h" => Facter.value("hostname"),
6
+ "h" => Puppet.runtime[:facter].value("hostname"),
7
7
  "H" => [
8
- Facter.value("hostname"),
9
- Facter.value("domain")
8
+ Puppet.runtime[:facter].value("hostname"),
9
+ Puppet.runtime[:facter].value("domain")
10
10
  ].join("."),
11
- "d" => Facter.value("domain")
11
+ "d" => Puppet.runtime[:facter].value("domain")
12
12
  }
13
13
  end
14
14
 
@@ -84,7 +84,9 @@ class Puppet::FileSystem::FileImpl
84
84
  end
85
85
 
86
86
  def read_preserve_line_endings(path)
87
- read(path, encoding: "bom|#{Encoding.default_external.name}")
87
+ default_encoding = Encoding.default_external.name
88
+ encoding = default_encoding.downcase.start_with?('utf-') ? "bom|#{default_encoding}" : default_encoding
89
+ read(path, encoding: encoding)
88
90
  end
89
91
 
90
92
  def binread(path)
data/lib/puppet/forge.rb CHANGED
@@ -213,7 +213,7 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
213
213
  end
214
214
 
215
215
  def validate_checksum(file, checksum, digest_class)
216
- if Facter.value(:fips_enabled) && digest_class == Digest::MD5
216
+ if Puppet.runtime[:facter].value(:fips_enabled) && digest_class == Digest::MD5
217
217
  raise _("Module install using MD5 is prohibited in FIPS mode.")
218
218
  end
219
219
 
@@ -433,17 +433,17 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
433
433
  "serverip" => "ipaddress",
434
434
  "serverip6" => "ipaddress6"
435
435
  }.each do |var, fact|
436
- value = Facter.value(fact)
436
+ value = Puppet.runtime[:facter].value(fact)
437
437
  if !value.nil?
438
438
  @server_facts[var] = value
439
439
  end
440
440
  end
441
441
 
442
442
  if @server_facts["servername"].nil?
443
- host = Facter.value(:hostname)
443
+ host = Puppet.runtime[:facter].value(:hostname)
444
444
  if host.nil?
445
445
  Puppet.warning _("Could not retrieve fact servername")
446
- elsif domain = Facter.value(:domain) #rubocop:disable Lint/AssignmentInCondition
446
+ elsif domain = Puppet.runtime[:facter].value(:domain) #rubocop:disable Lint/AssignmentInCondition
447
447
  @server_facts["servername"] = [host, domain].join(".")
448
448
  else
449
449
  @server_facts["servername"] = host
@@ -20,10 +20,10 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
20
20
 
21
21
  # Lookup a host's facts up in Facter.
22
22
  def find(request)
23
- Facter.reset
23
+ Puppet.runtime[:facter].reset
24
24
 
25
25
  # Note: we need to setup puppet's external search paths before adding the puppetversion
26
- # fact. This is because in Facter 2.x, the first `Facter.add` causes Facter to create
26
+ # fact. This is because in Facter 2.x, the first `Puppet.runtime[:facter].add` causes Facter to create
27
27
  # its directory loaders which cannot be changed, meaning other external facts won't
28
28
  # be resolved. (PUP-4607)
29
29
  self.class.setup_external_search_paths(request)
@@ -36,7 +36,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
36
36
  raise(Puppet::Error, _("puppet facts show requires version 4.0.40 or greater of Facter.")) unless Facter.respond_to?(:resolve)
37
37
  find_with_options(request)
38
38
  else
39
- Puppet::Node::Facts.new(request.key, Facter.to_hash)
39
+ Puppet::Node::Facts.new(request.key, Puppet.runtime[:facter].to_hash)
40
40
  end
41
41
 
42
42
  result.add_local_facts unless request.options[:resolve_options]
@@ -68,7 +68,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
68
68
  true
69
69
  end
70
70
  dirs << request.options[:custom_dir] if request.options[:custom_dir]
71
- Facter.search(*dirs)
71
+ Puppet.runtime[:facter].search(*dirs)
72
72
  end
73
73
 
74
74
  def self.setup_external_search_paths(request)
@@ -90,7 +90,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
90
90
  end
91
91
 
92
92
  dirs << request.options[:external_dir] if request.options[:external_dir]
93
- Facter.search_external dirs
93
+ Puppet.runtime[:facter].search_external dirs
94
94
  end
95
95
 
96
96
  private
@@ -105,6 +105,6 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
105
105
  options_for_facter += " --no-cache" if options[:no_cache] == false
106
106
  options_for_facter += " --timing" if options[:timing]
107
107
 
108
- Puppet::Node::Facts.new(request.key, Facter.resolve(options_for_facter))
108
+ Puppet::Node::Facts.new(request.key, Puppet.runtime[:facter].resolve(options_for_facter))
109
109
  end
110
110
  end