puppet 5.3.5 → 5.3.6

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 (71) hide show
  1. data/lib/puppet/application/cert.rb +3 -1
  2. data/lib/puppet/application/device.rb +99 -12
  3. data/lib/puppet/application/lookup.rb +11 -1
  4. data/lib/puppet/context.rb +1 -1
  5. data/lib/puppet/functions/map.rb +1 -1
  6. data/lib/puppet/indirector/request.rb +6 -10
  7. data/lib/puppet/indirector/rest.rb +9 -9
  8. data/lib/puppet/network/http/connection.rb +8 -0
  9. data/lib/puppet/parser/compiler.rb +7 -0
  10. data/lib/puppet/parser/functions/new.rb +31 -46
  11. data/lib/puppet/parser/functions/return.rb +22 -1
  12. data/lib/puppet/provider/group/windows_adsi.rb +4 -7
  13. data/lib/puppet/provider/service/systemd.rb +1 -1
  14. data/lib/puppet/provider/user/aix.rb +1 -1
  15. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  16. data/lib/puppet/reference/configuration.rb +2 -0
  17. data/lib/puppet/resource/catalog.rb +1 -1
  18. data/lib/puppet/type/user.rb +34 -3
  19. data/lib/puppet/util/plist.rb +1 -1
  20. data/lib/puppet/util/reference.rb +1 -8
  21. data/lib/puppet/util/windows/adsi.rb +15 -18
  22. data/lib/puppet/util/windows/principal.rb +7 -6
  23. data/lib/puppet/util/windows/sid.rb +60 -7
  24. data/lib/puppet/version.rb +1 -1
  25. data/locales/ja/puppet.po +163 -140
  26. data/locales/puppet.pot +94 -76
  27. data/man/man5/puppet.conf.5 +91 -16
  28. data/man/man8/puppet-agent.8 +6 -2
  29. data/man/man8/puppet-apply.8 +2 -2
  30. data/man/man8/puppet-ca.8 +1 -1
  31. data/man/man8/puppet-catalog.8 +1 -1
  32. data/man/man8/puppet-cert.8 +1 -1
  33. data/man/man8/puppet-certificate.8 +1 -1
  34. data/man/man8/puppet-certificate_request.8 +1 -1
  35. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  36. data/man/man8/puppet-config.8 +1 -1
  37. data/man/man8/puppet-describe.8 +1 -1
  38. data/man/man8/puppet-device.8 +33 -11
  39. data/man/man8/puppet-doc.8 +1 -1
  40. data/man/man8/puppet-epp.8 +1 -1
  41. data/man/man8/puppet-facts.8 +1 -1
  42. data/man/man8/puppet-filebucket.8 +22 -4
  43. data/man/man8/puppet-generate.8 +1 -1
  44. data/man/man8/puppet-help.8 +1 -1
  45. data/man/man8/puppet-key.8 +1 -1
  46. data/man/man8/puppet-lookup.8 +1 -1
  47. data/man/man8/puppet-man.8 +1 -1
  48. data/man/man8/puppet-master.8 +1 -1
  49. data/man/man8/puppet-module.8 +11 -2
  50. data/man/man8/puppet-node.8 +1 -1
  51. data/man/man8/puppet-parser.8 +1 -1
  52. data/man/man8/puppet-plugin.8 +1 -1
  53. data/man/man8/puppet-report.8 +1 -1
  54. data/man/man8/puppet-resource.8 +1 -1
  55. data/man/man8/puppet-status.8 +1 -1
  56. data/man/man8/puppet.8 +2 -2
  57. data/spec/integration/application/lookup_spec.rb +21 -0
  58. data/spec/integration/util/windows/adsi_spec.rb +86 -1
  59. data/spec/integration/util/windows/principal_spec.rb +10 -1
  60. data/spec/unit/application/cert_spec.rb +17 -5
  61. data/spec/unit/application/device_spec.rb +96 -2
  62. data/spec/unit/indirector/rest_spec.rb +43 -0
  63. data/spec/unit/parser/compiler_spec.rb +8 -0
  64. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -22
  65. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  66. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  67. data/spec/unit/util/plist_spec.rb +3 -3
  68. data/spec/unit/util/windows/adsi_spec.rb +31 -27
  69. data/spec/unit/util/windows/sid_spec.rb +86 -15
  70. data/tasks/manpages.rake +1 -1
  71. metadata +3415 -3415
