puppet 8.7.0-universal-darwin → 8.9.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +57 -43
  4. data/ext/project_data.yaml +12 -0
  5. data/ext/windows/service/daemon.rb +9 -2
  6. data/install.rb +3 -74
  7. data/lib/puppet/application/apply.rb +1 -0
  8. data/lib/puppet/application/doc.rb +1 -5
  9. data/lib/puppet/application/filebucket.rb +6 -4
  10. data/lib/puppet/application/lookup.rb +2 -0
  11. data/lib/puppet/application/ssl.rb +4 -4
  12. data/lib/puppet/daemon.rb +0 -1
  13. data/lib/puppet/defaults.rb +67 -71
  14. data/lib/puppet/face/catalog.rb +24 -8
  15. data/lib/puppet/face/help.rb +43 -23
  16. data/lib/puppet/file_serving/http_metadata.rb +2 -0
  17. data/lib/puppet/functions/capitalize.rb +1 -1
  18. data/lib/puppet/functions/find_file.rb +4 -0
  19. data/lib/puppet/functions/hiera.rb +1 -0
  20. data/lib/puppet/functions/index.rb +2 -2
  21. data/lib/puppet/functions/lookup.rb +1 -1
  22. data/lib/puppet/functions/new.rb +1 -1
  23. data/lib/puppet/functions/regsubst.rb +11 -14
  24. data/lib/puppet/functions/unique.rb +3 -2
  25. data/lib/puppet/functions/yaml_data.rb +1 -0
  26. data/lib/puppet/indirector/catalog/compiler.rb +2 -35
  27. data/lib/puppet/interface/action_manager.rb +1 -1
  28. data/lib/puppet/module_tool/tar/gnu.rb +10 -8
  29. data/lib/puppet/node/server_facts.rb +43 -0
  30. data/lib/puppet/parser/functions/generate.rb +2 -1
  31. data/lib/puppet/pops/evaluator/deferred_resolver.rb +41 -6
  32. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -1
  33. data/lib/puppet/pops/evaluator/runtime3_support.rb +0 -6
  34. data/lib/puppet/provider/file/posix.rb +16 -2
  35. data/lib/puppet/provider/package/gem.rb +1 -0
  36. data/lib/puppet/provider/package/pacman.rb +9 -10
  37. data/lib/puppet/provider/package/pkgutil.rb +6 -5
  38. data/lib/puppet/provider/package/puppet_gem.rb +4 -15
  39. data/lib/puppet/reference/configuration.rb +6 -1
  40. data/lib/puppet/resource/type.rb +15 -1
  41. data/lib/puppet/scheduler/splay_job.rb +0 -9
  42. data/lib/puppet/settings.rb +2 -2
  43. data/lib/puppet/transaction/resource_harness.rb +7 -3
  44. data/lib/puppet/type/exec.rb +3 -4
  45. data/lib/puppet/type/file/checksum.rb +4 -2
  46. data/lib/puppet/type/file/ctime.rb +2 -2
  47. data/lib/puppet/type/file/mtime.rb +2 -2
  48. data/lib/puppet/type/file/selcontext.rb +8 -7
  49. data/lib/puppet/type/file/target.rb +9 -11
  50. data/lib/puppet/type/package.rb +4 -3
  51. data/lib/puppet/type/user.rb +1 -1
  52. data/lib/puppet/util/checksums.rb +1 -0
  53. data/lib/puppet/util/execution.rb +1 -1
  54. data/lib/puppet/util/profiler/aggregate.rb +2 -2
  55. data/lib/puppet/util/profiler/wall_clock.rb +2 -2
  56. data/lib/puppet/util/reference.rb +1 -31
  57. data/lib/puppet/util/run_mode.rb +40 -0
  58. data/lib/puppet/util/selinux.rb +38 -16
  59. data/lib/puppet/util/windows/daemon.rb +15 -32
  60. data/lib/puppet/version.rb +1 -1
  61. data/locales/puppet.pot +141 -145
  62. data/man/man5/puppet.conf.5 +18 -18
  63. data/man/man8/puppet-agent.8 +1 -1
  64. data/man/man8/puppet-apply.8 +2 -1
  65. data/man/man8/puppet-catalog.8 +5 -2
  66. data/man/man8/puppet-config.8 +1 -1
  67. data/man/man8/puppet-describe.8 +1 -1
  68. data/man/man8/puppet-device.8 +1 -1
  69. data/man/man8/puppet-doc.8 +1 -1
  70. data/man/man8/puppet-epp.8 +1 -1
  71. data/man/man8/puppet-facts.8 +1 -1
  72. data/man/man8/puppet-filebucket.8 +10 -1
  73. data/man/man8/puppet-generate.8 +1 -1
  74. data/man/man8/puppet-help.8 +1 -1
  75. data/man/man8/puppet-lookup.8 +1 -1
  76. data/man/man8/puppet-module.8 +1 -1
  77. data/man/man8/puppet-node.8 +1 -1
  78. data/man/man8/puppet-parser.8 +1 -1
  79. data/man/man8/puppet-plugin.8 +1 -1
  80. data/man/man8/puppet-report.8 +1 -1
  81. data/man/man8/puppet-resource.8 +1 -1
  82. data/man/man8/puppet-script.8 +1 -1
  83. data/man/man8/puppet-ssl.8 +3 -3
  84. data/man/man8/puppet.8 +128 -9
  85. metadata +44 -29