@@ -269,8 +269,10 @@ Copyright (c) 2011 Puppet Inc., LLC Licensed under the Apache 2.0 License
269
269
  end
270
270
  begin
271
271
  if subcommand == :destroy
272
+ raise _("Refusing to destroy all certs, provide an explicit list of certs to destroy") if hosts == :all
273
+
272
274
  signed_hosts = hosts - @ca.waiting?
273
- apply(@ca, :revoke, options.merge(:to => signed_hosts))
275
+ apply(@ca, :revoke, options.merge(:to => signed_hosts)) unless signed_hosts.empty?
274
276
  end
275
277
  apply(@ca, subcommand, options.merge(:to => hosts, :digest => @digest))
276
278
  rescue => detail
@@ -24,13 +24,16 @@ class Puppet::Application::Device < Puppet::Application
24
24
  end
25
25
 
26
26
  {
27
+ :apply => nil,
27
28
  :waitforcert => nil,
28
29
  :detailed_exitcodes => false,
29
30
  :verbose => false,
30
31
  :debug => false,
31
32
  :centrallogs => false,
32
33
  :setdest => false,
34
+ :resource => false,
33
35
  :target => nil,
36
+ :to_yaml => false,
34
37
  }.each do |opt,val|
35
38
  options[opt] = val
36
39
  end
@@ -40,12 +43,18 @@ class Puppet::Application::Device < Puppet::Application
40
43
 
41
44
  option("--centrallogging")
42
45
  option("--debug","-d")
46
+ option("--resource","-r")
47
+ option("--to_yaml","-y")
43
48
  option("--verbose","-v")
44
49
 
45
50
  option("--detailed-exitcodes") do |arg|
46
51
  options[:detailed_exitcodes] = true
47
52
  end
48
53
 
54
+ option("--apply MANIFEST") do |arg|
55
+ options[:apply] = arg.to_s
56
+ end
57
+
49
58
  option("--logdest DEST", "-l DEST") do |arg|
50
59
  handle_logdest_arg(arg)
51
60
  end
@@ -85,6 +94,7 @@ USAGE
85
94
  puppet device [-d|--debug] [--detailed-exitcodes] [--deviceconfig <file>]
86
95
  [-h|--help] [-l|--logdest syslog|<file>|console]
87
96
  [-v|--verbose] [-w|--waitforcert <seconds>]
97
+ [-a|--apply <file>] [-r|--resource <type> [name]]
88
98
  [-t|--target <device>] [--user=<user>] [-V|--version]
89
99
 
90
100
 
@@ -150,10 +160,21 @@ you can specify '--server <servername>' as an argument.
150
160
  appending nature of logging. It must be appended manually to make the content
151
161
  valid JSON.
152
162
 
163
+ * --apply:
164
+ Apply a manifest against a remote target. Target must be specified.
165
+
166
+ * --resource:
167
+ Displays a resource state as Puppet code, roughly equivalent to
168
+ `puppet resource`. Can be filterd by title. Requires --target be specified.
169
+
153
170
  * --target:
154
171
  Target a specific device/certificate in the device.conf. Doing so will perform a
155
172
  device run against only that device/certificate.
156
173
 
174
+ * --to_yaml:
175
+ Output found resources in yaml format, suitable to use with Hiera and
176
+ create_resources.
177
+
157
178
  * --user:
158
179
  The user to run as.
159
180
 
@@ -170,7 +191,7 @@ you can specify '--server <servername>' as an argument.
170
191
 
171
192
  EXAMPLE
172
193
  -------
173
- $ puppet device --server puppet.domain.com
194
+ $ puppet device --target remotehost --verbose
174
195
 
175
196
  AUTHOR
176
197
  ------
@@ -186,6 +207,20 @@ Licensed under the Apache 2.0 License
186
207
 
187
208
 
188
209
  def main
210
+ if options[:resource] and !options[:target]
211
+ Puppet.err _("resource command requires target")
212
+ exit(1)
213
+ end
214
+ unless options[:apply].nil?
215
+ if options[:target].nil?
216
+ Puppet.err _("missing argument: --target is required when using --apply")
217
+ exit(1)
218
+ end
219
+ unless File.file?(options[:apply])
220
+ Puppet.err _("%{file} does not exist, cannot apply") % { file: options[:apply] }
221
+ exit(1)
222
+ end
223
+ end
189
224
  vardir = Puppet[:vardir]
190
225
  confdir = Puppet[:confdir]
191
226
  certname = Puppet[:certname]
@@ -212,27 +247,61 @@ Licensed under the Apache 2.0 License
212
247
  # Handle nil scheme & port
213
248
  scheme = "#{device_url.scheme}://" if device_url.scheme
214
249
  port = ":#{device_url.port}" if device_url.port
215
- Puppet.info _("starting applying configuration to %{target} at %{scheme}%{url_host}%{port}%{url_path}") % { target: device.name, scheme: scheme, url_host: device_url.host, port: port, url_path: device_url.path }
216
250
 
217
251
  # override local $vardir and $certname
218
252
  Puppet[:confdir] = ::File.join(Puppet[:devicedir], device.name)
219
253
  Puppet[:vardir] = ::File.join(Puppet[:devicedir], device.name)
220
254
  Puppet[:certname] = device.name
221
255
 
222
- # this will reload and recompute default settings and create the devices sub vardir, or we hope so :-)
223
- Puppet.settings.use :main, :agent, :ssl
224
-
225
256
  # this init the device singleton, so that the facts terminus
226
257
  # and the various network_device provider can use it
227
258
  Puppet::Util::NetworkDevice.init(device)
228
259
 
229
- # ask for a ssl cert if needed, but at least
230
- # setup the ssl system for this device.
231
- setup_host
232
-
233
- require 'puppet/configurer'
234
- configurer = Puppet::Configurer.new
235
- configurer.run(:network_device => true, :pluginsync => Puppet::Configurer.should_pluginsync?)
260
+ if options[:resource]
261
+ type, name = parse_args(command_line.args)
262
+ Puppet.info _("retrieving resource: %{resource} from %{target} at %{scheme}%{url_host}%{port}%{url_path}") % { resource: type, target: device.name, scheme: scheme, url_host: device_url.host, port: port, url_path: device_url.path }
263
+
264
+ resources = find_resources(type, name)
265
+
266
+ if options[:to_yaml]
267
+ text = resources.map do |resource|
268
+ resource.prune_parameters(:parameters_to_include => @extra_params).to_hierayaml.force_encoding(Encoding.default_external)
269
+ end.join("\n")
270
+ text.prepend("#{type.downcase}:\n")
271
+ else
272
+ text = resources.map do |resource|
273
+ resource.prune_parameters(:parameters_to_include => @extra_params).to_manifest.force_encoding(Encoding.default_external)
274
+ end.join("\n")
275
+ end
276
+ (puts text)
277
+ elsif options[:apply]
278
+ # avoid reporting to server
279
+ Puppet::Transaction::Report.indirection.terminus_class = :yaml
280
+ Puppet::Resource::Catalog.indirection.cache_class = nil
281
+
282
+ require 'puppet/application/apply'
283
+ begin
284
+
285
+ Puppet[:node_terminus] = :plain
286
+ Puppet[:catalog_terminus] = :compiler
287
+ Puppet[:catalog_cache_terminus] = nil
288
+ Puppet[:facts_terminus] = :network_device
289
+ Puppet.override(:network_device => true) do
290
+ Puppet::Application::Apply.new(Puppet::Util::CommandLine.new('puppet', ["apply", options[:apply]])).run_command
291
+ end
292
+ end
293
+ else
294
+ Puppet.info _("starting applying configuration to %{target} at %{scheme}%{url_host}%{port}%{url_path}") % { target: device.name, scheme: scheme, url_host: device_url.host, port: port, url_path: device_url.path }
295
+ # this will reload and recompute default settings and create the devices sub vardir
296
+ Puppet.settings.use :main, :agent, :ssl
297
+ # ask for a ssl cert if needed, but at least
298
+ # setup the ssl system for this device.
299
+ setup_host
300
+
301
+ require 'puppet/configurer'
302
+ configurer = Puppet::Configurer.new
303
+ configurer.run(:network_device => true, :pluginsync => Puppet::Configurer.should_pluginsync?)
304
+ end
236
305
  rescue => detail