@@ -7,6 +7,7 @@ module Puppet
7
7
  '-u'
8
8
  end
9
9
 
10
+ # If you modify this, update puppet/type/file/checksum.rb too
10
11
  def self.default_digest_algorithm
11
12
  'sha256'
12
13
  end
@@ -47,29 +48,15 @@ module Puppet
47
48
  end
48
49
 
49
50
  def self.default_basemodulepath
50
- if Puppet::Util::Platform.windows?
51
- path = ['$codedir/modules']
52
- installdir = ENV.fetch("FACTER_env_windows_installdir", nil)
53
- if installdir
54
- path << "#{installdir}/puppet/modules"
55
- end
56
- path.join(File::PATH_SEPARATOR)
57
- else
58
- '$codedir/modules:/opt/puppetlabs/puppet/modules'
51
+ path = ['$codedir/modules']
52
+ if (run_mode_dir = Puppet.run_mode.common_module_dir)
53
+ path << run_mode_dir
59
54
  end
55
+ path.join(File::PATH_SEPARATOR)
60
56
  end
61
57
 
62
58
  def self.default_vendormoduledir
63
- if Puppet::Util::Platform.windows?
64
- installdir = ENV.fetch("FACTER_env_windows_installdir", nil)
65
- if installdir
66
- "#{installdir}\\puppet\\vendor_modules"
67
- else
68
- nil
69
- end
70
- else
71
- '/opt/puppetlabs/puppet/vendor_modules'
72
- end
59
+ Puppet.run_mode.vendor_module_dir
73
60
  end
74
61
 
75
62
  ############################################################################################
@@ -175,8 +162,8 @@ module Puppet
175
162
  :skip_logging_catalog_request_destination => {
176
163
  :default => false,
177
164
  :type => :boolean,
178
- :desc => "If you wish to suppress the notice of which compiler supplied the
179
- catalog",
165
+ :desc => "Specifies whether to suppress the notice of which compiler
166
+ supplied the catalog. A value of `true` suppresses the notice.",
180
167
  },
181
168
  :merge_dependency_warnings => {
182
169
  :default => false,
@@ -431,13 +418,15 @@ module Puppet
431
418
  :type => :boolean,
432
419
  :default => true,
433
420
  :desc => <<-'EOT'
434
- When versioned_environment_dirs is `true` Puppet will readlink the environmentpath
435
- when constructing the environment's modulepath. The full readlinked path is referred
436
- to as the "resolved path" and the configured path potentially containing symlinks is
437
- the "configured path". When reporting where resources come from users may choose
438
- between the configured or resolved path.
439
-
440
- When set to false, the resolved paths are reported instead of the configured paths.
421
+ Specifies how environment paths are reported. When the value of
422
+ `versioned_environment_dirs` is `true`, Puppet applies the readlink function to
423
+ the `environmentpath` setting when constructing the environment's modulepath. The
424
+ full readlinked path is referred to as the "resolved path," and the configured
425
+ path potentially containing symlinks is the "configured path." When reporting
426
+ where resources come from, users may choose between the configured and resolved
427
+ path.
428
+
429
+ When set to `false`, the resolved paths are reported instead of the configured paths.
441
430
  EOT
442
431
  },