237
306
  Puppet.log_exception(detail)
238
307
  # If we rescued an error, then we return 1 as the exit code
@@ -258,6 +327,24 @@ Licensed under the Apache 2.0 License
258
327
  end
259
328
  end
260
329
 
330
+ def parse_args(args)
331
+ type = args.shift or raise _("You must specify the type to display")
332
+ Puppet::Type.type(type) or raise _("Could not find type %{type}") % { type: type }
333
+ name = args.shift
334
+
335
+ [type, name]
336
+ end
337
+
338
+ def find_resources(type, name)
339
+ key = [type, name].join('/')
340
+
341
+ if name
342
+ [ Puppet::Resource.indirection.find( key ) ]
343
+ else
344
+ Puppet::Resource.indirection.search( key, {} )
345
+ end
346
+ end
347
+
261
348
  def setup_host
262
349
  @host = Puppet::SSL::Host.new
263
350
  waitforcert = options[:waitforcert] || (Puppet[:onetime] ? 0 : Puppet[:waitforcert])
@@ -335,7 +335,17 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
335
335
  Puppet.settings[:facts_terminus] = 'facter'
336
336
  end
337
337
 
338
- node = Puppet::Node.indirection.find(node) unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
338
+ unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
339
+ ni = Puppet::Node.indirection
340
+ tc = ni.terminus_class
341
+ if tc == :plain || options[:compile]
342
+ node = ni.find(node)
343
+ else
344
+ ni.terminus_class = :plain
345
+ node = ni.find(node)
346
+ ni.terminus_class = tc
347
+ end
348
+ end
339
349
 
340
350
  fact_file = options[:fact_file]
341
351
 
@@ -52,7 +52,7 @@ class Puppet::Context
52
52
  elsif block
53
53
  block.call
54
54
  else
55
- raise UndefinedBindingError, _("no '%{name}' in %{table} at top of %{stack}") % { name: name, table: @table.inspect, stack: @stack.inspect }
55
+ raise UndefinedBindingError, _("Unable to lookup '%{name}'") % { name: name }
56
56
  end
57
57
  end
58
58
 
@@ -123,7 +123,7 @@ Puppet::Functions.create_function(:map) do
123
123
  begin
124
124
  loop do
125
125
  result << yield(index, enum.next)
126
- index = index +1
126
+ index = index + 1
127
127
  end
128
128
  rescue StopIteration
129
129
  end
@@ -197,23 +197,19 @@ class Puppet::Indirector::Request
197
197
  end
198
198
 
199
199
  # ... Fall back onto the default server.
200
- begin
201
- bound_server = Puppet.lookup(:server)
202
- rescue
200
+ bound_server = Puppet.lookup(:server) do
203
201
  if primary_server = Puppet.settings[:server_list][0]
204
- bound_server = primary_server[0]
202
+ primary_server[0]
205
203
  else
206
- bound_server = Puppet.settings[:server]
204
+ Puppet.settings[:server]
207
205
  end
208
206
  end
209
207
 
210
- begin
211
- bound_port = Puppet.lookup(:serverport)
212
- rescue
208
+ bound_port = Puppet.lookup(:serverport) do
213
209
  if primary_server = Puppet.settings[:server_list][0]
214
- bound_port = primary_server[1]
210
+ primary_server[1]
215
211
  else
216
- bound_port = Puppet.settings[:masterport]
212
+ Puppet.settings[:masterport]
217
213
  end
218
214
  end
219
215
  self.server = default_server || bound_server
@@ -57,9 +57,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
57
57
  if setting && setting != :server && Puppet.settings.set_by_config?(setting)
58
58
  Puppet.settings[setting]
59
59
  else
60
- begin
61
- Puppet.lookup(:server)
62
- rescue
60
+ server = Puppet.lookup(:server) do
63
61
  if primary_server = Puppet.settings[:server_list][0]
64
62
  Puppet.debug "Dynamically-bound server lookup failed; using first entry"
65
63
  primary_server[0]
@@ -69,6 +67,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
69
67
  Puppet.settings[setting]
70
68
  end
71
69
  end
70
+ server
72
71
  end
73
72
  end
74
73
 
@@ -84,22 +83,21 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
84
83
  (srv_setting && srv_setting != :server && Puppet.settings.set_by_config?(srv_setting))
85
84
  Puppet.settings[setting].to_i
86
85
  else
87
- begin
88
- Puppet.lookup(:serverport).to_i
89
- rescue
86
+ port = Puppet.lookup(:serverport) do
90
87
  if primary_server = Puppet.settings[:server_list][0]
91
88
  Puppet.debug "Dynamically-bound port lookup failed; using first entry"
92
89
 
93
90
  # Port might not be set, so we want to fallback in that
94
91
  # case. We know we don't need to use `setting` here, since
95
92
  # the default value of every port setting is `masterport`
96
- (primary_server[1] || Puppet.settings[:masterport]).to_i
93
+ (primary_server[1] || Puppet.settings[:masterport])
97
94
  else
98
95
  setting ||= :masterport
99
96
  Puppet.debug "Dynamically-bound port lookup failed; falling back to #{setting} setting"
100
- Puppet.settings[setting].to_i
97
+ Puppet.settings[setting]
101
98
  end
102
99
  end
100
+ port.to_i
103
101
  end
104
102
  end
105
103
 
@@ -263,7 +261,9 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
263
261
  def handle_response(request, response)
264
262
  server_version = response[Puppet::Network::HTTP::HEADER_PUPPET_VERSION]
265
263
  if server_version
266
- Puppet.push_context({:server_agent_version => server_version})
264
+ Puppet.lookup(:server_agent_version) do
265
+ Puppet.push_context(:server_agent_version => server_version)
266
+ end
267
267
  if SemanticPuppet::Version.parse(server_version).major < MAJOR_VERSION_JSON_DEFAULT &&
268
268
  Puppet[:preferred_serialization_format] != 'pson'
269
269
  #TRANSLATORS "PSON" should not be translated
@@ -5,6 +5,7 @@ require 'puppet/ssl/validator'
5
5
  require 'puppet/network/http'
6
6
  require 'uri'
7
7
  require 'date'
8
+ require 'time'
8
9
 
9
10
  module Puppet::Network::HTTP
10
11
 
@@ -297,7 +298,14 @@ module Puppet::Network::HTTP
297
298
  end
298
299
 
299
300
  def execute_request(connection, request)
301
+ start = Time.now
300
302
  connection.request(request)
303
+ rescue EOFError => e
304
+ elapsed = (Time.now - start).to_f.round(3)
305
+ uri = @site.addr + request.path.split('?')[0]
306
+ eof = EOFError.new(_('request %{uri} interrupted after %{elapsed} seconds') % {uri: uri, elapsed: elapsed})
307
+ eof.set_backtrace(e.backtrace) unless e.backtrace.empty?
308
+ raise eof
301
309
  end
302
310
 
303
311
  def with_connection(site, &block)
@@ -790,9 +790,16 @@ class Puppet::Parser::Compiler
790
790
  # Set the node's parameters into the top-scope as variables.
791
791
  def set_node_parameters
792
792
  node.parameters.each do |param, value|
793
+ # We don't want to set @topscope['environment'] from the parameters,
794
+ # instead we want to get that from the node's environment itself in
795
+ # case a custom node terminus has done any mucking about with
796
+ # node.parameters.
797
+ next if param.to_s == 'environment'
793
798
  # Ensure node does not leak Symbol instances in general
794
799
  @topscope[param.to_s] = value.is_a?(Symbol) ? value.to_s : value