443
432
  :use_last_environment => {
@@ -1218,17 +1207,18 @@ EOT
1218
1207
  :ca_refresh_interval => {
1219
1208
  :default => "1d",
1220
1209
  :type => :duration,
1221
- :desc => "How often the Puppet agent refreshes its local CA certs. By
1222
- default the CA certs are refreshed once every 24 hours. If a different
1223
- duration is specified, then the agent will refresh its CA certs whenever
1224
- it next runs and the elapsed time since the certs were last refreshed
1225
- exceeds the duration.
1226
-
1227
- In general, the duration should be greater than the `runinterval`.
1228
- Setting it to 0 or an equal or lesser value than `runinterval`,
1229
- will cause the CA certs to be refreshed on every run.
1230
-
1231
- If the agent downloads new CA certs, the agent will use it for subsequent
1210
+ :desc => "How often the Puppet agent refreshes its local CA
1211
+ certificates. By default, CA certificates are refreshed every 24 hours. If a
1212
+ different interval is specified, the agent refreshes its CA certificates during
1213
+ the next agent run if the elapsed time since the certificates were last
1214
+ refreshed exceeds the specified duration.
1215
+
1216
+ In general, the interval should be greater than the `runinterval`
1217
+ value. Setting the `ca_refresh_interval` value to 0 or an equal or
1218
+ lesser value than `runinterval` causes the CA certificates to be
1219
+ refreshed on every run.
1220
+
1221
+ If the agent downloads new CA certs, the agent uses those for subsequent
1232
1222
  network requests. If the refresh request fails or if the CA certs are
1233
1223
  unchanged on the server, then the agent run will continue using the
1234
1224
  local CA certs it already has. #{AS_DURATION}",
@@ -1236,15 +1226,15 @@ EOT
1236
1226
  :crl_refresh_interval => {
1237
1227
  :default => "1d",
1238
1228
  :type => :duration,
1239
- :desc => "How often the Puppet agent refreshes its local CRL. By
1240
- default the CRL is refreshed once every 24 hours. If a different
1241
- duration is specified, then the agent will refresh its CRL whenever
1242
- it next runs and the elapsed time since the CRL was last refreshed
1243
- exceeds the duration.
1229
+ :desc => "How often the Puppet agent refreshes its local Certificate
1230
+ Revocation List (CRL). By default, the CRL is refreshed every 24 hours. If
1231
+ a different interval is specified, the agent refreshes its CRL on the next
1232
+ Puppet agent run if the elapsed time since the CRL was last refreshed
1233
+ exceeds the specified interval.
1244
1234
 
1245
- In general, the duration should be greater than the `runinterval`.
1246
- Setting it to 0 or an equal or lesser value than `runinterval`,
1247
- will cause the CRL to be refreshed on every run.
1235
+ In general, the interval should be greater than the `runinterval` value.
1236
+ Setting the `crl_refresh_interval` value to 0 or an equal or lesser value
1237
+ than `runinterval` causes the CRL to be refreshed on every run.
1248
1238
 
1249
1239
  If the agent downloads a new CRL, the agent will use it for subsequent
1250
1240
  network requests. If the refresh request fails or if the CRL is
@@ -1254,18 +1244,19 @@ EOT
1254
1244
  :hostcert_renewal_interval => {
1255
1245
  :default => "30d",
1256
1246
  :type => :duration,
1257
- :desc => "When the Puppet agent refreshes its client certificate.
1258
- By default the client certificate will refresh 30 days before the certificate
1259
- expires. If a different duration is specified, then the agent will refresh its
1260
- client certificate whenever it next runs and if the client certificate expires
1261
- within the duration specified.
1247
+ :desc => "How often the Puppet agent renews its client certificate. By
1248
+ default, the client certificate is renewed 30 days before the certificate
1249
+ expires. If a different interval is specified, the agent renews its client
1250
+ certificate during the next agent run, assuming that the client certificate has
1251
+ expired within the specified duration.
1262
1252
 
1263
- In general, the duration should be greater than the `runinterval`.
1264
- Setting it to 0 will disable automatic renewal.
1253
+ In general, the `hostcert_renewal_interval` value should be greater than the
1254
+ `runinterval` value. Setting the `hostcert_renewal_interval` value to 0 disables
1255
+ automatic renewal.
1265
1256
 
1266
- If the agent downloads a new certificate, the agent will use it for subsequent
1267
- network requests. If the refresh request fails, then the agent run will continue using the
1268
- certificate it already has. #{AS_DURATION}",
1257
+ If the agent downloads a new certificate, the agent will use it
1258
+ for subsequent network requests. If the refresh request fails, the agent run
1259
+ continues to use its existing certificate. #{AS_DURATION}",
1269
1260
  },
1270
1261
  :keylength => {
1271
1262
  :default => 4096,
@@ -1506,8 +1497,10 @@ EOT
1506
1497
  :exclude_unchanged_resources => {
1507
1498
  :default => true,
1508
1499
  :type => :boolean,
1509
- :desc => 'When set to true, resources that have had no changes after catalog application
1510
- will not have corresponding unchanged resource status updates listed in the report.'
1500
+ :desc => "Specifies how unchanged resources are listed in reports. When
1501
+ set to `true`, resources that have had no changes after catalog application
1502
+ will not have corresponding unchanged resource status updates listed in a
1503
+ report."
1511
1504
  },
1512
1505
  :reportdir => {
1513
1506
  :default => "$vardir/reports",
@@ -1759,11 +1752,12 @@ EOT
1759
1752
  :allow_pson_serialization => {
1760
1753
  :default => false,
1761
1754
  :type => :boolean,
1762
- :desc => "Whether when unable to serialize to JSON or other formats,
1763
- Puppet falls back to PSON. This option affects both puppetserver's
1764
- configuration management service responses and when the agent saves its
1765
- cached catalog. This option is useful in preventing the loss of data because
1766
- rich data cannot be serialized via PSON.",
1755
+ :desc => "Whether to allow PSON serialization. When unable to serialize to
1756
+ JSON or other formats, Puppet falls back to PSON. This option affects the
1757
+ configuration management service responses of Puppet Server and the process by
1758
+ which the agent saves its cached catalog. With a default value of `false`, this
1759
+ option is useful in preventing the loss of data because rich data cannot be
1760
+ serialized via PSON.",
1767
1761
  },
1768
1762
  :agent_catalog_run_lockfile => {
1769
1763
  :default => "$statedir/agent_catalog_run.lock",
@@ -1789,7 +1783,7 @@ EOT
1789
1783
  :type => :boolean,
1790
1784
  :default => false,
1791
1785
  :desc => "Whether to include legacy facts when requesting a catalog. This
1792
- option can be set to false provided all puppet manifests, hiera.yaml and hiera
1786
+ option can be set to `false` if all puppet manifests, hiera.yaml, and hiera
1793
1787
  configuration layers no longer access legacy facts, such as `$osfamily`, and
1794
1788
  instead access structured facts, such as `$facts['os']['family']`."
1795
1789
  },
@@ -2105,12 +2099,12 @@ EOT
2105
2099
  :preprocess_deferred => {
2106
2100
  :default => false,
2107
2101
  :type => :boolean,
2108
- :desc => "Whether puppet should call deferred functions before applying
2109
- the catalog. If set to `true`, then all prerequisites needed for the
2110
- deferred function must be satisfied prior to puppet running. If set to
2111
- `false`, then deferred functions will follow puppet relationships and
2112
- ordering. This allows puppet to install prerequisites needed for a
2113
- deferred function and call the deferred function in the same run."
2102
+ :desc => "Whether Puppet should call deferred functions before applying
2103
+ the catalog. If set to `true`, all prerequisites required for the
2104
+ deferred function must be satisfied before the Puppet run. If set to
2105
+ `false`, deferred functions follow Puppet relationships and
2106
+ ordering. In this way, Puppet can install the prerequisites required for a
2107
+ deferred function and call the deferred function in the same run.",
2114
2108
  },
2115
2109
  :summarize => {
2116
2110
  :default => false,
@@ -2132,10 +2126,12 @@ EOT
2132
2126
  can produce node information. The command must:
2133
2127
 
2134
2128
  * Take the name of a node as a command-line argument.
2129
+
2135
2130
  * Return a YAML hash with up to three keys:
2136
2131
  * `classes` --- A list of classes, as an array or hash.
2137
2132
  * `environment` --- A string.
2138
2133
  * `parameters` --- A list of top-scope variables to set, as a hash.
2134
+
2139
2135
  * For unknown nodes, exit with a non-zero exit code.
2140
2136
 
2141
2137
  Generally, an ENC script makes requests to an external data source.
@@ -25,13 +25,27 @@ Puppet::Indirector::Face.define(:catalog, '0.0.1') do
25
25
 
26
26
  deactivate_action(:destroy)
27
27
  deactivate_action(:search)
28
- find = get_action(:find)
29
- find.summary "Retrieve the catalog for the node from which the command is run."
30
- find.arguments "<certname>"
31
- find.returns <<-'EOT'
32
- A serialized catalog. When used from the Ruby API, returns a
33
- Puppet::Resource::Catalog object.
34
- EOT
28
+ action(:find) do
29
+ summary _("Retrieve the catalog for the node from which the command is run.")
30
+ arguments "<certname>, <facts>"
31
+ option("--facts_for_catalog") do
32
+ summary _("Not implemented for the CLI; facts are collected internally.")
33
+ end
34
+ returns <<-'EOT'
35
+ A serialized catalog. When used from the Ruby API, returns a
36
+ Puppet::Resource::Catalog object.
37
+ EOT
38
+
39
+ when_invoked do |*args|
40
+ # Default the key to Puppet[:certname] if none is supplied
41
+ if args.length == 1
42
+ key = Puppet[:certname]
43
+ else
44
+ key = args.shift
45
+ end
46
+ call_indirection_method :find, key, args.first
47
+ end
48
+ end
35
49
 
36
50
  action(:apply) do
37
51
  summary "Find and apply a catalog."
@@ -135,9 +149,11 @@ Puppet::Indirector::Face.define(:catalog, '0.0.1') do
135
149
  when_invoked do |_options|
136
150
  Puppet::Resource::Catalog.indirection.terminus_class = :rest
137
151
  Puppet::Resource::Catalog.indirection.cache_class = nil
152
+ facts = Puppet::Face[:facts, '0.0.1'].find(Puppet[:certname])
138
153
  catalog = nil
139
154
  retrieval_duration = thinmark do
140
- catalog = Puppet::Face[:catalog, '0.0.1'].find(Puppet[:certname])
155
+ catalog = Puppet::Face[:catalog, '0.0.1'].find(Puppet[:certname],
156
+ { facts_for_catalog: facts })
141
157
  end
142
158
  catalog.retrieval_duration = retrieval_duration
143
159
  catalog.write_class_file
@@ -151,6 +151,33 @@ Puppet::Face.define(:help, '0.0.1') do
151
151
  end.sort
152
152
  end
153
153
 
154
+ def generate_summary(appname)
155
+ if is_face_app?(appname)
156
+ begin
157
+ face = Puppet::Face[appname, :current]
158
+ # Add deprecation message to summary if the face is deprecated
159
+ summary = face.deprecated? ? face.summary + ' ' + _("(Deprecated)") : face.summary
160
+ [appname, summary, ' ']
161
+ rescue StandardError, LoadError
162
+ error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
163
+ error_message += ' ' + _("Check error logs.")
164
+ [error_message, '', ' ']
165
+ end
166
+ else
167
+ begin
168
+ summary = Puppet::Application[appname].summary
169
+ if summary.empty?
170
+ summary = horribly_extract_summary_from(appname)
171
+ end
172
+ [appname, summary, ' ']
173
+ rescue StandardError, LoadError
174
+ error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
175
+ error_message += ' ' + _("Check error logs.")
176
+ [error_message, '', ' ']
177
+ end
178
+ end
179
+ end
180
+
154
181
  # Return a list of all applications (both legacy and Face applications), along with a summary
155
182
  # of their functionality.
156
183
  # @return [Array] An Array of Arrays. The outer array contains one entry per application; each
@@ -162,29 +189,8 @@ Puppet::Face.define(:help, '0.0.1') do
162
189
 
163
190
  if appname == COMMON || appname == SPECIALIZED || appname == BLANK
164
191
  result << appname
165
- elsif is_face_app?(appname)
166
- begin
167
- face = Puppet::Face[appname, :current]
168
- # Add deprecation message to summary if the face is deprecated
169
- summary = face.deprecated? ? face.summary + ' ' + _("(Deprecated)") : face.summary
170
- result << [appname, summary, ' ']
171
- rescue StandardError, LoadError
172
- error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
173
- error_message += ' ' + _("Check error logs.")
174
- result << [error_message, '', ' ']
175
- end
176
192
  else
177
- begin
178
- summary = Puppet::Application[appname].summary
179
- if summary.empty?
180
- summary = horribly_extract_summary_from(appname)
181
- end
182
- result << [appname, summary, ' ']
183
- rescue StandardError, LoadError
184
- error_message = _("!%{sub_command}! Subcommand unavailable due to error.") % { sub_command: appname }
185
- error_message += ' ' + _("Check error logs.")
186
- result << [error_message, '', ' ']
187
- end
193
+ result << generate_summary(appname)
188
194
  end
189
195
  end
190
196
  end
@@ -192,15 +198,29 @@ Puppet::Face.define(:help, '0.0.1') do
192
198
  COMMON = 'Common:'
193
199
  SPECIALIZED = 'Specialized:'
194
200
  BLANK = "\n"
201
+ COMMON_APPS = %w[apply agent config help lookup module resource]
195
202
  def available_application_names_special_sort
196
203
  full_list = Puppet::Application.available_application_names
197
- a_list = full_list & %w[apply agent config help lookup module resource]
204
+ a_list = full_list & COMMON_APPS
198
205
  a_list = a_list.sort
199
206
  also_ran = full_list - a_list
200
207
  also_ran = also_ran.sort
201
208
  [[COMMON], a_list, [BLANK], [SPECIALIZED], also_ran].flatten(1)
202
209
  end
203
210
 
211
+ def common_app_summaries
212
+ COMMON_APPS.map do |appname|
213
+ generate_summary(appname)
214
+ end
215
+ end
216
+
217
+ def specialized_app_summaries
218
+ specialized_apps = Puppet::Application.available_application_names - COMMON_APPS
219
+ specialized_apps.filter_map do |appname|
220
+ generate_summary(appname) unless exclude_from_docs?(appname)
221
+ end
222
+ end
223
+
204
224
  def horribly_extract_summary_from(appname)
205
225
  help = Puppet::Application[appname].help.split("\n")
206
226
  # Now we find the line with our summary, extract it, and return it. This
@@ -51,6 +51,8 @@ class Puppet::FileServing::HttpMetadata < Puppet::FileServing::Metadata
51
51
  # Prefer the checksum_type from the indirector request options
52
52
  # but fall back to the alternative otherwise
53
53
  [@checksum_type, :sha256, :sha1, :md5, :mtime].each do |type|
54
+ next if type == :md5 && Puppet::Util::Platform.fips_enabled?
55
+
54
56
  @checksum_type = type
55
57
  @checksum = @checksums[type]
56
58
  break if @checksum
@@ -5,7 +5,7 @@
5
5
  # This function is compatible with the stdlib function with the same name.
6
6
  #
7
7
  # The function does the following:
8
- # * For a `String`, a string with its first character in upper case version is returned.
8
+ # * For a `String`, a string is returned in which the first character is uppercase.
9
9
  # This is done using Ruby system locale which handles some, but not all
10
10
  # special international up-casing rules (for example German double-s ß is capitalized to "Ss").
11
11
  # * For an `Iterable[Variant[String, Numeric]]` (for example an `Array`) each value is capitalized and the conversion is not recursive.
@@ -7,6 +7,10 @@
7
7
  # directory. (For example, the reference `mysql/mysqltuner.pl` will search for the
8
8
  # file `<MODULES DIRECTORY>/mysql/files/mysqltuner.pl`.)
9
9
  #
10
+ # If this function is run via puppet agent, it checks for file existence on the
11
+ # Puppet Primary server. If run via puppet apply, it checks on the local host.
12
+ # In both cases, the check is performed before any resources are changed.
13
+ #
10
14
  # This function can also accept:
11
15
  #
12
16
  # * An absolute String path, which checks for the existence of a file from anywhere on disk.
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'hiera/puppet_function'
4
+
4
5
  # Performs a standard priority lookup of the hierarchy and returns the most specific value
5
6
  # for a given key. The returned value can be any type of data.
6
7
  #
@@ -40,8 +40,8 @@
40
40
  # Note that the lambda gets the value and not an array with `[key, value]` as in other
41
41
  # iterative functions.
42
42
  #
43
- # Using a lambda that accepts two values works the same way, it simply gets the index/key
44
- # as the first parameter, and the value as the second.
43
+ # Using a lambda that accepts two values works the same way. The lambda gets the index/key
44
+ # as the first parameter and the value as the second parameter.
45
45
  #
46
46
  # @example Using the `index` function with an Array and a two-parameter lambda
47
47
  #
@@ -97,7 +97,7 @@
97
97
  # or `{'strategy' => 'hash'}` --- Same as the string versions of these merge behaviors.
98
98
  # * `{'strategy' => 'deep', <DEEP OPTION> => <VALUE>, ...}` --- Same as `'deep'`,
99
99
  # but can adjust the merge with additional options. The available options are:
100
- # * `'knockout_prefix'` (string or undef) --- A string prefix to indicate a
100
+ # * `'knockout_prefix'` (string) --- A string prefix to indicate a
101
101
  # value should be _removed_ from the final result. If a value is exactly equal
102
102
  # to the prefix, it will knockout the entire element. Defaults to `undef`, which
103
103
  # disables this feature.
@@ -557,7 +557,7 @@
557
557
  # @example Simple Conversion to String specifying the format for the given value directly
558
558
  #
559
559
  # ```puppet
560
- # $str = String(10, "%#x") # produces '0x10'
560
+ # $str = String(10, "%#x") # produces '0xa'
561
561
  # $str = String([10], "%(a") # produces '("10")'
562
562
  # ```
563
563
  #
@@ -20,13 +20,10 @@ Puppet::Functions.create_function(:regsubst) do
20
20
  # - *M* Multiline regexps
21
21
  # - *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced.
22
22
  # @param encoding [Enum['N','E','S','U']]
23
- # Optional. How to handle multibyte characters when compiling the regexp (must not be used when pattern is a
24
- # precompiled regexp). A single-character string with the following values:
25
- # - *N* None
26
- # - *E* EUC
27
- # - *S* SJIS
28
- # - *U* UTF-8
23
+ # Deprecated and ignored parameter, included only for compatibility.
29
24
  # @return [Array[String], String] The result of the substitution. Result type is the same as for the target parameter.
25
+ # @deprecated
26
+ # This method has the optional encoding parameter, which is ignored.
30
27
  # @example Get the third octet from the node's IP address:
31
28
  # ```puppet
32
29
  # $i3 = regsubst($ipaddress,'^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$','\\3')
@@ -56,13 +53,6 @@ Puppet::Functions.create_function(:regsubst) do
56
53
  # - *I* Ignore case in regexps
57
54
  # - *M* Multiline regexps
58
55
  # - *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced.
59
- # @param encoding [Enum['N','E','S','U']]
60
- # Optional. How to handle multibyte characters when compiling the regexp (must not be used when pattern is a
61
- # precompiled regexp). A single-character string with the following values:
62
- # - *N* None
63
- # - *E* EUC
64
- # - *S* SJIS
65
- # - *U* UTF-8
66
56
  # @return [Array[String], String] The result of the substitution. Result type is the same as for the target parameter.
67
57
  # @example Put angle brackets around each octet in the node's IP address:
68
58
  # ```puppet
@@ -76,6 +66,13 @@ Puppet::Functions.create_function(:regsubst) do
76
66
  end
77
67
 
78
68
  def regsubst_string(target, pattern, replacement, flags = nil, encoding = nil)
69
+ if encoding
70
+ Puppet.warn_once(
71
+ 'deprecations', 'regsubst_function_encoding',
72
+ _("The regsubst() function's encoding argument has been ignored since Ruby 1.9 and will be removed in a future release")
73
+ )
74
+ end
75
+
79
76
  re_flags = 0
80
77
  operation = :sub
81
78
  unless flags.nil?
@@ -88,7 +85,7 @@ Puppet::Functions.create_function(:regsubst) do
88
85
  end
89
86
  end
90
87
  end
91
- inner_regsubst(target, Regexp.compile(pattern, re_flags, encoding), replacement, operation)
88
+ inner_regsubst(target, Regexp.compile(pattern, re_flags), replacement, operation)
92
89
  end
93
90
 
94
91
  def regsubst_regexp(target, pattern, replacement, flags = nil)
@@ -65,8 +65,9 @@
65
65
  # *first-found* unique value, but for `Hash` it contains associations from a set of keys to the set of values clustered by the
66
66
  # equality lambda (or the default value equality if no lambda was given). This makes the `unique` function more versatile for hashes
67
67
  # in general, while requiring that the simple computation of "hash's unique set of values" is performed as `$hsh.map |$k, $v| { $v }.unique`.
68
- # (A unique set of hash keys is in general meaningless (since they are unique by definition) - although if processed with a different
69
- # lambda for equality that would be different. First map the hash to an array of its keys if such a unique computation is wanted).
68
+ # (Generally, it's meaningless to compute the unique set of hash keys because they are unique by definition. However, the
69
+ # situation can change if the hash keys are processed with a different lambda for equality. For this unique computation,
70
+ # first map the hash to an array of its keys.)
70
71
  # If the more advanced clustering is wanted for one of the other data types, simply transform it into a `Hash` as shown in the
71
72
  # following example.
72
73
  #
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
+
4
5
  # The `yaml_data` is a hiera 5 `data_hash` data provider function.
5
6
  # See [the configuration guide documentation](https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-built-in-backends) for
6
7
  # how to use this function.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative '../../../puppet/environments'
4
4
  require_relative '../../../puppet/node'
5
+ require_relative '../../../puppet/node/server_facts'
5
6
  require_relative '../../../puppet/resource/catalog'
6
7
  require_relative '../../../puppet/indirector/code'
7
8
  require_relative '../../../puppet/util/profiler'
@@ -426,40 +427,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
426
427
  #
427
428
  # See also set_server_facts in Puppet::Server::Compiler in puppetserver.
428
429
  def set_server_facts
429
- @server_facts = {}
430
-
431
- # Add our server Puppet Enterprise version, if available.
432
- pe_version_file = '/opt/puppetlabs/server/pe_version'
433
- if File.readable?(pe_version_file) and !File.zero?(pe_version_file)
434
- @server_facts['pe_serverversion'] = File.read(pe_version_file).chomp
435
- end
436
-
437
- # Add our server version to the fact list
438
- @server_facts["serverversion"] = Puppet.version.to_s
439
-
440
- # And then add the server name and IP
441
- { "servername" => "networking.fqdn",
442
- "serverip" => "networking.ip",
443
- "serverip6" => "networking.ip6" }.each do |var, fact|
444
- value = Puppet.runtime[:facter].value(fact)
445
- unless value.nil?
446
- @server_facts[var] = value
447
- end
448
- end
449
-
450
- if @server_facts["servername"].nil?
451
- host = Puppet.runtime[:facter].value('networking.hostname')
452
- if host.nil?
453
- Puppet.warning _("Could not retrieve fact servername")
454
- elsif domain = Puppet.runtime[:facter].value('networking.domain') # rubocop:disable Lint/AssignmentInCondition
455
- @server_facts["servername"] = [host, domain].join(".")
456
- else
457
- @server_facts["servername"] = host
458
- end
459
- end
460
-
461
- if @server_facts["serverip"].nil? && @server_facts["serverip6"].nil?
462
- Puppet.warning _("Could not retrieve either serverip or serverip6 fact")
463
- end
430
+ @server_facts = Puppet::Node::ServerFacts.load
464
431
  end
465
432
  end
@@ -19,7 +19,7 @@ module Puppet::Interface::ActionManager
19
19
  # @dsl Faces
20
20
  def action(name, &block)
21
21
  @actions ||= {}
22
- Puppet.warning _("Redefining action %{name} for %{self}") % { name: name, self: self } if action?(name)
22
+ Puppet.debug _("Redefining action %{name} for %{self}") % { name: name, self: self } if action?(name)
23
23
 
24
24
  action = Puppet::Interface::ActionBuilder.build(self, name, &block)
25
25
 
@@ -4,18 +4,20 @@ require 'shellwords'
4
4
 
5
5
  class Puppet::ModuleTool::Tar::Gnu
6
6
  def unpack(sourcefile, destdir, owner)
7
- sourcefile = File.expand_path(sourcefile)
7
+ safe_sourcefile = Shellwords.shellescape(File.expand_path(sourcefile))
8
8
  destdir = File.expand_path(destdir)
9
+ safe_destdir = Shellwords.shellescape(destdir)
9
10
 
10
- Dir.chdir(destdir) do
11
- Puppet::Util::Execution.execute("gzip -dc #{Shellwords.shellescape(sourcefile)} | tar xof -")
12
- Puppet::Util::Execution.execute("find . -type d -exec chmod 755 {} +")
13
- Puppet::Util::Execution.execute("find . -type f -exec chmod u+rw,g+r,a-st {} +")
14
- Puppet::Util::Execution.execute("chown -R #{owner} .")
15
- end
11
+ Puppet::Util::Execution.execute("gzip -dc #{safe_sourcefile} | tar --extract --no-same-owner --directory #{safe_destdir} --file -")
12
+ Puppet::Util::Execution.execute(['find', destdir, '-type', 'd', '-exec', 'chmod', '755', '{}', '+'])
13
+ Puppet::Util::Execution.execute(['find', destdir, '-type', 'f', '-exec', 'chmod', 'u+rw,g+r,a-st', '{}', '+'])
14
+ Puppet::Util::Execution.execute(['chown', '-R', owner, destdir])
16
15
  end
17
16
 
18
17
  def pack(sourcedir, destfile)
19
- Puppet::Util::Execution.execute("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}")
18
+ safe_sourcedir = Shellwords.shellescape(sourcedir)
19
+ safe_destfile = Shellwords.shellescape(File.basename(destfile))
20
+
21
+ Puppet::Util::Execution.execute("tar cf - #{safe_sourcedir} | gzip -c > #{safe_destfile}")
20
22
  end
21
23
  end