795
800
  end
801
+ @topscope['environment'] = node.environment.name.to_s
802
+
796
803
  # These might be nil.
797
804
  catalog.client_version = node.parameters["clientversion"]
798
805
  catalog.server_version = node.parameters["serverversion"]
@@ -56,16 +56,14 @@ Would fail with an assertion error (since value is less than 0).
56
56
  The following sections show the arguments and conversion rules
57
57
  per data type built into the Puppet Type System.
58
58
 
59
- Conversion to Optional[T] and NotUndef[T]
60
- -----------------------------------------
59
+ ### Conversion to Optional[T] and NotUndef[T]
61
60
 
62
61
  Conversion to these data types is the same as a conversion to the type argument `T`.
63
62
  In the case of `Optional[T]` it is accepted that the argument to convert may be `undef`.
64
63
  It is however not acceptable to give other arguments (than `undef`) that cannot be
65
64
  converted to `T`.
66
65
 
67
- Conversion to Integer
68
- ---------------------
66
+ ### Conversion to Integer
69
67
 
70
68
  A new `Integer` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
71
69
  For conversion from `String` it is possible to specify the radix (base).
@@ -113,8 +111,7 @@ $a_number = Integer(true) # results in 1
113
111
  $a_number = Integer(-38, 10, true) # results in 38
114
112
  ```
115
113
 
116
- Conversion to Float
117
- -------------------
114
+ ### Conversion to Float
118
115
 
119
116
  A new `Float` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
120
117
  For conversion from `String` both float and integer formats are supported.
@@ -126,15 +123,13 @@ function Float.new(
126
123
  )
127
124
  ```
128
125
 
129
-
130
126
  * For an integer, the floating point fraction of `.0` is added to the value.
131
127
  * A `Boolean` `true` is converted to 1.0, and a `false` to 0.0
132
128
  * In `String` format, integer prefixes for hex and binary are understood (but not octal since
133
129
  floating point in string format may start with a '0').
134
130
  * When `abs` is set to `true`, the result will be an absolute floating point value.
135
131
 
136
- Conversion to Numeric
137
- ---------------------
132
+ ### Conversion to Numeric
138
133
 
139
134
  A new `Integer` or `Float` can be created from `Integer`, `Float`, `Boolean` and
140
135
  `String` values.
@@ -163,8 +158,7 @@ $a_number = Numeric(-42.3, true) # results in 42.3
163
158
  $a_number = Numeric(-42, true) # results in 42
164
159
  ```
165
160
 
166
- Conversion to Timespan
167
- -------------------
161
+ ### Conversion to Timespan
168
162
 
169
163
  A new `Timespan` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
170
164
 
@@ -281,8 +275,7 @@ $duration = Timespan('10:03.5', '%M:%S.%L') # 10 minutes, 3 seconds, and 5 milli
281
275
  $duration = Timespan('10:03.5', '%M:%S.%N') # 10 minutes, 3 seconds, and 5 nano-seconds
282
276
  ```
283
277
 
284
- Conversion to Timestamp
285
- -------------------
278
+ ### Conversion to Timestamp
286
279
 
287
280
  A new `Timestamp` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
288
281
 
@@ -475,8 +468,8 @@ $ts = Timestamp('2016-08-24T12:13:14', default, 'PST') # 2016-08-24 20:13:14.0
475
468
 
476
469
  ```
477
470
 
478
- Conversion to Type
479
- ------------------
471
+ ### Conversion to Type
472
+
480
473
  A new `Type` can be create from its `String` representation.
481
474
 
482
475
  **Example:** Creating a type from a string
@@ -485,8 +478,7 @@ A new `Type` can be create from its `String` representation.
485
478
  $t = Type.new('Integer[10]')
486
479
  ```
487
480
 
488
- Conversion to String
489
- --------------------
481
+ ### Conversion to String
490
482
 
491
483
  Conversion to `String` is the most comprehensive conversion as there are many
492
484
  use cases where a string representation is wanted. The defaults for the many options
@@ -529,7 +521,7 @@ included in a string format.
529
521
  Note that all data type supports the formats `s` and `p` with the meaning "default string representation" and
530
522
  "default programmatic string representation" (which for example means that a String is quoted in 'p' format).
531
523
 
532
- ### Signatures of String conversion
524
+ #### Signatures of String conversion
533
525
 
534
526
  ```puppet
535
527
  type Format = Pattern[/^%([\s\+\-#0\[\{<\(\|]*)([1-9][0-9]*)?(?:\.([0-9]+))?([a-zA-Z])/]
@@ -587,7 +579,7 @@ $str = String([1,2,3], $formats) # produces '(0x1, 0x2, 0x3)'
587
579
  The given formats are merged with the default formats, and matching of values to convert against format is based on
588
580
  the specificity of the mapped type; for example, different formats can be used for short and long arrays.
589
581
 
590
- ### Integer to String
582
+ #### Integer to String
591
583
 
592
584
  | Format | Integer Formats
593
585
  | ------ | ---------------
@@ -602,7 +594,7 @@ the specificity of the mapped type; for example, different formats can be used f
602
594
 
603
595
  Defaults to `d`.
604
596
 
605
- ### Float to String
597
+ #### Float to String
606
598
 
607
599
  | Format | Float formats
608
600
  | ------ | -------------
@@ -616,7 +608,7 @@ Defaults to `d`.
616
608
 
617
609
  Defaults to `p`.
618
610
 
619
- ### String to String
611
+ #### String to String
620
612
 
621
613
  | Format | String
622
614
  | ------ | ------
@@ -630,7 +622,7 @@ Defaults to `p`.
630
622
 
631
623
  Defaults to `s` at top level and `p` inside array or hash.
632
624
 
633
- ### Boolean to String
625
+ #### Boolean to String
634
626
 
635
627
  | Format | Boolean Formats
636
628
  | ---- | -------------------
@@ -641,14 +633,14 @@ Defaults to `s` at top level and `p` inside array or hash.
641
633
  | s | String 'true' / 'false'.
642
634
  | p | String 'true' / 'false'.
643
635
 
644
- ### Regexp to String
636
+ #### Regexp to String
645
637
 
646
638
  | Format | Regexp Formats
647
639
  | ---- | --------------
648
640
  | s | No delimiters, quoted if alternative flag `#` is used.
649
641
  | p | Delimiters `/ /`.
650
642
 
651
- ### Undef to String
643
+ #### Undef to String
652
644
 
653
645
  | Format | Undef formats
654
646
  | ------ | -------------
@@ -661,7 +653,7 @@ Defaults to `s` at top level and `p` inside array or hash.
661
653
  | V | String 'N/A'.
662
654
  | u | String 'undef', or 'undefined' if alternative `#` flag is used.
663
655
 
664
- ### Default value to String
656
+ #### Default value to String
665
657
 
666
658
  | Format | Default formats
667
659
  | ------ | ---------------
@@ -669,7 +661,7 @@ Defaults to `s` at top level and `p` inside array or hash.
669
661
  | s | Same as d.
670
662
  | p | Same as d.
671
663
 
672
- ### Binary value to String
664
+ #### Binary value to String
673
665
 
674
666
  | Format | Default formats
675
667
  | ------ | ---------------
@@ -686,7 +678,7 @@ Defaults to `s` at top level and `p` inside array or hash.
686
678
  as hex escaped characters on the form `\\xHH` where `H` is a hex digit.
687
679
  * The width and precision values are applied to the text part only in `%p` format.
688
680
 
689
- ### Array & Tuple to String
681
+ #### Array & Tuple to String
690
682
 
691
683
  | Format | Array/Tuple Formats
692
684
  | ------ | -------------
@@ -701,7 +693,7 @@ The alternate form flag `#` will cause indentation of nested array or hash conta
701
693
  it is taken as the maximum allowed length of a sequence of elements (not including delimiters). If this max length
702
694
  is exceeded, each element will be indented.
703
695
 
704
- ### Hash & Struct to String
696
+ #### Hash & Struct to String
705
697
 
706
698
  | Format | Hash/Struct Formats
707
699
  | ------ | -------------
@@ -715,14 +707,14 @@ more information about options.
715
707
 
716
708
  The alternate form flag `#` will format each hash key/value entry indented on a separate line.
717
709
 
718
- ### Type to String
710
+ #### Type to String
719
711
 
720
712
  | Format | Array/Tuple Formats
721
713
  | ------ | -------------
722
714
  | s | The same as `p`, quoted if alternative flag `#` is used.
723
715
  | p | Outputs the type in string form as specified by the Puppet Language.
724
716
 
725
- ### Flags
717
+ #### Flags
726
718
 
727
719
  | Flag | Effect
728
720
  | ------ | ------
@@ -733,8 +725,7 @@ The alternate form flag `#` will format each hash key/value entry indented on a
733
725
  | 0 | Pad with 0 instead of space for widths larger than value.
734
726
  | <[({\| | Defines an enclosing pair <> [] () {} or \| \| when used with a container type.
735
727
 
736
- Conversion to Boolean
737
- ---
728
+ ### Conversion to Boolean
738
729
 
739
730
  Accepts a single value as argument:
740
731
 
@@ -745,8 +736,7 @@ Accepts a single value as argument:
745
736
  * `false` if 'false', 'no', 'n' (case independent compare)
746
737
  * Boolean is already boolean and is simply returned
747
738
 
748
- Conversion to Array and Tuple
749
- ---
739
+ ### Conversion to Array and Tuple
750
740
 
751
741
  When given a single value as argument:
752
742
 
@@ -771,8 +761,7 @@ $arr = Array($value, true)
771
761
  Conversion to a `Tuple` works exactly as conversion to an `Array`, only that the constructed array is
772
762
  asserted against the given tuple type.
773
763
 
774
- Conversion to Hash and Struct
775
- ---
764
+ ### Conversion to Hash and Struct
776
765
 
777
766
  Accepts a single value as argument:
778
767
 
@@ -811,8 +800,8 @@ Would notice the hash `{a => {b => {x => wine}}, b => {y => wine}}`
811
800
  Conversion to a `Struct` works exactly as conversion to a `Hash`, only that the constructed hash is
812
801
  asserted against the given struct type.
813
802
 
814
- Conversion to a Regexp
815
- ---
803
+ ### Conversion to a Regexp
804
+
816
805
  A `String` can be converted into a `Regexp`
817
806
 
818
807
  **Example**: Converting a String into a Regexp
@@ -824,8 +813,7 @@ if('foo.com' =~ $r) {
824
813
  }
825
814
  ```
826
815
 
827
- Creating a SemVer
828
- ---
816
+ ### Creating a SemVer
829
817
 
830
818
  A SemVer object represents a single [Semantic Version](http://semver.org/).
831
819
  It can be created from a String, individual values for its parts, or a hash specifying the value per part.
@@ -874,8 +862,7 @@ notice(SemVer('2.3.4') =~ $t) # false
874
862
  notice(SemVer('3.4.5') =~ $t) # true
875
863
  ```
876
864
 
877
- Creating a SemVerRange
878
- ---
865
+ ### Creating a SemVerRange
879
866
 
880
867
  A `SemVerRange` object represents a range of `SemVer`. It can be created from
881
868
  a `String`, or from two `SemVer` instances, where either end can be given as
@@ -909,10 +896,9 @@ function SemVerRange.new(
909
896
  )
910
897
  ```
911
898
 
912
- For examples of `SemVerRange` use see "Creating a SemVer"
899
+ For examples of `SemVerRange` use, see "Creating a SemVer".
913
900
 
914
- Creating a Binary
915
- ---
901
+ ### Creating a Binary
916
902
 
917
903
  A `Binary` object represents a sequence of bytes and it can be created from a String in Base64 format,
918
904
  an Array containing byte values. A Binary can also be created from a Hash containing the value to convert to
@@ -932,7 +918,6 @@ function Binary.new(
932
918
  Optional[Base64Format] $format
933
919
  )
934
920
 
935
-
936
921
  function Binary.new(
937
922
  Array[ByteInteger] $byte_array
938
923
  }