Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / REFERENCE.md
1 # Reference
2 <!-- DO NOT EDIT: This document was generated by Puppet Strings -->
3
4 ## Table of Contents
5
6 **Classes**
7
8 * [`stdlib`](#stdlib): This module manages stdlib.
9 * [`stdlib::stages`](#stdlibstages): This class manages a standard set of run stages for Puppet. It is managed by
10 the stdlib class, and should not be declared independently.
11
12 **Resource types**
13
14 * [`anchor`](#anchor): A simple resource type intended to be used as an anchor in a composite class.
15 * [`file_line`](#file_line): Ensures that a given line is contained within a file.
16
17 **Functions**
18
19 * [`abs`](#abs): **Deprecated:** Returns the absolute value of a number
20 * [`any2array`](#any2array): This converts any object to an array containing that object.
21 * [`any2bool`](#any2bool): Converts 'anything' to a boolean.
22 * [`assert_private`](#assert_private): Sets the current class or definition as private.
23 * [`base64`](#base64): Base64 encode or decode a string based on the command and the string submitted
24 * [`basename`](#basename): Strips directory (and optional suffix) from a filename
25 * [`bool2num`](#bool2num): Converts a boolean to a number.
26 * [`bool2str`](#bool2str): Converts a boolean to a string using optionally supplied arguments.
27 * [`camelcase`](#camelcase): **Deprecated** Converts the case of a string or all strings in an array to camel case.
28 * [`capitalize`](#capitalize): **Deprecated** Capitalizes the first letter of a string or array of strings.
29 * [`ceiling`](#ceiling): **Deprecated** Returns the smallest integer greater or equal to the argument.
30 * [`chomp`](#chomp): **Deprecated** Removes the record separator from the end of a string or an array of strings.
31 * [`chop`](#chop): **Deprecated** Returns a new string with the last character removed.
32 * [`clamp`](#clamp): Keeps value within the range [Min, X, Max] by sort based on integer value
33 (parameter order doesn't matter).
34 * [`concat`](#concat): Appends the contents of multiple arrays into array 1.
35 * [`convert_base`](#convert_base): Converts a given integer or base 10 string representing an integer to a
36 specified base, as a string.
37 * [`count`](#count): Counts the number of elements in array.
38 * [`deep_merge`](#deep_merge): Recursively merges two or more hashes together and returns the resulting hash.
39 * [`defined_with_params`](#defined_with_params): Takes a resource reference and an optional hash of attributes.
40 * [`delete`](#delete): Deletes all instances of a given element from an array, substring from a
41 string, or key from a hash.
42 * [`delete_at`](#delete_at): Deletes a determined indexed value from an array.
43 * [`delete_regex`](#delete_regex): Deletes all instances of a given element that match a regular expression
44 from an array or key from a hash.
45 * [`delete_undef_values`](#delete_undef_values): Returns a copy of input hash or array with all undefs deleted.
46 * [`delete_values`](#delete_values): Deletes all instances of a given value from a hash.
47 * [`deprecation`](#deprecation): Function to print deprecation warnings (this is the 3.X version of it).
48 * [`deprecation`](#deprecation): Function to print deprecation warnings, Logs a warning once for a given key.  The uniqueness key - can appear once. The msg is the message te
49 * [`difference`](#difference): This function returns the difference between two arrays.
50 * [`dig`](#dig): **DEPRECATED** Retrieves a value within multiple layers of hashes and arrays via an
51 array of keys containing a path.
52 * [`dig44`](#dig44): **DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value
53 or the default value if nothing was found.
54 * [`dirname`](#dirname): Returns the dirname of a path.
55 * [`dos2unix`](#dos2unix): Returns the Unix version of the given string.
56 * [`downcase`](#downcase): **Deprecated:** Converts the case of a string or all strings in an array to lower case.
57 * [`empty`](#empty): **Deprecated:** Returns true if the variable is empty.
58 * [`enclose_ipv6`](#enclose_ipv6): Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
59 * [`ensure_packages`](#ensure_packages): Takes a list of packages and only installs them if they don't already exist.
60 * [`ensure_resource`](#ensure_resource): Takes a resource type, title, and a list of attributes that describe a
61 resource.
62 * [`ensure_resources`](#ensure_resources): Takes a resource type, title (only hash), and a list of attributes that describe a
63 resource.
64 * [`fact`](#fact): Digs into the facts hash using dot-notation
65 * [`flatten`](#flatten): This function flattens any deeply nested arrays and returns a single flat array
66 as a result.
67 * [`floor`](#floor): Returns the largest integer less or equal to the argument.
68 * [`fqdn_rand_string`](#fqdn_rand_string): Generates a random alphanumeric string. Combining the `$fqdn` fact and an
69 optional seed for repeatable randomness.
70 * [`fqdn_rotate`](#fqdn_rotate): Rotates an array or string a random number of times, combining the `$fqdn` fact
71 and an optional seed for repeatable randomness.
72 * [`fqdn_uuid`](#fqdn_uuid): Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based
73 on an FQDN string under the DNS namespace
74 * [`get_module_path`](#get_module_path): Returns the absolute path of the specified module for the current
75 environment.
76 * [`getparam`](#getparam): Returns the value of a resource's parameter.
77 * [`getvar`](#getvar): Lookup a variable in a given namespace.
78 * [`glob`](#glob): Uses same patterns as Dir#glob.
79 * [`grep`](#grep): This function searches through an array and returns any elements that match
80 the provided regular expression.
81 * [`has_interface_with`](#has_interface_with): Returns boolean based on kind and value.
82 * [`has_ip_address`](#has_ip_address): Returns true if the client has the requested IP address on some interface.
83 * [`has_ip_network`](#has_ip_network): Returns true if the client has an IP address within the requested network.
84 * [`has_key`](#has_key): **Deprecated:** Determine if a hash has a certain key value.
85 * [`hash`](#hash): **Deprecated:** This function converts an array into a hash.
86 * [`intersection`](#intersection): This function returns an array of the intersection of two.
87 * [`is_a`](#is_a): Boolean check to determine whether a variable is of a given data type.
88 This is equivalent to the `=~` type checks.
89 * [`is_absolute_path`](#is_absolute_path): **Deprecated:** Returns boolean true if the string represents an absolute path in the filesystem.
90 * [`is_absolute_path`](#is_absolute_path): Wrapper that calls the Puppet 3.x funtion of the same name.
91 * [`is_array`](#is_array): Wrapper that calls the Puppet 3.x funtion of the same name.
92 * [`is_array`](#is_array): **Deprecated:** Returns true if the variable passed to this function is an array.
93 * [`is_bool`](#is_bool): Wrapper that calls the Puppet 3.x funtion of the same name.
94 * [`is_bool`](#is_bool): **Deprecated:** Returns true if the variable passed to this function is a boolean.
95 * [`is_domain_name`](#is_domain_name): **Deprecated:** Returns true if the string passed to this function is
96 a syntactically correct domain name.
97 * [`is_email_address`](#is_email_address): **Deprecated:** Returns true if the string passed to this function is a valid email address.
98 * [`is_float`](#is_float): Wrapper that calls the Puppet 3.x funtion of the same name.
99 * [`is_float`](#is_float): **Deprecated:** Returns true if the variable passed to this function is a float.
100 * [`is_function_available`](#is_function_available): **Deprecated:** Determines whether the Puppet runtime has access to a function by that name.
101 * [`is_hash`](#is_hash): **Deprecated:** Returns true if the variable passed to this function is a hash.
102 * [`is_integer`](#is_integer): **Deprecated:** Returns true if the variable passed to this function is an Integer or
103 a decimal (base 10) integer in String form.
104 * [`is_ip_address`](#is_ip_address): **Deprecated:** Returns true if the string passed to this function is a valid IP address.
105 * [`is_ip_address`](#is_ip_address): Wrapper that calls the Puppet 3.x funtion of the same name.
106 * [`is_ipv4_address`](#is_ipv4_address): Wrapper that calls the Puppet 3.x funtion of the same name.
107 * [`is_ipv4_address`](#is_ipv4_address): **Deprecated:** Returns true if the string passed to this function is a valid IPv4 address.
108 * [`is_ipv6_address`](#is_ipv6_address): **Deprecated:** Returns true if the string passed to this function is a valid IPv6 address.
109 * [`is_ipv6_address`](#is_ipv6_address): Wrapper that calls the Puppet 3.x funtion of the same name.
110 * [`is_mac_address`](#is_mac_address): **Deprecated:** Returns true if the string passed to this function is a valid mac address.
111 * [`is_numeric`](#is_numeric): Wrapper that calls the Puppet 3.x funtion of the same name.
112 * [`is_numeric`](#is_numeric): **Deprecated:** Returns true if the given value is numeric.
113 * [`is_string`](#is_string): **Deprecated:** Returns true if the variable passed to this function is a string.
114 * [`is_string`](#is_string): Wrapper that calls the Puppet 3.x funtion of the same name.
115 * [`join`](#join): **Deprecated:** This function joins an array into a string using a separator.
116 * [`join_keys_to_values`](#join_keys_to_values): This function joins each key of a hash to that key's corresponding value with a
117 separator.
118 * [`keys`](#keys): **Deprecated:** Returns the keys of a hash as an array.
119 * [`length`](#length): **Deprecated:** A function to eventually replace the old size() function for stdlib
120 * [`load_module_metadata`](#load_module_metadata): This function loads the metadata of a given module.
121 * [`loadjson`](#loadjson): Load a JSON file containing an array, string, or hash, and return the data
122 in the corresponding native data type.
123 * [`loadyaml`](#loadyaml): Load a YAML file containing an array, string, or hash, and return the data
124 in the corresponding native data type.
125 * [`lstrip`](#lstrip): **Deprecated:** Strips leading spaces to the left of a string.
126 * [`max`](#max): **Deprecated:** Returns the highest value of all arguments.
127 * [`member`](#member): This function determines if a variable is a member of an array.
128 * [`merge`](#merge): Merges two or more hashes together and returns the resulting hash.
129 * [`merge`](#merge): Merges two or more hashes together or hashes resulting from iteration, and returns
130 the resulting hash.
131 * [`min`](#min): **Deprecated:** Returns the lowest value of all arguments.
132 * [`num2bool`](#num2bool): This function converts a number or a string representation of a number into a
133 true boolean.
134 * [`os_version_gte`](#os_version_gte): Checks if the OS version is at least a certain version.
135 * [`parsejson`](#parsejson): This function accepts JSON as a string and converts it into the correct
136 Puppet structure.
137 * [`parseyaml`](#parseyaml): This function accepts YAML as a string and converts it into the correct
138 Puppet structure.
139 * [`pick`](#pick): This function is similar to a coalesce function in SQL in that it will return
140 the first value in a list of values that is not undefined or an empty string.
141 * [`pick_default`](#pick_default): This function will return the first value in a list of values that is not undefined or an empty string.
142 * [`prefix`](#prefix): This function applies a prefix to all elements in an array or a hash.
143 * [`private`](#private): **Deprecated:** Sets the current class or definition as private.
144 Calling the class or definition from outside the current module will fail.
145 * [`pry`](#pry): This function invokes a pry debugging session in the current scope object.
146 * [`pw_hash`](#pw_hash): Hashes a password using the crypt function. Provides a hash usable
147 on most POSIX systems.
148 * [`range`](#range): When given range in the form of (start, stop) it will extrapolate a range as
149 an array.
150 * [`regexpescape`](#regexpescape): Regexp escape a string or array of strings.
151 Requires either a single string or an array as an input.
152 * [`reject`](#reject): This function searches through an array and rejects all elements that match
153 the provided regular expression.
154 * [`reverse`](#reverse): Reverses the order of a string or array.
155 * [`round`](#round): Rounds a number to the nearest integer
156 * [`rstrip`](#rstrip): Strips leading spaces to the right of the string.
157 * [`seeded_rand`](#seeded_rand): Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness.
158 * [`seeded_rand_string`](#seeded_rand_string): Generates a consistent random string of specific length based on provided seed.
159 * [`shell_escape`](#shell_escape): Escapes a string so that it can be safely used in a Bourne shell command line.
160 * [`shell_join`](#shell_join): Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are then joined together
161 * [`shell_split`](#shell_split): Splits a string into an array of tokens in the same way the Bourne shell does.
162 * [`shuffle`](#shuffle): @summary  Randomizes the order of a string or array elements.
163 * [`size`](#size): Returns the number of elements in a string, an array or a hash
164 * [`sort`](#sort): Sorts strings and arrays lexically.
165 * [`sprintf_hash`](#sprintf_hash): Uses sprintf with named references.
166 * [`squeeze`](#squeeze): Returns a new string where runs of the same character that occur in this set are replaced by a single character.
167 * [`stdlib::extname`](#stdlibextname): Returns the Extension (the Portion of Filename in Path starting from the
168 last Period).
169 * [`stdlib::ip_in_range`](#stdlibip_in_range): Returns true if the ipaddress is within the given CIDRs
170 * [`str2bool`](#str2bool): This converts a string to a boolean.
171 * [`str2saltedsha512`](#str2saltedsha512): This converts a string to a salted-SHA512 password hash (which is used for
172 OS X versions >= 10.7).
173 * [`strftime`](#strftime): This function returns formatted time.
174 * [`strip`](#strip): This function removes leading and trailing whitespace from a string or from
175 every string inside an array.
176 * [`suffix`](#suffix): This function applies a suffix to all elements in an array, or to the keys
177 in a hash.
178 * [`swapcase`](#swapcase): This function will swap the existing case of a string.
179 * [`time`](#time): This function will return the current time since epoch as an integer.
180 * [`to_bytes`](#to_bytes): Converts the argument into bytes, for example 4 kB becomes 4096.
181 * [`to_json`](#to_json): Convert a data structure and output to JSON
182 * [`to_json_pretty`](#to_json_pretty): Convert data structure and output to pretty JSON
183 * [`to_yaml`](#to_yaml): Convert a data structure and output it as YAML
184 * [`try_get_value`](#try_get_value): **DEPRECATED:** this function is deprecated, please use dig() instead.
185 * [`type`](#type): **DEPRECATED:** This function will cease to function on Puppet 4;
186 * [`type3x`](#type3x): **DEPRECATED:** This function will be removed when Puppet 3 support is dropped; please migrate to the new parser's typing system.
187 * [`type_of`](#type_of): Returns the type of the passed value.
188 * [`union`](#union): This function returns a union of two or more arrays.
189 * [`unique`](#unique): This function will remove duplicates from strings and arrays.
190 * [`unix2dos`](#unix2dos): Returns the DOS version of the given string.
191 * [`upcase`](#upcase): Converts a string or an array of strings to uppercase.
192 * [`uriescape`](#uriescape): Urlencodes a string or array of strings.
193 Requires either a single string or an array as an input.
194 * [`validate_absolute_path`](#validate_absolute_path): Validate the string represents an absolute path in the filesystem.  This function works
195 for windows and unix style paths.
196 * [`validate_absolute_path`](#validate_absolute_path): Validate the string represents an absolute path in the filesystem.
197 * [`validate_array`](#validate_array): Validate the passed value represents an array.
198 * [`validate_array`](#validate_array): Validate that all passed values are array data structures. Abort catalog
199 compilation if any value fails this check.
200 * [`validate_augeas`](#validate_augeas): Perform validation of a string using an Augeas lens
201 * [`validate_bool`](#validate_bool): Validate that all passed values are either true or false. Abort catalog
202 compilation if any value fails this check.
203 * [`validate_bool`](#validate_bool): Validate the passed value represents a boolean.
204 * [`validate_cmd`](#validate_cmd): Perform validation of a string with an external command.
205 * [`validate_domain_name`](#validate_domain_name): Validate that all values passed are syntactically correct domain names.
206 Fail compilation if any value fails this check.
207 * [`validate_email_address`](#validate_email_address): Validate that all values passed are valid email addresses.
208 Fail compilation if any value fails this check.
209 * [`validate_hash`](#validate_hash): Validate the passed value represents a hash.
210 * [`validate_hash`](#validate_hash): Validate that all passed values are hash data structures. Abort catalog
211 compilation if any value fails this check.
212 * [`validate_integer`](#validate_integer): Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail.
213 * [`validate_integer`](#validate_integer): Validate the passed value represents an integer.
214 * [`validate_ip_address`](#validate_ip_address): Validate the passed value represents an ip_address.
215 * [`validate_ip_address`](#validate_ip_address): Validate that all values passed are valid IP addresses,
216 regardless they are IPv4 or IPv6
217 Fail compilation if any value fails this check.
218 * [`validate_ipv4_address`](#validate_ipv4_address): Validate the passed value represents an ipv4_address.
219 * [`validate_ipv4_address`](#validate_ipv4_address): Validate that all values passed are valid IPv4 addresses.
220 Fail compilation if any value fails this check.
221 * [`validate_ipv6_address`](#validate_ipv6_address): Validate the passed value represents an ipv6_address.
222 * [`validate_ipv6_address`](#validate_ipv6_address): Validate that all values passed are valid IPv6 addresses.
223 Fail compilation if any value fails this check.
224 * [`validate_legacy`](#validate_legacy): Validate a value against both the target_type (new) and the previous_validation function (old).
225 * [`validate_numeric`](#validate_numeric): Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail.
226 * [`validate_numeric`](#validate_numeric): Validate the passed value represents a numeric value.
227 * [`validate_re`](#validate_re): Perform simple validation of a string against one or more regular
228 expressions.
229 * [`validate_re`](#validate_re): Perform validation of a string against one or more regular
230 expressions.
231 * [`validate_slength`](#validate_slength): Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument.
232 An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings,
233 and if arg 2 and arg 3 are not convertable to a number.
234 * [`validate_slength`](#validate_slength): Validate that a passed string has length less/equal with the passed value
235 * [`validate_string`](#validate_string): Validate that all passed values are string data structures.
236 * [`validate_string`](#validate_string): Validate that all passed values are string data structures
237 * [`validate_x509_rsa_key_pair`](#validate_x509_rsa_key_pair): Validates a PEM-formatted X.509 certificate and RSA private key using
238 OpenSSL. Verifies that the certficate's signature was created from the
239 supplied key.
240 * [`values`](#values): When given a hash this function will return the values of that hash.
241 * [`values_at`](#values_at): Finds value inside an array based on location.
242 * [`zip`](#zip): Takes one element from first array and merges corresponding elements from second array.
243
244 **Data types**
245
246 * [`Stdlib::Absolutepath`](#stdlibabsolutepath): A strict absolutepath type
247 * [`Stdlib::Base32`](#stdlibbase32): Type to match base32 String
248 * [`Stdlib::Base64`](#stdlibbase64): Type to match base64 String
249 * [`Stdlib::Compat::Absolute_path`](#stdlibcompatabsolute_path): Emulate the is_absolute_path and validate_absolute_path functions  The first pattern is originally from is_absolute_path, which had it from 2
250 * [`Stdlib::Compat::Array`](#stdlibcompatarray): Emulate the is_array and validate_array functions
251 * [`Stdlib::Compat::Bool`](#stdlibcompatbool): Emulate the is_bool and validate_bool functions
252 * [`Stdlib::Compat::Float`](#stdlibcompatfloat): Emulate the is_float function The regex is what's currently used in is_float To keep your development moving forward, you can also add a depr
253 * [`Stdlib::Compat::Hash`](#stdlibcompathash): Emulate the is_hash and validate_hash functions
254 * [`Stdlib::Compat::Integer`](#stdlibcompatinteger): Emulate the is_integer and validate_integer functions The regex is what's currently used in is_integer validate_numeric also allows range che
255 * [`Stdlib::Compat::Ip_address`](#stdlibcompatip_address): 
256 * [`Stdlib::Compat::Ipv4`](#stdlibcompatipv4): Emulate the validate_ipv4_address and is_ipv4_address functions
257 * [`Stdlib::Compat::Ipv6`](#stdlibcompatipv6): 
258 * [`Stdlib::Compat::Numeric`](#stdlibcompatnumeric): Emulate the is_numeric and validate_numeric functions The regex is what's currently used in is_numeric validate_numeric also allows range che
259 * [`Stdlib::Compat::String`](#stdlibcompatstring): Emulate the is_string and validate_string functions
260 * [`Stdlib::Ensure::Service`](#stdlibensureservice): 
261 * [`Stdlib::Filemode`](#stdlibfilemode): See `man chmod.1` for the regular expression for symbolic mode
262 * [`Stdlib::Filesource`](#stdlibfilesource): Validate the source parameter on file types
263 * [`Stdlib::Fqdn`](#stdlibfqdn): 
264 * [`Stdlib::HTTPSUrl`](#stdlibhttpsurl): 
265 * [`Stdlib::HTTPUrl`](#stdlibhttpurl): 
266 * [`Stdlib::Host`](#stdlibhost): 
267 * [`Stdlib::IP::Address`](#stdlibipaddress): 
268 * [`Stdlib::IP::Address::Nosubnet`](#stdlibipaddressnosubnet): 
269 * [`Stdlib::IP::Address::V4`](#stdlibipaddressv4): 
270 * [`Stdlib::IP::Address::V4::CIDR`](#stdlibipaddressv4cidr): 
271 * [`Stdlib::IP::Address::V4::Nosubnet`](#stdlibipaddressv4nosubnet): 
272 * [`Stdlib::IP::Address::V6`](#stdlibipaddressv6): 
273 * [`Stdlib::IP::Address::V6::Alternative`](#stdlibipaddressv6alternative): 
274 * [`Stdlib::IP::Address::V6::CIDR`](#stdlibipaddressv6cidr): 
275 * [`Stdlib::IP::Address::V6::Compressed`](#stdlibipaddressv6compressed): 
276 * [`Stdlib::IP::Address::V6::Full`](#stdlibipaddressv6full): 
277 * [`Stdlib::IP::Address::V6::Nosubnet`](#stdlibipaddressv6nosubnet): 
278 * [`Stdlib::IP::Address::V6::Nosubnet::Alternative`](#stdlibipaddressv6nosubnetalternative): 
279 * [`Stdlib::IP::Address::V6::Nosubnet::Compressed`](#stdlibipaddressv6nosubnetcompressed): 
280 * [`Stdlib::IP::Address::V6::Nosubnet::Full`](#stdlibipaddressv6nosubnetfull): 
281 * [`Stdlib::MAC`](#stdlibmac): A type for a MAC address
282 * [`Stdlib::ObjectStore`](#stdlibobjectstore): 
283 * [`Stdlib::ObjectStore::GSUri`](#stdlibobjectstoregsuri): 
284 * [`Stdlib::ObjectStore::S3Uri`](#stdlibobjectstores3uri): 
285 * [`Stdlib::Port`](#stdlibport): 
286 * [`Stdlib::Port::Privileged`](#stdlibportprivileged): 
287 * [`Stdlib::Port::Unprivileged`](#stdlibportunprivileged): 
288 * [`Stdlib::Syslogfacility`](#stdlibsyslogfacility): 
289 * [`Stdlib::Unixpath`](#stdlibunixpath): this regex rejects any path component that does not start with "/" or is NUL
290 * [`Stdlib::Windowspath`](#stdlibwindowspath): 
291 * [`Stdlib::Yes_no`](#stdlibyes_no): 
292
293 ## Classes
294
295 ### stdlib
296
297 Most of stdlib's features are automatically loaded by Puppet, but this class should be
298 declared in order to use the standardized run stages.
299
300 Declares all other classes in the stdlib module. Currently, this consists
301 of stdlib::stages.
302
303 ### stdlib::stages
304
305 Declares various run-stages for deploying infrastructure,
306 language runtimes, and application layers.
307
308 The high level stages are (in order):
309  * setup
310  * main
311  * runtime
312  * setup_infra
313  * deploy_infra
314  * setup_app
315  * deploy_app
316  * deploy
317
318 #### Examples
319
320 ##### 
321
322 ```puppet
323 node default {
324   include ::stdlib
325   class { java: stage => 'runtime' }
326 }
327 ```
328
329 ## Resource types
330
331 ### anchor
332
333 In Puppet 2.6, when a class declares another class, the resources in the
334 interior class are not contained by the exterior class. This interacts badly
335 with the pattern of composing complex modules from smaller classes, as it
336 makes it impossible for end users to specify order relationships between the
337 exterior class and other modules.
338
339 The anchor type lets you work around this. By sandwiching any interior
340 classes between two no-op resources that _are_ contained by the exterior
341 class, you can ensure that all resources in the module are contained.
342
343 ```
344 class ntp {
345   # These classes will have the correct order relationship with each
346   # other. However, without anchors, they won't have any order
347   # relationship to Class['ntp'].
348   class { 'ntp::package': }
349   -> class { 'ntp::config': }
350   -> class { 'ntp::service': }
351
352   # These two resources "anchor" the composed classes within the ntp
353   # class.
354   anchor { 'ntp::begin': } -> Class['ntp::package']
355   Class['ntp::service']    -> anchor { 'ntp::end': }
356 }
357 ```
358
359 This allows the end user of the ntp module to establish require and before
360 relationships with Class['ntp']:
361
362 ```
363 class { 'ntp': } -> class { 'mcollective': }
364 class { 'mcollective': } -> class { 'ntp': }
365 ```
366
367 #### Parameters
368
369 The following parameters are available in the `anchor` type.
370
371 ##### `name`
372
373 namevar
374
375 The name of the anchor resource.
376
377 ### file_line
378
379 The implementation matches the full line, including whitespace at the
380 beginning and end.  If the line is not contained in the given file, Puppet
381 will append the line to the end of the file to ensure the desired state.
382 Multiple resources may be declared to manage multiple lines in the same file.
383
384 * Ensure Example
385 ```
386 file_line { 'sudo_rule':
387   path => '/etc/sudoers',
388   line => '%sudo ALL=(ALL) ALL',
389 }
390
391 file_line { 'sudo_rule_nopw':
392   path => '/etc/sudoers',
393   line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
394 }
395 ```
396 In this example, Puppet will ensure both of the specified lines are
397 contained in the file /etc/sudoers.
398
399 * Match Example
400
401 ```
402 file_line { 'bashrc_proxy':
403   ensure => present,
404   path   => '/etc/bashrc',
405   line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
406   match  => '^export\ HTTP_PROXY\=',
407 }
408 ```
409
410 In this code example match will look for a line beginning with export
411 followed by HTTP_PROXY and replace it with the value in line.
412
413 * Examples With `ensure => absent`:
414
415 This type has two behaviors when `ensure => absent` is set.
416
417 One possibility is to set `match => ...` and `match_for_absence => true`,
418 as in the following example:
419
420 ```
421 file_line { 'bashrc_proxy':
422   ensure            => absent,
423   path              => '/etc/bashrc',
424   match             => '^export\ HTTP_PROXY\=',
425   match_for_absence => true,
426 }
427 ```
428
429 In this code example match will look for a line beginning with export
430 followed by HTTP_PROXY and delete it.  If multiple lines match, an
431 error will be raised unless the `multiple => true` parameter is set.
432
433 Note that the `line => ...` parameter would be accepted BUT IGNORED in
434 the above example.
435
436 The second way of using `ensure => absent` is to specify a `line => ...`,
437 and no match:
438
439 ```
440 file_line { 'bashrc_proxy':
441   ensure => absent,
442   path   => '/etc/bashrc',
443   line   => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
444 }
445 ```
446
447 > *Note:*
448 When ensuring lines are absent this way, the default behavior
449 this time is to always remove all lines matching, and this behavior
450 can't be disabled.
451
452 * Encoding example:
453
454 ```
455 file_line { "XScreenSaver":
456   ensure   => present,
457   path     => '/root/XScreenSaver',
458   line     => "*lock: 10:00:00",
459   match    => '^*lock:',
460   encoding => "iso-8859-1",
461 }
462 ```
463
464 Files with special characters that are not valid UTF-8 will give the
465 error message "invalid byte sequence in UTF-8".  In this case, determine
466 the correct file encoding and specify the correct encoding using the
467 encoding attribute, the value of which needs to be a valid Ruby character
468 encoding.
469
470 **Autorequires:** If Puppet is managing the file that will contain the line
471 being managed, the file_line resource will autorequire that file.
472
473 #### Properties
474
475 The following properties are available in the `file_line` type.
476
477 ##### `ensure`
478
479 Valid values: present, absent
480
481 Manage the state of this type.
482
483 Default value: present
484
485 ##### `line`
486
487 The line to be appended to the file or used to replace matches found by the match attribute.
488
489 #### Parameters
490
491 The following parameters are available in the `file_line` type.
492
493 ##### `name`
494
495 namevar
496
497 An arbitrary name used as the identity of the resource.
498
499 ##### `match`
500
501 An optional ruby regular expression to run against existing lines in the file.
502 If a match is found, we replace that line rather than adding a new line.
503 A regex comparison is performed against the line value and if it does not
504 match an exception will be raised.
505
506 ##### `match_for_absence`
507
508 Valid values: `true`, `false`
509
510 An optional value to determine if match should be applied when ensure => absent.
511 If set to true and match is set, the line that matches match will be deleted.
512 If set to false (the default), match is ignored when ensure => absent.
513 When `ensure => present`, match_for_absence is ignored.
514
515 Default value: `false`
516
517 ##### `multiple`
518
519 Valid values: `true`, `false`
520
521 An optional value to determine if match can change multiple lines.
522 If set to false, an exception will be raised if more than one line matches
523
524 ##### `after`
525
526 An optional value used to specify the line after which we will add any new lines. (Existing lines are added in place)
527 This is also takes a regex.
528
529 ##### `path`
530
531 The file Puppet will ensure contains the line specified by the line parameter.
532
533 ##### `replace`
534
535 Valid values: `true`, `false`
536
537 If true, replace line that matches. If false, do not write line if a match is found
538
539 Default value: `true`
540
541 ##### `replace_all_matches_not_matching_line`
542
543 Valid values: `true`, `false`
544
545 Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, regardless of whether the specified line is already present in the file.
546
547 Default value: `false`
548
549 ##### `encoding`
550
551 For files that are not UTF-8 encoded, specify encoding such as iso-8859-1
552
553 Default value: UTF-8
554
555 ##### `append_on_no_match`
556
557 Valid values: `true`, `false`
558
559 If true, append line if match is not found. If false, do not append line if a match is not found
560
561 Default value: `true`
562
563 ## Functions
564
565 ### abs
566
567 Type: Ruby 3.x API
568
569 For example -34.56 becomes 34.56.
570 Takes a single integer or float value as an argument.
571
572 > *Note:*
573   **Deprected** from Puppet 6.0.0, the built-in
574   ['abs'](https://puppet.com/docs/puppet/6.4/function.html#abs)function will be used instead.
575
576 #### `abs()`
577
578 For example -34.56 becomes 34.56.
579 Takes a single integer or float value as an argument.
580
581 > *Note:*
582   **Deprected** from Puppet 6.0.0, the built-in
583   ['abs'](https://puppet.com/docs/puppet/6.4/function.html#abs)function will be used instead.
584
585 Returns: `Any` The absolute value of the given number if it was an Integer
586
587 ### any2array
588
589 Type: Ruby 3.x API
590
591 Empty argument lists are converted to an empty array. Arrays are left
592 untouched. Hashes are converted to arrays of alternating keys and values.
593
594 > *Note:*
595   since Puppet 5.0.0 it is possible to create new data types for almost any
596   datatype using the type system and the built-in
597   [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple)
598   function is used to create a new Array..
599
600   ```
601   $hsh = {'key' => 42, 'another-key' => 100}
602   notice(Array($hsh))
603   ```
604
605 Would notice `[['key', 42], ['another-key', 100]]`
606
607 The Array data type also has a special mode to "create an array if not already an array"
608
609   ```
610   notice(Array({'key' => 42, 'another-key' => 100}, true))
611   ```
612
613 Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being
614 transformed into an array.
615
616 #### `any2array()`
617
618 Empty argument lists are converted to an empty array. Arrays are left
619 untouched. Hashes are converted to arrays of alternating keys and values.
620
621 > *Note:*
622   since Puppet 5.0.0 it is possible to create new data types for almost any
623   datatype using the type system and the built-in
624   [`Array.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-array-and-tuple)
625   function is used to create a new Array..
626
627   ```
628   $hsh = {'key' => 42, 'another-key' => 100}
629   notice(Array($hsh))
630   ```
631
632 Would notice `[['key', 42], ['another-key', 100]]`
633
634 The Array data type also has a special mode to "create an array if not already an array"
635
636   ```
637   notice(Array({'key' => 42, 'another-key' => 100}, true))
638   ```
639
640 Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being
641 transformed into an array.
642
643 Returns: `Array` The new array containing the given object
644
645 ### any2bool
646
647 Type: Ruby 3.x API
648
649 In practise it does the following:
650 * Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
651 * Strings such as 0,F,f,N,n,FALSE,no,'false' will return false
652 * Booleans will just return their original value
653 * Number (or a string representation of a number) > 0 will return true, otherwise false
654 * undef will return false
655 * Anything else will return true
656
657 Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
658 function.
659
660 #### `any2bool()`
661
662 In practise it does the following:
663 * Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
664 * Strings such as 0,F,f,N,n,FALSE,no,'false' will return false
665 * Booleans will just return their original value
666 * Number (or a string representation of a number) > 0 will return true, otherwise false
667 * undef will return false
668 * Anything else will return true
669
670 Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
671 function.
672
673 Returns: `Boolean` The boolean value of the object that was given
674
675 ### assert_private
676
677 Type: Ruby 3.x API
678
679 Calling the class or definition from outside the current module will fail.
680
681 #### `assert_private()`
682
683 Calling the class or definition from outside the current module will fail.
684
685 Returns: `Any` set the current class or definition as private.
686
687 ### base64
688
689 Type: Ruby 3.x API
690
691 > **Note:*
692     Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings.
693     See the `new()` function for the Binary and String types for documentation. Also see `binary_file()`
694     function for reading a file with binary (non UTF-8) content.
695
696 #### Examples
697
698 ##### Example usage
699
700 ```puppet
701
702 Encode and decode a string
703
704   $encodestring = base64('encode', 'thestring')
705   $decodestring = base64('decode', 'dGhlc3RyaW5n')
706
707 Explicitly define encode/decode method: default, strict, urlsafe
708
709   $method = 'default'
710   $encodestring = base64('encode', 'thestring', $method)
711   $decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
712
713 Encode a string as if it was binary
714
715  $encodestring = String(Binary('thestring', '%s'))
716
717 Decode a Binary assuming it is an UTF-8 String
718
719  $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
720 ```
721
722 #### `base64()`
723
724 > **Note:*
725     Since Puppet 4.8.0, the Binary data type can be used to produce base 64 encoded strings.
726     See the `new()` function for the Binary and String types for documentation. Also see `binary_file()`
727     function for reading a file with binary (non UTF-8) content.
728
729 Returns: `String` The encoded/decoded va
730
731 ##### Examples
732
733 ###### Example usage
734
735 ```puppet
736
737 Encode and decode a string
738
739   $encodestring = base64('encode', 'thestring')
740   $decodestring = base64('decode', 'dGhlc3RyaW5n')
741
742 Explicitly define encode/decode method: default, strict, urlsafe
743
744   $method = 'default'
745   $encodestring = base64('encode', 'thestring', $method)
746   $decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
747
748 Encode a string as if it was binary
749
750  $encodestring = String(Binary('thestring', '%s'))
751
752 Decode a Binary assuming it is an UTF-8 String
753
754  $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
755 ```
756
757 ### basename
758
759 Type: Ruby 3.x API
760
761 Strips directory (and optional suffix) from a filename
762
763 #### `basename()`
764
765 The basename function.
766
767 Returns: `String` The stripped filename
768
769 ### bool2num
770
771 Type: Ruby 3.x API
772
773 Converts the values:
774   ```
775   false, f, 0, n, and no to 0
776   true, t, 1, y, and yes to 1
777   ```
778 Requires a single boolean or string as an input.
779
780 > *Note:*
781   since Puppet 5.0.0 it is possible to create new data types for almost any
782   datatype using the type system and the built-in
783   [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric),
784   [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and
785   [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float)
786   function are used to convert to numeric values.
787   ```
788   notice(Integer(false)) # Notices 0
789   notice(Float(true))    # Notices 1.0
790   ```
791
792 #### `bool2num()`
793
794 Converts the values:
795   ```
796   false, f, 0, n, and no to 0
797   true, t, 1, y, and yes to 1
798   ```
799 Requires a single boolean or string as an input.
800
801 > *Note:*
802   since Puppet 5.0.0 it is possible to create new data types for almost any
803   datatype using the type system and the built-in
804   [`Numeric.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-numeric),
805   [`Integer.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-integer), and
806   [`Float.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-float)
807   function are used to convert to numeric values.
808   ```
809   notice(Integer(false)) # Notices 0
810   notice(Float(true))    # Notices 1.0
811   ```
812
813 Returns: `Integer` The converted value as a number
814
815 ### bool2str
816
817 Type: Ruby 3.x API
818
819 The optional second and third arguments represent what true and false will be
820 converted to respectively. If only one argument is given, it will be
821 converted from a boolean to a string containing 'true' or 'false'.
822
823 **Examples of usage**
824
825   ```
826     bool2str(true)                    => 'true'
827     bool2str(true, 'yes', 'no')       => 'yes'
828     bool2str(false, 't', 'f')         => 'f'
829   ```
830
831 Requires a single boolean as an input.
832
833 > *Note:*
834   since Puppet 5.0.0 it is possible to create new data types for almost any
835   datatype using the type system and the built-in
836   [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string)
837   function is used to convert to String with many different format options.
838
839   ```
840     notice(String(false))         # Notices 'false'
841     notice(String(true))          # Notices 'true'
842     notice(String(false, '%y'))   # Notices 'yes'
843     notice(String(true, '%y'))    # Notices 'no'
844   ```
845
846 #### `bool2str()`
847
848 The optional second and third arguments represent what true and false will be
849 converted to respectively. If only one argument is given, it will be
850 converted from a boolean to a string containing 'true' or 'false'.
851
852 **Examples of usage**
853
854   ```
855     bool2str(true)                    => 'true'
856     bool2str(true, 'yes', 'no')       => 'yes'
857     bool2str(false, 't', 'f')         => 'f'
858   ```
859
860 Requires a single boolean as an input.
861
862 > *Note:*
863   since Puppet 5.0.0 it is possible to create new data types for almost any
864   datatype using the type system and the built-in
865   [`String.new`](https://puppet.com/docs/puppet/latest/function.html#boolean-to-string)
866   function is used to convert to String with many different format options.
867
868   ```
869     notice(String(false))         # Notices 'false'
870     notice(String(true))          # Notices 'true'
871     notice(String(false, '%y'))   # Notices 'yes'
872     notice(String(true, '%y'))    # Notices 'no'
873   ```
874
875 Returns: `Any` The converted value to string of the given Boolean
876
877 ### camelcase
878
879 Type: Ruby 3.x API
880
881 > *Note:*
882   **Deprecated** from Puppet 6.0.0, this function has been replaced with
883   a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase)
884   function.
885
886 #### `camelcase()`
887
888 > *Note:*
889   **Deprecated** from Puppet 6.0.0, this function has been replaced with
890   a built-in [`camelcase`](https://puppet.com/docs/puppet/latest/function.html#camelcase)
891   function.
892
893 Returns: `String` The converted String, if it was a String that was given
894
895 ### capitalize
896
897 Type: Ruby 3.x API
898
899 Requires either a single string or an array as an input.
900
901 > *Note:*
902   **Deprecated** from Puppet 6.0.0, yhis function has been replaced with a
903   built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize)
904   function.
905
906 #### `capitalize()`
907
908 Requires either a single string or an array as an input.
909
910 > *Note:*
911   **Deprecated** from Puppet 6.0.0, yhis function has been replaced with a
912   built-in [`capitalize`](https://puppet.com/docs/puppet/latest/function.html#capitalize)
913   function.
914
915 Returns: `String` The converted String, if it was a String that was given
916
917 ### ceiling
918
919 Type: Ruby 3.x API
920
921 Takes a single numeric value as an argument.
922
923 > *Note:*
924   **Deprecated** from Puppet 6.0.0, this function has been replaced with a
925   built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function.
926
927 #### `ceiling()`
928
929 Takes a single numeric value as an argument.
930
931 > *Note:*
932   **Deprecated** from Puppet 6.0.0, this function has been replaced with a
933   built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function.
934
935 Returns: `Integer` The rounded value
936
937 ### chomp
938
939 Type: Ruby 3.x API
940
941 For example `hello\n` becomes `hello`.
942 Requires a single string or array as an input.
943
944 > *Note:*
945   **Deprecated** from Puppet 6.0.0, this function has been replaced with a
946 built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function.
947
948 #### `chomp()`
949
950 For example `hello\n` becomes `hello`.
951 Requires a single string or array as an input.
952
953 > *Note:*
954   **Deprecated** from Puppet 6.0.0, this function has been replaced with a
955 built-in [`chomp`](https://puppet.com/docs/puppet/latest/function.html#chomp) function.
956
957 Returns: `String` The converted String, if it was a String that was given
958
959 ### chop
960
961 Type: Ruby 3.x API
962
963 If the string ends with `\r\n`, both characters are removed. Applying
964 chop to an empty string returns an empty string. If you wish to merely
965 remove record separators then you should use the `chomp` function.
966 Requires a string or array of strings as input.
967
968 > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a
969 built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function.
970
971 #### `chop()`
972
973 If the string ends with `\r\n`, both characters are removed. Applying
974 chop to an empty string returns an empty string. If you wish to merely
975 remove record separators then you should use the `chomp` function.
976 Requires a string or array of strings as input.
977
978 > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a
979 built-in [`chop`](https://puppet.com/docs/puppet/latest/function.html#chop) function.
980
981 Returns: `String` The given String, sans the last character.
982
983 ### clamp
984
985 Type: Ruby 3.x API
986
987 Strings are converted and compared numerically. Arrays of values are flattened
988 into a list for further handling.
989
990 > *Note:*
991   From Puppet 6.0.0 this can be done with only core Puppet like this:
992   `[$minval, $maxval, $value_to_clamp].sort[1]`
993
994 #### Examples
995
996 ##### Example usage
997
998 ```puppet
999
1000 clamp('24', [575, 187])` returns 187.
1001 clamp(16, 88, 661)` returns 88.
1002 clamp([4, 3, '99'])` returns 4.
1003 ```
1004
1005 #### `clamp()`
1006
1007 Strings are converted and compared numerically. Arrays of values are flattened
1008 into a list for further handling.
1009
1010 > *Note:*
1011   From Puppet 6.0.0 this can be done with only core Puppet like this:
1012   `[$minval, $maxval, $value_to_clamp].sort[1]`
1013
1014 Returns: `Array[Integer]` The sorted Array
1015
1016 ##### Examples
1017
1018 ###### Example usage
1019
1020 ```puppet
1021
1022 clamp('24', [575, 187])` returns 187.
1023 clamp(16, 88, 661)` returns 88.
1024 clamp([4, 3, '99'])` returns 4.
1025 ```
1026
1027 ### concat
1028
1029 Type: Ruby 3.x API
1030
1031 > *Note:*
1032   Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and
1033   merge of hashes, and the `<<`` operator for appending:
1034
1035 `['1','2','3'] + ['4','5','6'] + ['7','8','9']` returns `['1','2','3','4','5','6','7','8','9']`
1036 `[1, 2, 3] << 4` returns `[1, 2, 3, 4]`
1037 `[1, 2, 3] << [4, 5]` returns `[1, 2, 3, [4, 5]]`
1038
1039 #### Examples
1040
1041 ##### Example usage
1042
1043 ```puppet
1044
1045 concat(['1','2','3'],'4') returns ['1','2','3','4']
1046 concat(['1','2','3'],'4',['5','6','7']) returns ['1','2','3','4','5','6','7']
1047 ```
1048
1049 #### `concat()`
1050
1051 > *Note:*
1052   Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and
1053   merge of hashes, and the `<<`` operator for appending:
1054
1055 `['1','2','3'] + ['4','5','6'] + ['7','8','9']` returns `['1','2','3','4','5','6','7','8','9']`
1056 `[1, 2, 3] << 4` returns `[1, 2, 3, 4]`
1057 `[1, 2, 3] << [4, 5]` returns `[1, 2, 3, [4, 5]]`
1058
1059 Returns: `Array` The single concatenated array
1060
1061 ##### Examples
1062
1063 ###### Example usage
1064
1065 ```puppet
1066
1067 concat(['1','2','3'],'4') returns ['1','2','3','4']
1068 concat(['1','2','3'],'4',['5','6','7']) returns ['1','2','3','4','5','6','7']
1069 ```
1070
1071 ### convert_base
1072
1073 Type: Ruby 3.x API
1074
1075 convert_base(5, 2)` results in: `'101'`
1076 convert_base('254', '16')` results in: `'fe'`
1077
1078 > *Note:*
1079   Since Puppet 4.5.0 this can be done with the built-in
1080   [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string)
1081   function and its many formatting options:
1082
1083   `$binary_repr = String(5, '%b')` return `"101"`
1084   `$hex_repr = String(254, "%x")`  return `"fe"`
1085   `$hex_repr = String(254, "%#x")` return `"0xfe"`
1086
1087   @return [String] The converted value as a Str
1088
1089 #### Examples
1090
1091 ##### Example usage
1092
1093 ```puppet
1094
1095 ```
1096
1097 #### `convert_base()`
1098
1099 convert_base(5, 2)` results in: `'101'`
1100 convert_base('254', '16')` results in: `'fe'`
1101
1102 > *Note:*
1103   Since Puppet 4.5.0 this can be done with the built-in
1104   [`String.new`](https://puppet.com/docs/puppet/latest/function.html#integer-to-string)
1105   function and its many formatting options:
1106
1107   `$binary_repr = String(5, '%b')` return `"101"`
1108   `$hex_repr = String(254, "%x")`  return `"fe"`
1109   `$hex_repr = String(254, "%#x")` return `"0xfe"`
1110
1111   @return [String] The converted value as a Str
1112
1113 Returns: `Any` converted value as a string
1114
1115 ##### Examples
1116
1117 ###### Example usage
1118
1119 ```puppet
1120
1121 ```
1122
1123 ### count
1124
1125 Type: Ruby 3.x API
1126
1127 Takes an array as first argument and an optional second argument. Counts the number of elements in array that is equal to the second argument.
1128 If called with only an array, it counts the number of elements that are not nil/undef/empty-string.
1129
1130 > *Note:*
1131   equality is tested with a Ruby method and it is therefore subject to what Ruby considers
1132   to be equal. For strings this means that equality is case sensitive.
1133
1134 In Puppet core, counting can be done in general by using a combination of the core functions
1135 filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib).
1136
1137 Example below shows counting values that are not undef.
1138
1139   ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)```
1140
1141 Would notice the value 2.
1142
1143 #### `count()`
1144
1145 Takes an array as first argument and an optional second argument. Counts the number of elements in array that is equal to the second argument.
1146 If called with only an array, it counts the number of elements that are not nil/undef/empty-string.
1147
1148 > *Note:*
1149   equality is tested with a Ruby method and it is therefore subject to what Ruby considers
1150   to be equal. For strings this means that equality is case sensitive.
1151
1152 In Puppet core, counting can be done in general by using a combination of the core functions
1153 filter() (since Puppet 4.0.0) and length() (since Puppet 5.5.0, before that in stdlib).
1154
1155 Example below shows counting values that are not undef.
1156
1157   ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)```
1158
1159 Would notice the value 2.
1160
1161 Returns: `Integer` The amount of elements counted within the array
1162
1163 ### deep_merge
1164
1165 Type: Ruby 3.x API
1166
1167 Recursively merges two or more hashes together and returns the resulting hash.
1168
1169 #### Examples
1170
1171 ##### Example usage
1172
1173 ```puppet
1174
1175 $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
1176 $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
1177 $merged_hash = deep_merge($hash1, $hash2)
1178
1179 The resulting hash is equivalent to:
1180
1181 $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
1182
1183 When there is a duplicate key that is a hash, they are recursively merged.
1184 When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
1185 ```
1186
1187 #### `deep_merge()`
1188
1189 The deep_merge function.
1190
1191 Returns: `Hash` The merged h
1192
1193 ##### Examples
1194
1195 ###### Example usage
1196
1197 ```puppet
1198
1199 $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
1200 $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
1201 $merged_hash = deep_merge($hash1, $hash2)
1202
1203 The resulting hash is equivalent to:
1204
1205 $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
1206
1207 When there is a duplicate key that is a hash, they are recursively merged.
1208 When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
1209 ```
1210
1211 ### defined_with_params
1212
1213 Type: Ruby 3.x API
1214
1215 Returns `true` if a resource with the specified attributes has already been added
1216 to the catalog, and `false` otherwise.
1217
1218   ```
1219   user { 'dan':
1220     ensure => present,
1221   }
1222
1223   if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
1224     user { 'dan': ensure => present, }
1225   }
1226   ```
1227
1228 #### `defined_with_params()`
1229
1230 Returns `true` if a resource with the specified attributes has already been added
1231 to the catalog, and `false` otherwise.
1232
1233   ```
1234   user { 'dan':
1235     ensure => present,
1236   }
1237
1238   if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
1239     user { 'dan': ensure => present, }
1240   }
1241   ```
1242
1243 Returns: `Boolean` returns `true` or `false`
1244
1245 ### delete
1246
1247 Type: Ruby 3.x API
1248
1249 > *Note:*
1250 From Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash
1251 `{'a'=>1,'b'=>2,'c'=>3} - ['b','c'])`
1252 >
1253 A global delete from a string can be performed with the
1254 [`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function:
1255 `'abracadabra'.regsubst(/bra/, '', 'G')`
1256
1257 In general, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)
1258 function can filter out entries from arrays and hashes based on keys and/or values.
1259
1260 #### Examples
1261
1262 ##### Example usage
1263
1264 ```puppet
1265
1266 delete(['a','b','c','b'], 'b')
1267 Would return: ['a','c']
1268
1269 delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
1270 Would return: {'a'=>1,'c'=>3}
1271
1272 delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
1273 Would return: {'a'=>1}
1274
1275 delete('abracadabra', 'bra')
1276 Would return: 'acada'
1277
1278 ['a', 'b', 'c', 'b'] - 'b'
1279 Would return: ['a', 'c']
1280
1281 {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
1282 Would return: {'a' => '1'}
1283
1284 'abracadabra'.regsubst(/bra/, '', 'G')
1285 Would return: 'acada'
1286 ```
1287
1288 #### `delete()`
1289
1290 > *Note:*
1291 From Puppet 4.0.0 the minus (-) operator deletes values from arrays and keys from a hash
1292 `{'a'=>1,'b'=>2,'c'=>3} - ['b','c'])`
1293 >
1294 A global delete from a string can be performed with the
1295 [`regsubst`](https://puppet.com/docs/puppet/latest/function.html#regsubst) function:
1296 `'abracadabra'.regsubst(/bra/, '', 'G')`
1297
1298 In general, the built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter)
1299 function can filter out entries from arrays and hashes based on keys and/or values.
1300
1301 Returns: `String` The filtered String, if one was given.
1302
1303 ##### Examples
1304
1305 ###### Example usage
1306
1307 ```puppet
1308
1309 delete(['a','b','c','b'], 'b')
1310 Would return: ['a','c']
1311
1312 delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
1313 Would return: {'a'=>1,'c'=>3}
1314
1315 delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
1316 Would return: {'a'=>1}
1317
1318 delete('abracadabra', 'bra')
1319 Would return: 'acada'
1320
1321 ['a', 'b', 'c', 'b'] - 'b'
1322 Would return: ['a', 'c']
1323
1324 {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
1325 Would return: {'a' => '1'}
1326
1327 'abracadabra'.regsubst(/bra/, '', 'G')
1328 Would return: 'acada'
1329 ```
1330
1331 ### delete_at
1332
1333 Type: Ruby 3.x API
1334
1335 For example
1336     ```delete_at(['a','b','c'], 1)```
1337
1338 Would return: `['a','c']`
1339
1340 > *Note:*
1341   Since Puppet 4 this can be done in general with the built-in
1342   [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1343
1344   ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }```
1345
1346 Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]:
1347   ```
1348   $array[0, -1] # the same as all the values
1349   $array[2, -1] # all but the first 2 elements
1350   $array[0, -3] # all but the last 2 elements
1351   $array[1, -2] # all but the first and last element
1352   ```
1353
1354 #### `delete_at()`
1355
1356 For example
1357     ```delete_at(['a','b','c'], 1)```
1358
1359 Would return: `['a','c']`
1360
1361 > *Note:*
1362   Since Puppet 4 this can be done in general with the built-in
1363   [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1364
1365   ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }```
1366
1367 Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]:
1368   ```
1369   $array[0, -1] # the same as all the values
1370   $array[2, -1] # all but the first 2 elements
1371   $array[0, -3] # all but the last 2 elements
1372   $array[1, -2] # all but the first and last element
1373   ```
1374
1375 Returns: `Array` The given array, now missing the tar
1376
1377 ### delete_regex
1378
1379 Type: Ruby 3.x API
1380
1381 Multiple regular expressions are assumed to be matched as an OR.
1382
1383 > *Note:*
1384 Since Puppet 4 this can be done in general with the built-in
1385 [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1386 ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ }
1387 Would return: ['aaa', 'aca']
1388
1389 #### Examples
1390
1391 ##### Example usage
1392
1393 ```puppet
1394
1395 delete_regex(['a','b','c','b'], 'b')
1396 Would return: ['a','c']
1397
1398 delete_regex(['a','b','c','b'], ['b', 'c'])
1399 Would return: ['a']
1400
1401 delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
1402 Would return: {'a'=>1,'c'=>3}
1403
1404 delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
1405 Would return: {'b'=>2,'c'=>3}
1406 ```
1407
1408 #### `delete_regex()`
1409
1410 Multiple regular expressions are assumed to be matched as an OR.
1411
1412 > *Note:*
1413 Since Puppet 4 this can be done in general with the built-in
1414 [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1415 ["aaa", "aba", "aca"].filter |$val| { $val !~ /b/ }
1416 Would return: ['aaa', 'aca']
1417
1418 Returns: `Array` The given array now missing all targeted values.
1419
1420 ##### Examples
1421
1422 ###### Example usage
1423
1424 ```puppet
1425
1426 delete_regex(['a','b','c','b'], 'b')
1427 Would return: ['a','c']
1428
1429 delete_regex(['a','b','c','b'], ['b', 'c'])
1430 Would return: ['a']
1431
1432 delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
1433 Would return: {'a'=>1,'c'=>3}
1434
1435 delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
1436 Would return: {'b'=>2,'c'=>3}
1437 ```
1438
1439 ### delete_undef_values
1440
1441 Type: Ruby 3.x API
1442
1443 > *Note:*
1444 Since Puppet 4.0.0 the equivalent can be performed with the built-in
1445 [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1446 $array.filter |$val| { $val =~ NotUndef }
1447 $hash.filter |$key, $val| { $val =~ NotUndef }
1448
1449 #### Examples
1450
1451 ##### Example usage
1452
1453 ```puppet
1454
1455 $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
1456 Would return: {a => 'A', b => '', d => false}
1457
1458 While:
1459 $array = delete_undef_values(['A','',undef,false])
1460 Would return: ['A','',false]
1461 ```
1462
1463 #### `delete_undef_values()`
1464
1465 > *Note:*
1466 Since Puppet 4.0.0 the equivalent can be performed with the built-in
1467 [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1468 $array.filter |$val| { $val =~ NotUndef }
1469 $hash.filter |$key, $val| { $val =~ NotUndef }
1470
1471 Returns: `Array` The given array now issing of undefined values.
1472
1473 ##### Examples
1474
1475 ###### Example usage
1476
1477 ```puppet
1478
1479 $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
1480 Would return: {a => 'A', b => '', d => false}
1481
1482 While:
1483 $array = delete_undef_values(['A','',undef,false])
1484 Would return: ['A','',false]
1485 ```
1486
1487 ### delete_values
1488
1489 Type: Ruby 3.x API
1490
1491 > *Note:*
1492 Since Puppet 4.0.0 the equivalent can be performed with the
1493 built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1494 $array.filter |$val| { $val != 'B' }
1495 $hash.filter |$key, $val| { $val != 'B' }
1496
1497 #### Examples
1498
1499 ##### Example usage
1500
1501 ```puppet
1502
1503 delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
1504 Would return: {'a'=>'A','c'=>'C','B'=>'D'}
1505 ```
1506
1507 #### `delete_values()`
1508
1509 > *Note:*
1510 Since Puppet 4.0.0 the equivalent can be performed with the
1511 built-in [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function:
1512 $array.filter |$val| { $val != 'B' }
1513 $hash.filter |$key, $val| { $val != 'B' }
1514
1515 Returns: `Hash` The given hash now missing all instances of the targeted value
1516
1517 ##### Examples
1518
1519 ###### Example usage
1520
1521 ```puppet
1522
1523 delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
1524 Would return: {'a'=>'A','c'=>'C','B'=>'D'}
1525 ```
1526
1527 ### deprecation
1528
1529 Type: Ruby 3.x API
1530
1531 The uniqueness key - can appear once. The msg is the message text including any positional
1532 information that is formatted by the user/caller of the method.).
1533
1534 #### `deprecation()`
1535
1536 The uniqueness key - can appear once. The msg is the message text including any positional
1537 information that is formatted by the user/caller of the method.).
1538
1539 Returns: `String` return deprecation warnings
1540
1541 ### deprecation
1542
1543 Type: Ruby 4.x API
1544
1545 Function to print deprecation warnings, Logs a warning once for a given key.
1546
1547 The uniqueness key - can appear once.
1548 The msg is the message text including any positional information that is formatted by the
1549 user/caller of the method.
1550 It is affected by the puppet setting 'strict', which can be set to :error
1551 (outputs as an error message), :off (no message / error is displayed) and :warning
1552 (default, outputs a warning)  *Type*: String, String.
1553
1554 #### `deprecation(String $key, String $message)`
1555
1556 Function to print deprecation warnings, Logs a warning once for a given key.
1557
1558 The uniqueness key - can appear once.
1559 The msg is the message text including any positional information that is formatted by the
1560 user/caller of the method.
1561 It is affected by the puppet setting 'strict', which can be set to :error
1562 (outputs as an error message), :off (no message / error is displayed) and :warning
1563 (default, outputs a warning)  *Type*: String, String.
1564
1565 Returns: `Any` deprecated warnings
1566
1567 ##### `key`
1568
1569 Data type: `String`
1570
1571
1572
1573 ##### `message`
1574
1575 Data type: `String`
1576
1577
1578
1579 ### difference
1580
1581 Type: Ruby 3.x API
1582
1583 The returned array is a copy of the original array, removing any items that
1584 also appear in the second array.
1585
1586 > *Note:*
1587 Since Puppet 4 the minus (-) operator in the Puppet language does the same thing:
1588 ['a', 'b', 'c'] - ['b', 'c', 'd']
1589 Would return: `['a']`
1590
1591 #### Examples
1592
1593 ##### Example usage
1594
1595 ```puppet
1596
1597 difference(["a","b","c"],["b","c","d"])
1598 Would return: `["a"]`
1599 ```
1600
1601 #### `difference()`
1602
1603 The returned array is a copy of the original array, removing any items that
1604 also appear in the second array.
1605
1606 > *Note:*
1607 Since Puppet 4 the minus (-) operator in the Puppet language does the same thing:
1608 ['a', 'b', 'c'] - ['b', 'c', 'd']
1609 Would return: `['a']`
1610
1611 Returns: `Array` The difference between the two given arrays
1612
1613 ##### Examples
1614
1615 ###### Example usage
1616
1617 ```puppet
1618
1619 difference(["a","b","c"],["b","c","d"])
1620 Would return: `["a"]`
1621 ```
1622
1623 ### dig
1624
1625 Type: Ruby 3.x API
1626
1627 In addition to the required path argument, the function accepts the default argument.
1628 It is returned if the path is not correct, if no value was found, or if any other error
1629 has occurred.
1630
1631   ```ruby
1632   $data = {
1633     'a' => {
1634       'b' => [
1635         'b1',
1636         'b2',
1637         'b3',
1638       ]
1639     }
1640   }
1641
1642   $value = dig($data, ['a', 'b', 2])
1643   # $value = 'b3'
1644
1645   # with all possible options
1646   $value = dig($data, ['a', 'b', 2], 'not_found')
1647   # $value = 'b3'
1648
1649   # using the default value
1650   $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
1651   # $value = 'not_found'
1652   ```
1653
1654   1. `$data` The data structure we are working with.
1655   2. `['a', 'b', 2]` The path array.
1656   3. `not_found` The default value. It is returned if nothing is found.
1657
1658 > **Note:*
1659   **Deprecated** This function has been replaced with a built-in
1660   [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of
1661   Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version.
1662
1663 #### `dig()`
1664
1665 In addition to the required path argument, the function accepts the default argument.
1666 It is returned if the path is not correct, if no value was found, or if any other error
1667 has occurred.
1668
1669   ```ruby
1670   $data = {
1671     'a' => {
1672       'b' => [
1673         'b1',
1674         'b2',
1675         'b3',
1676       ]
1677     }
1678   }
1679
1680   $value = dig($data, ['a', 'b', 2])
1681   # $value = 'b3'
1682
1683   # with all possible options
1684   $value = dig($data, ['a', 'b', 2], 'not_found')
1685   # $value = 'b3'
1686
1687   # using the default value
1688   $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
1689   # $value = 'not_found'
1690   ```
1691
1692   1. `$data` The data structure we are working with.
1693   2. `['a', 'b', 2]` The path array.
1694   3. `not_found` The default value. It is returned if nothing is found.
1695
1696 > **Note:*
1697   **Deprecated** This function has been replaced with a built-in
1698   [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of
1699   Puppet 4.5.0. Use [`dig44()`](#dig44) for backwards compatibility or use the new version.
1700
1701 Returns: `Any` The function goes through the structure by each path component and tries to return
1702 the value at the end of the path.
1703
1704 ### dig44
1705
1706 Type: Ruby 3.x API
1707
1708 Key can contain slashes to describe path components. The function will go down
1709 the structure and try to extract the required value.
1710
1711 ```
1712 $data = {
1713   'a' => {
1714     'b' => [
1715       'b1',
1716       'b2',
1717       'b3',
1718     ]
1719   }
1720 }
1721
1722 $value = dig44($data, ['a', 'b', 2])
1723 # $value = 'b3'
1724
1725 # with all possible options
1726 $value = dig44($data, ['a', 'b', 2], 'not_found')
1727 # $value = 'b3'
1728
1729 # using the default value
1730 $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
1731 # $value = 'not_found'
1732 ```
1733
1734 > **Note:* **Deprecated** This function has been replaced with a built-in
1735   [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of
1736   Puppet 4.5.0.
1737
1738 #### `dig44()`
1739
1740 Key can contain slashes to describe path components. The function will go down
1741 the structure and try to extract the required value.
1742
1743 ```
1744 $data = {
1745   'a' => {
1746     'b' => [
1747       'b1',
1748       'b2',
1749       'b3',
1750     ]
1751   }
1752 }
1753
1754 $value = dig44($data, ['a', 'b', 2])
1755 # $value = 'b3'
1756
1757 # with all possible options
1758 $value = dig44($data, ['a', 'b', 2], 'not_found')
1759 # $value = 'b3'
1760
1761 # using the default value
1762 $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
1763 # $value = 'not_found'
1764 ```
1765
1766 > **Note:* **Deprecated** This function has been replaced with a built-in
1767   [`dig`](https://puppet.com/docs/puppet/latest/function.html#dig) function as of
1768   Puppet 4.5.0.
1769
1770 Returns: `String` 'not_found' will be returned if nothing is found
1771
1772 ### dirname
1773
1774 Type: Ruby 3.x API
1775
1776 Returns the dirname of a path.
1777
1778 #### `dirname()`
1779
1780 The dirname function.
1781
1782 Returns: `String` the given path's dirname
1783
1784 ### dos2unix
1785
1786 Type: Ruby 3.x API
1787
1788 Takes a single string argument.
1789
1790 #### `dos2unix()`
1791
1792 Takes a single string argument.
1793
1794 Returns: `Any` The retrieved version
1795
1796 ### downcase
1797
1798 Type: Ruby 3.x API
1799
1800 > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a
1801 built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function.
1802 >
1803 This function is an implementation of a Ruby class and might not be UTF8 compatible.
1804 To ensure compatibility, use this function with Ruby 2.4.0 or greater.
1805
1806 #### `downcase()`
1807
1808 > *Note:* **Deprecated** from Puppet 6.0.0, this function has been replaced with a
1809 built-in [`downcase`](https://puppet.com/docs/puppet/latest/function.html#downcase) function.
1810 >
1811 This function is an implementation of a Ruby class and might not be UTF8 compatible.
1812 To ensure compatibility, use this function with Ruby 2.4.0 or greater.
1813
1814 Returns: `String` The converted String, if it was a String that was given
1815
1816 ### empty
1817
1818 Type: Ruby 3.x API
1819
1820 > *Note*: **Deprecated** from Puppet 5.5.0, the built-in
1821 [`empty`](https://puppet.com/docs/puppet/6.4/function.html#empty) function will be used instead.
1822
1823 #### `empty()`
1824
1825 > *Note*: **Deprecated** from Puppet 5.5.0, the built-in
1826 [`empty`](https://puppet.com/docs/puppet/6.4/function.html#empty) function will be used instead.
1827
1828 Returns: `Any` Returns `true` if the argument is an array or hash that contains no elements,
1829 or an empty string. Returns `false` when the argument is a numerical value.
1830
1831 ### enclose_ipv6
1832
1833 Type: Ruby 3.x API
1834
1835 Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
1836
1837 #### `enclose_ipv6()`
1838
1839 The enclose_ipv6 function.
1840
1841 Returns: `Any` encloses the ipv6 addresses with square brackets.
1842
1843 ### ensure_packages
1844
1845 Type: Ruby 3.x API
1846
1847 It optionally takes a hash as a second parameter that will be passed as the
1848 third argument to the ensure_resource() function.
1849
1850 #### `ensure_packages()`
1851
1852 It optionally takes a hash as a second parameter that will be passed as the
1853 third argument to the ensure_resource() function.
1854
1855 Returns: `Any` install the passed packages
1856
1857 ### ensure_resource
1858
1859 Type: Ruby 3.x API
1860
1861 user { 'dan':
1862   ensure => present,
1863 }
1864
1865 #### Examples
1866
1867 ##### Example usage
1868
1869 ```puppet
1870
1871 Creates the resource if it does not already exist:
1872
1873   ensure_resource('user', 'dan', {'ensure' => 'present' })
1874
1875 If the resource already exists but does not match the specified parameters,
1876 this function will attempt to recreate the resource leading to a duplicate
1877 resource definition error.
1878
1879 An array of resources can also be passed in and each will be created with
1880 the type and parameters specified if it doesn't already exist.
1881
1882   ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
1883 ```
1884
1885 #### `ensure_resource()`
1886
1887 user { 'dan':
1888   ensure => present,
1889 }
1890
1891 Returns: `Any` created or recreated the passed resource with the passed type and attributes
1892
1893 ##### Examples
1894
1895 ###### Example usage
1896
1897 ```puppet
1898
1899 Creates the resource if it does not already exist:
1900
1901   ensure_resource('user', 'dan', {'ensure' => 'present' })
1902
1903 If the resource already exists but does not match the specified parameters,
1904 this function will attempt to recreate the resource leading to a duplicate
1905 resource definition error.
1906
1907 An array of resources can also be passed in and each will be created with
1908 the type and parameters specified if it doesn't already exist.
1909
1910   ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
1911 ```
1912
1913 ### ensure_resources
1914
1915 Type: Ruby 3.x API
1916
1917 An hash of resources should be passed in and each will be created with
1918   the type and parameters specified if it doesn't already exist.
1919
1920   ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
1921
1922   From Hiera Backend:
1923
1924   userlist:
1925     dan:
1926       gid: 'mygroup'
1927    uid: '600'
1928     alex:
1929    gid: 'mygroup'
1930
1931   Call:
1932   ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
1933
1934 #### Examples
1935
1936 ##### Example usage
1937
1938 ```puppet
1939
1940 user { 'dan':
1941   gid => 'mygroup',
1942   ensure => present,
1943 }
1944 ```
1945
1946 #### `ensure_resources()`
1947
1948 An hash of resources should be passed in and each will be created with
1949   the type and parameters specified if it doesn't already exist.
1950
1951   ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
1952
1953   From Hiera Backend:
1954
1955   userlist:
1956     dan:
1957       gid: 'mygroup'
1958    uid: '600'
1959     alex:
1960    gid: 'mygroup'
1961
1962   Call:
1963   ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
1964
1965 Returns: `Any` created resources with the passed type and attributes
1966
1967 ##### Examples
1968
1969 ###### Example usage
1970
1971 ```puppet
1972
1973 user { 'dan':
1974   gid => 'mygroup',
1975   ensure => present,
1976 }
1977 ```
1978
1979 ### fact
1980
1981 Type: Ruby 4.x API
1982
1983 Supports the use of dot-notation for referring to structured facts. If a fact requested
1984 does not exist, returns Undef.
1985
1986 #### Examples
1987
1988 ##### Example usage:
1989
1990 ```puppet
1991 fact('osfamily')
1992 fact('os.architecture')
1993 ```
1994
1995 ##### Array indexing:
1996
1997 ```puppet
1998 fact('mountpoints."/dev".options.1')
1999 ```
2000
2001 ##### Fact containing a "." in the name:
2002
2003 ```puppet
2004 fact('vmware."VRA.version"')
2005 ```
2006
2007 #### `fact(String $fact_name)`
2008
2009 Supports the use of dot-notation for referring to structured facts. If a fact requested
2010 does not exist, returns Undef.
2011
2012 Returns: `Any` All information retrieved on the given fact_name
2013
2014 ##### Examples
2015
2016 ###### Example usage:
2017
2018 ```puppet
2019 fact('osfamily')
2020 fact('os.architecture')
2021 ```
2022
2023 ###### Array indexing:
2024
2025 ```puppet
2026 fact('mountpoints."/dev".options.1')
2027 ```
2028
2029 ###### Fact containing a "." in the name:
2030
2031 ```puppet
2032 fact('vmware."VRA.version"')
2033 ```
2034
2035 ##### `fact_name`
2036
2037 Data type: `String`
2038
2039 The name of the fact to check
2040
2041 ### flatten
2042
2043 Type: Ruby 3.x API
2044
2045 > **Note:** **Deprecated** from Puppet 5.5.0, this function has been replaced with a
2046 built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function.
2047
2048 #### Examples
2049
2050 ##### Example usage
2051
2052 ```puppet
2053
2054 flatten(['a', ['b', ['c']]])` returns: `['a','b','c']
2055 ```
2056
2057 #### `flatten()`
2058
2059 > **Note:** **Deprecated** from Puppet 5.5.0, this function has been replaced with a
2060 built-in [`flatten`](https://puppet.com/docs/puppet/latest/function.html#flatten) function.
2061
2062 Returns: `Any` convert nested arrays into a single flat array
2063
2064 ##### Examples
2065
2066 ###### Example usage
2067
2068 ```puppet
2069
2070 flatten(['a', ['b', ['c']]])` returns: `['a','b','c']
2071 ```
2072
2073 ### floor
2074
2075 Type: Ruby 3.x API
2076
2077 Takes a single numeric value as an argument.
2078
2079 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with
2080 a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function.
2081
2082 #### `floor()`
2083
2084 Takes a single numeric value as an argument.
2085
2086 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with
2087 a built-in [`floor`](https://puppet.com/docs/puppet/latest/function.html#floor) function.
2088
2089 Returns: `Any` the largest integer less or equal to the argument.
2090
2091 ### fqdn_rand_string
2092
2093 Type: Ruby 3.x API
2094
2095 Optionally, you can specify a character set for the function (defaults to alphanumeric).
2096
2097 Arguments
2098 * An integer, specifying the length of the resulting string.
2099 * Optionally, a string specifying the character set.
2100 * Optionally, a string specifying the seed for repeatable randomness.
2101
2102 #### Examples
2103
2104 ##### Example Usage:
2105
2106 ```puppet
2107 fqdn_rand_string(10)
2108 fqdn_rand_string(10, 'ABCDEF!@$%^')
2109 fqdn_rand_string(10, '', 'custom seed')
2110 ```
2111
2112 #### `fqdn_rand_string()`
2113
2114 Optionally, you can specify a character set for the function (defaults to alphanumeric).
2115
2116 Arguments
2117 * An integer, specifying the length of the resulting string.
2118 * Optionally, a string specifying the character set.
2119 * Optionally, a string specifying the seed for repeatable randomness.
2120
2121 Returns: `String`
2122
2123 ##### Examples
2124
2125 ###### Example Usage:
2126
2127 ```puppet
2128 fqdn_rand_string(10)
2129 fqdn_rand_string(10, 'ABCDEF!@$%^')
2130 fqdn_rand_string(10, '', 'custom seed')
2131 ```
2132
2133 ### fqdn_rotate
2134
2135 Type: Ruby 3.x API
2136
2137 Rotates an array or string a random number of times, combining the `$fqdn` fact
2138 and an optional seed for repeatable randomness.
2139
2140 #### Examples
2141
2142 ##### Example Usage:
2143
2144 ```puppet
2145 fqdn_rotate(['a', 'b', 'c', 'd'])
2146 fqdn_rotate('abcd')
2147 fqdn_rotate([1, 2, 3], 'custom seed')
2148 ```
2149
2150 #### `fqdn_rotate()`
2151
2152 The fqdn_rotate function.
2153
2154 Returns: `Any` rotated array or string
2155
2156 ##### Examples
2157
2158 ###### Example Usage:
2159
2160 ```puppet
2161 fqdn_rotate(['a', 'b', 'c', 'd'])
2162 fqdn_rotate('abcd')
2163 fqdn_rotate([1, 2, 3], 'custom seed')
2164 ```
2165
2166 ### fqdn_uuid
2167
2168 Type: Ruby 3.x API
2169
2170 Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID based
2171 on an FQDN string under the DNS namespace
2172
2173 #### Examples
2174
2175 ##### Example Usage:
2176
2177 ```puppet
2178 fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c'
2179 fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09
2180 ```
2181
2182 #### `fqdn_uuid()`
2183
2184 The fqdn_uuid function.
2185
2186 Returns: `Any` Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID
2187
2188 ##### Examples
2189
2190 ###### Example Usage:
2191
2192 ```puppet
2193 fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c'
2194 fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09
2195 ```
2196
2197 ### get_module_path
2198
2199 Type: Ruby 3.x API
2200
2201 > *Note:*
2202   that since Puppet 5.4.0 the  built-in
2203   [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory)
2204   function in Puppet does the same thing and will return the path to the first found module
2205   if given multiple values or an array.
2206
2207 #### Examples
2208
2209 ##### Example Usage:
2210
2211 ```puppet
2212 $module_path = get_module_path('stdlib')
2213 ```
2214
2215 #### `get_module_path()`
2216
2217 > *Note:*
2218   that since Puppet 5.4.0 the  built-in
2219   [`module_directory`](https://puppet.com/docs/puppet/latest/function.html#module_directory)
2220   function in Puppet does the same thing and will return the path to the first found module
2221   if given multiple values or an array.
2222
2223 Returns: `Any` Returns the absolute path of the specified module for the current
2224 environment.
2225
2226 ##### Examples
2227
2228 ###### Example Usage:
2229
2230 ```puppet
2231 $module_path = get_module_path('stdlib')
2232 ```
2233
2234 ### getparam
2235
2236 Type: Ruby 3.x API
2237
2238 Takes a resource reference and name of the parameter and
2239 returns value of resource's parameter. Note that user defined
2240 resource types are evaluated lazily.
2241
2242 Would notice: 'the value we are getting in this example'
2243
2244 > **Note** that since Puppet 4.0.0 it is possible to get a parameter value by using its data type
2245 and the [ ] operator. The example below is equivalent to a call to getparam():
2246   ```Example_resource['example_resource_instance']['param']``
2247
2248 #### Examples
2249
2250 ##### Example Usage:
2251
2252 ```puppet
2253
2254 # define a resource type with a parameter
2255 define example_resource($param) {
2256 }
2257
2258 # declare an instance of that type
2259 example_resource { "example_resource_instance":
2260     param => "'the value we are getting in this example''"
2261 }
2262
2263 # Because of order of evaluation, a second definition is needed
2264 # that will be evaluated after the first resource has been declared
2265 #
2266 define example_get_param {
2267   # This will notice the value of the parameter
2268   notice(getparam(Example_resource["example_resource_instance"], "param"))
2269 }
2270
2271 # Declare an instance of the second resource type - this will call notice
2272 example_get_param { 'show_notify': }
2273 ```
2274
2275 #### `getparam()`
2276
2277 Takes a resource reference and name of the parameter and
2278 returns value of resource's parameter. Note that user defined
2279 resource types are evaluated lazily.
2280
2281 Would notice: 'the value we are getting in this example'
2282
2283 > **Note** that since Puppet 4.0.0 it is possible to get a parameter value by using its data type
2284 and the [ ] operator. The example below is equivalent to a call to getparam():
2285   ```Example_resource['example_resource_instance']['param']``
2286
2287 Returns: `Any` value of a resource's parameter.
2288
2289 ##### Examples
2290
2291 ###### Example Usage:
2292
2293 ```puppet
2294
2295 # define a resource type with a parameter
2296 define example_resource($param) {
2297 }
2298
2299 # declare an instance of that type
2300 example_resource { "example_resource_instance":
2301     param => "'the value we are getting in this example''"
2302 }
2303
2304 # Because of order of evaluation, a second definition is needed
2305 # that will be evaluated after the first resource has been declared
2306 #
2307 define example_get_param {
2308   # This will notice the value of the parameter
2309   notice(getparam(Example_resource["example_resource_instance"], "param"))
2310 }
2311
2312 # Declare an instance of the second resource type - this will call notice
2313 example_get_param { 'show_notify': }
2314 ```
2315
2316 ### getvar
2317
2318 Type: Ruby 3.x API
2319
2320 > **Note:** from Puppet 6.0.0, the compatible function with the same name in Puppet core
2321 will be used instead of this function. The new function also has support for
2322 digging into a structured value. See the built-in
2323 [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) funct
2324
2325 #### Examples
2326
2327 ##### Example usage
2328
2329 ```puppet
2330 $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo
2331 ```
2332
2333 ##### Where namespace is stored in a string
2334
2335 ```puppet
2336 $datalocation = 'site::data'
2337 $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar
2338 ```
2339
2340 #### `getvar()`
2341
2342 > **Note:** from Puppet 6.0.0, the compatible function with the same name in Puppet core
2343 will be used instead of this function. The new function also has support for
2344 digging into a structured value. See the built-in
2345 [`getvar`](https://puppet.com/docs/puppet/latest/function.html#getvar) funct
2346
2347 Returns: `Any` undef - if variable does not exist
2348
2349 ##### Examples
2350
2351 ###### Example usage
2352
2353 ```puppet
2354 $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo
2355 ```
2356
2357 ###### Where namespace is stored in a string
2358
2359 ```puppet
2360 $datalocation = 'site::data'
2361 $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar
2362 ```
2363
2364 ### glob
2365
2366 Type: Ruby 3.x API
2367
2368 Uses same patterns as Dir#glob.
2369
2370 #### Examples
2371
2372 ##### Example Usage:
2373
2374 ```puppet
2375 $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
2376 ```
2377
2378 #### `glob()`
2379
2380 The glob function.
2381
2382 Returns: `Any` Returns an Array of file entries of a directory or an Array of directories.
2383
2384 ##### Examples
2385
2386 ###### Example Usage:
2387
2388 ```puppet
2389 $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
2390 ```
2391
2392 ### grep
2393
2394 Type: Ruby 3.x API
2395
2396 > **Note:** that since Puppet 4.0.0, the built-in
2397 [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does
2398 the "same" - as any logic can be used to filter, as opposed to just regular expressions:
2399 ```['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }```
2400
2401 #### Examples
2402
2403 ##### Example Usage:
2404
2405 ```puppet
2406 grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd']
2407 ```
2408
2409 #### `grep()`
2410
2411 > **Note:** that since Puppet 4.0.0, the built-in
2412 [`filter`](https://puppet.com/docs/puppet/latest/function.html#filter) function does
2413 the "same" - as any logic can be used to filter, as opposed to just regular expressions:
2414 ```['aaa', 'bbb', 'ccc', 'aaaddd']. filter |$x| { $x =~ 'aaa' }```
2415
2416 Returns: `Any` array of elements that match the provided regular expression.
2417
2418 ##### Examples
2419
2420 ###### Example Usage:
2421
2422 ```puppet
2423 grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd']
2424 ```
2425
2426 ### has_interface_with
2427
2428 Type: Ruby 3.x API
2429
2430 Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`.
2431
2432 #### Examples
2433
2434 ##### **Usage**
2435
2436 ```puppet
2437 has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false`
2438 has_interface_with("ipaddress", "127.0.0.1") # Returns `true`
2439 ```
2440
2441 ##### If no "kind" is given, then the presence of the interface is checked:
2442
2443 ```puppet
2444 has_interface_with("lo") # Returns `true`
2445 ```
2446
2447 #### `has_interface_with()`
2448
2449 Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`.
2450
2451 Returns: `Any` boolean values `true` or `false`
2452
2453 ##### Examples
2454
2455 ###### **Usage**
2456
2457 ```puppet
2458 has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false`
2459 has_interface_with("ipaddress", "127.0.0.1") # Returns `true`
2460 ```
2461
2462 ###### If no "kind" is given, then the presence of the interface is checked:
2463
2464 ```puppet
2465 has_interface_with("lo") # Returns `true`
2466 ```
2467
2468 ### has_ip_address
2469
2470 Type: Ruby 3.x API
2471
2472 This function iterates through the 'interfaces' fact and checks the
2473 'ipaddress_IFACE' facts, performing a simple string comparison.
2474
2475 #### `has_ip_address()`
2476
2477 This function iterates through the 'interfaces' fact and checks the
2478 'ipaddress_IFACE' facts, performing a simple string comparison.
2479
2480 Returns: `Boolean` `true` or `false`
2481
2482 ### has_ip_network
2483
2484 Type: Ruby 3.x API
2485
2486 This function iterates through the 'interfaces' fact and checks the
2487 'network_IFACE' facts, performing a simple string comparision.
2488
2489 #### `has_ip_network()`
2490
2491 This function iterates through the 'interfaces' fact and checks the
2492 'network_IFACE' facts, performing a simple string comparision.
2493
2494 Returns: `Any` Boolean value, `true` if the client has an IP address within the requested network.
2495
2496 ### has_key
2497
2498 Type: Ruby 3.x API
2499
2500 > **Note:** **Deprecated** since Puppet 4.0.0, this can now be achieved in the Puppet
2501 language with the following equivalent expression:
2502 $my_hash = {'key_one' => 'value_one'}
2503 if 'key_one' in $my_hash {
2504   notice('this will be printed')
2505
2506 #### Examples
2507
2508 ##### Example Usage:
2509
2510 ```puppet
2511
2512 $my_hash = {'key_one' => 'value_one'}
2513 if has_key($my_hash, 'key_two') {
2514   notice('we will not reach here')
2515 }
2516 if has_key($my_hash, 'key_one') {
2517   notice('this will be printed')
2518 }
2519 ```
2520
2521 #### `has_key()`
2522
2523 > **Note:** **Deprecated** since Puppet 4.0.0, this can now be achieved in the Puppet
2524 language with the following equivalent expression:
2525 $my_hash = {'key_one' => 'value_one'}
2526 if 'key_one' in $my_hash {
2527   notice('this will be printed')
2528
2529 Returns: `Any` Boolean value
2530
2531 ##### Examples
2532
2533 ###### Example Usage:
2534
2535 ```puppet
2536
2537 $my_hash = {'key_one' => 'value_one'}
2538 if has_key($my_hash, 'key_two') {
2539   notice('we will not reach here')
2540 }
2541 if has_key($my_hash, 'key_one') {
2542   notice('this will be printed')
2543 }
2544 ```
2545
2546 ### hash
2547
2548 Type: Ruby 3.x API
2549
2550 > **Note:** This function has been replaced with the built-in ability to create a new value of almost any
2551 data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function
2552 in Puppet.
2553 This example shows the equivalent expression in the Puppet language:
2554   ```
2555   Hash(['a',1,'b',2,'c',3])
2556   Hash([['a',1],['b',2],['c',3]])
2557   ```
2558
2559 #### Examples
2560
2561 ##### Example Usage:
2562
2563 ```puppet
2564 hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3}
2565 ```
2566
2567 #### `hash()`
2568
2569 > **Note:** This function has been replaced with the built-in ability to create a new value of almost any
2570 data type - see the built-in [`Hash.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-hash-and-struct) function
2571 in Puppet.
2572 This example shows the equivalent expression in the Puppet language:
2573   ```
2574   Hash(['a',1,'b',2,'c',3])
2575   Hash([['a',1],['b',2],['c',3]])
2576   ```
2577
2578 Returns: `Any` the converted array as a hash
2579
2580 ##### Examples
2581
2582 ###### Example Usage:
2583
2584 ```puppet
2585 hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3}
2586 ```
2587
2588 ### intersection
2589
2590 Type: Ruby 3.x API
2591
2592 This function returns an array of the intersection of two.
2593
2594 #### Examples
2595
2596 ##### Example Usage:
2597
2598 ```puppet
2599 intersection(["a","b","c"],["b","c","d"])  # returns ["b","c"]
2600 intersection(["a","b","c"],[1,2,3,4])      # returns [] (true, when evaluated as a Boolean)
2601 ```
2602
2603 #### `intersection()`
2604
2605 The intersection function.
2606
2607 Returns: `Any` an array of the intersection of two.
2608
2609 ##### Examples
2610
2611 ###### Example Usage:
2612
2613 ```puppet
2614 intersection(["a","b","c"],["b","c","d"])  # returns ["b","c"]
2615 intersection(["a","b","c"],[1,2,3,4])      # returns [] (true, when evaluated as a Boolean)
2616 ```
2617
2618 ### is_a
2619
2620 Type: Ruby 4.x API
2621
2622 See the documentation for "The Puppet Type System" for more information about types.
2623 See the `assert_type()` function for flexible ways to assert the type of a value.
2624
2625 #### Examples
2626
2627 ##### Example Usage:
2628
2629 ```puppet
2630 # check a data type
2631   foo = 3
2632   $bar = [1,2,3]
2633   $baz = 'A string!'
2634
2635   if $foo.is_a(Integer) {
2636     notify  { 'foo!': }
2637   }
2638   if $bar.is_a(Array) {
2639     notify { 'bar!': }
2640   }
2641   if $baz.is_a(String) {
2642     notify { 'baz!': }
2643   }
2644 ```
2645
2646 #### `is_a(Any $value, Type $type)`
2647
2648 See the documentation for "The Puppet Type System" for more information about types.
2649 See the `assert_type()` function for flexible ways to assert the type of a value.
2650
2651 Returns: `Boolean` Return's `true` or `false`.
2652
2653 ##### Examples
2654
2655 ###### Example Usage:
2656
2657 ```puppet
2658 # check a data type
2659   foo = 3
2660   $bar = [1,2,3]
2661   $baz = 'A string!'
2662
2663   if $foo.is_a(Integer) {
2664     notify  { 'foo!': }
2665   }
2666   if $bar.is_a(Array) {
2667     notify { 'bar!': }
2668   }
2669   if $baz.is_a(String) {
2670     notify { 'baz!': }
2671   }
2672 ```
2673
2674 ##### `value`
2675
2676 Data type: `Any`
2677
2678 The value to be checked
2679
2680 ##### `type`
2681
2682 Data type: `Type`
2683
2684 The expected type
2685
2686 ### is_absolute_path
2687
2688 Type: Ruby 3.x API
2689
2690 This function works for windows and unix style paths.
2691
2692 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2693 [`validate_legacy`](#validate_leg
2694
2695 #### Examples
2696
2697 ##### The following values will return true:
2698
2699 ```puppet
2700 $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
2701 is_absolute_path($my_path)
2702 $my_path2 = '/var/lib/puppet'
2703 is_absolute_path($my_path2)
2704 $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet']
2705 is_absolute_path($my_path3)
2706 $my_path4 = ['/var/lib/puppet']
2707 is_absolute_path($my_path4)
2708 ```
2709
2710 ##### The following values will return false:
2711
2712 ```puppet
2713 is_absolute_path(true)
2714 is_absolute_path('../var/lib/puppet')
2715 is_absolute_path('var/lib/puppet')
2716 $undefined = undef
2717 is_absolute_path($undefined)
2718 ```
2719
2720 #### `is_absolute_path()`
2721
2722 This function works for windows and unix style paths.
2723
2724 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2725 [`validate_legacy`](#validate_leg
2726
2727 Returns: `Boolean` Returns `true` or `false`
2728
2729 ##### Examples
2730
2731 ###### The following values will return true:
2732
2733 ```puppet
2734 $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
2735 is_absolute_path($my_path)
2736 $my_path2 = '/var/lib/puppet'
2737 is_absolute_path($my_path2)
2738 $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet']
2739 is_absolute_path($my_path3)
2740 $my_path4 = ['/var/lib/puppet']
2741 is_absolute_path($my_path4)
2742 ```
2743
2744 ###### The following values will return false:
2745
2746 ```puppet
2747 is_absolute_path(true)
2748 is_absolute_path('../var/lib/puppet')
2749 is_absolute_path('var/lib/puppet')
2750 $undefined = undef
2751 is_absolute_path($undefined)
2752 ```
2753
2754 ### is_absolute_path
2755
2756 Type: Ruby 4.x API
2757
2758 Wrapper that calls the Puppet 3.x funtion of the same name.
2759
2760 #### `is_absolute_path(Any $scope, Any *$args)`
2761
2762 The is_absolute_path function.
2763
2764 Returns: `Boolea` A boolean value returned from the called 3.x function.
2765
2766 ##### `scope`
2767
2768 Data type: `Any`
2769
2770 The main value that will be passed to the wrapped method
2771
2772 ##### `*args`
2773
2774 Data type: `Any`
2775
2776 Any additional values that are to be passed to the wrapped method
2777
2778 ### is_array
2779
2780 Type: Ruby 4.x API
2781
2782 Wrapper that calls the Puppet 3.x funtion of the same name.
2783
2784 #### `is_array(Any $scope, Any *$args)`
2785
2786 The is_array function.
2787
2788 Returns: `Boolea` A boolean value returned from the called 3.x function.
2789
2790 ##### `scope`
2791
2792 Data type: `Any`
2793
2794 The main value that will be passed to the wrapped method
2795
2796 ##### `*args`
2797
2798 Data type: `Any`
2799
2800 Any additional values that are to be passed to the wrapped method
2801
2802 ### is_array
2803
2804 Type: Ruby 3.x API
2805
2806 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2807 [`validate_legacy`](#validate_legacy).
2808
2809 #### `is_array()`
2810
2811 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2812 [`validate_legacy`](#validate_legacy).
2813
2814 Returns: `Boolean` Returns `true` or `false`
2815
2816 ### is_bool
2817
2818 Type: Ruby 4.x API
2819
2820 Wrapper that calls the Puppet 3.x funtion of the same name.
2821
2822 #### `is_bool(Any $scope, Any *$args)`
2823
2824 The is_bool function.
2825
2826 Returns: `Boolea` A boolean value returned from the called 3.x function.
2827
2828 ##### `scope`
2829
2830 Data type: `Any`
2831
2832 The main value that will be passed to the wrapped method
2833
2834 ##### `*args`
2835
2836 Data type: `Any`
2837
2838 Any additional values that are to be passed to the wrapped method
2839
2840 ### is_bool
2841
2842 Type: Ruby 3.x API
2843
2844 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2845 [`validate_legacy`](#validate_legacy).
2846
2847 #### `is_bool()`
2848
2849 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2850 [`validate_legacy`](#validate_legacy).
2851
2852 Returns: `Boolean` Returns `true` or `false`
2853
2854 ### is_domain_name
2855
2856 Type: Ruby 3.x API
2857
2858 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2859 [`validate_legacy`](#validate_legacy).
2860
2861 #### `is_domain_name()`
2862
2863 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2864 [`validate_legacy`](#validate_legacy).
2865
2866 Returns: `Boolean` Returns `true` or `false`
2867
2868 ### is_email_address
2869
2870 Type: Ruby 3.x API
2871
2872 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2873 [`validate_legacy`](#validate_legacy).
2874
2875 #### `is_email_address()`
2876
2877 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2878 [`validate_legacy`](#validate_legacy).
2879
2880 Returns: `Boolean` Returns `true` or `false`
2881
2882 ### is_float
2883
2884 Type: Ruby 4.x API
2885
2886 Wrapper that calls the Puppet 3.x funtion of the same name.
2887
2888 #### `is_float(Any $scope, Any *$args)`
2889
2890 The is_float function.
2891
2892 Returns: `Boolea` A boolean value returned from the called 3.x function.
2893
2894 ##### `scope`
2895
2896 Data type: `Any`
2897
2898 The main value that will be passed to the wrapped method
2899
2900 ##### `*args`
2901
2902 Data type: `Any`
2903
2904 Any additional values that are to be passed to the wrapped method
2905
2906 ### is_float
2907
2908 Type: Ruby 3.x API
2909
2910 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2911 [`validate_legacy`](#validate_legacy).
2912
2913 #### `is_float()`
2914
2915 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2916 [`validate_legacy`](#validate_legacy).
2917
2918 Returns: `Boolean` Returns `true` or `false`
2919
2920 ### is_function_available
2921
2922 Type: Ruby 3.x API
2923
2924 This function accepts a string as an argument.
2925
2926 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2927 [`validate_legacy`](#validate_legacy).
2928
2929 #### `is_function_available()`
2930
2931 This function accepts a string as an argument.
2932
2933 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2934 [`validate_legacy`](#validate_legacy).
2935
2936 Returns: `Boolean` Returns `true` or `false`
2937
2938 ### is_hash
2939
2940 Type: Ruby 3.x API
2941
2942 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2943 [`validate_legacy`](#validate_legacy).
2944
2945 #### `is_hash()`
2946
2947 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2948 [`validate_legacy`](#validate_legacy).
2949
2950 Returns: `Boolean` Returns `true` or `false`
2951
2952 ### is_integer
2953
2954 Type: Ruby 3.x API
2955
2956 The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0'
2957 digit may not be followed by other digits as this indicates that the value is octal (base 8).
2958
2959 If given any other argument `false` is returned.
2960
2961 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2962 [`validate_legacy`](#validate_legacy).
2963
2964 #### `is_integer()`
2965
2966 The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0'
2967 digit may not be followed by other digits as this indicates that the value is octal (base 8).
2968
2969 If given any other argument `false` is returned.
2970
2971 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2972 [`validate_legacy`](#validate_legacy).
2973
2974 Returns: `Boolean` Returns `true` or `false`
2975
2976 ### is_ip_address
2977
2978 Type: Ruby 3.x API
2979
2980 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2981 [`validate_legacy`](#validate_legacy).
2982
2983 #### `is_ip_address()`
2984
2985 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2986 [`validate_legacy`](#validate_legacy).
2987
2988 Returns: `Boolean` Returns `true` or `false`
2989
2990 ### is_ip_address
2991
2992 Type: Ruby 4.x API
2993
2994 Wrapper that calls the Puppet 3.x funtion of the same name.
2995
2996 #### `is_ip_address(Any $scope, Any *$args)`
2997
2998 The is_ip_address function.
2999
3000 Returns: `Boolea` A boolean value returned from the called 3.x function.
3001
3002 ##### `scope`
3003
3004 Data type: `Any`
3005
3006 The main value that will be passed to the wrapped method
3007
3008 ##### `*args`
3009
3010 Data type: `Any`
3011
3012 Any additional values that are to be passed to the wrapped method
3013
3014 ### is_ipv4_address
3015
3016 Type: Ruby 4.x API
3017
3018 Wrapper that calls the Puppet 3.x funtion of the same name.
3019
3020 #### `is_ipv4_address(Any $scope, Any *$args)`
3021
3022 The is_ipv4_address function.
3023
3024 Returns: `Boolea` A boolean value returned from the called 3.x function.
3025
3026 ##### `scope`
3027
3028 Data type: `Any`
3029
3030 The main value that will be passed to the wrapped method
3031
3032 ##### `*args`
3033
3034 Data type: `Any`
3035
3036 Any additional values that are to be passed to the wrapped method
3037
3038 ### is_ipv4_address
3039
3040 Type: Ruby 3.x API
3041
3042 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3043 [`validate_legacy`](#validate_legacy).
3044
3045 #### `is_ipv4_address()`
3046
3047 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3048 [`validate_legacy`](#validate_legacy).
3049
3050 Returns: `Boolean` Returns `true` or `false`
3051
3052 ### is_ipv6_address
3053
3054 Type: Ruby 3.x API
3055
3056 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3057 [`validate_legacy`](#validate_legacy).
3058
3059 #### `is_ipv6_address()`
3060
3061 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3062 [`validate_legacy`](#validate_legacy).
3063
3064 Returns: `Boolean` Returns `true` or `false`
3065
3066 ### is_ipv6_address
3067
3068 Type: Ruby 4.x API
3069
3070 Wrapper that calls the Puppet 3.x funtion of the same name.
3071
3072 #### `is_ipv6_address(Any $scope, Any *$args)`
3073
3074 The is_ipv6_address function.
3075
3076 Returns: `Boolea` A boolean value returned from the called 3.x function.
3077
3078 ##### `scope`
3079
3080 Data type: `Any`
3081
3082 The main value that will be passed to the wrapped method
3083
3084 ##### `*args`
3085
3086 Data type: `Any`
3087
3088 Any additional values that are to be passed to the wrapped method
3089
3090 ### is_mac_address
3091
3092 Type: Ruby 3.x API
3093
3094 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3095 [`validate_legacy`](#validate_legacy).
3096
3097 #### `is_mac_address()`
3098
3099 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3100 [`validate_legacy`](#validate_legacy).
3101
3102 Returns: `Boolean` Returns `true` or `false`
3103
3104 ### is_numeric
3105
3106 Type: Ruby 4.x API
3107
3108 Wrapper that calls the Puppet 3.x funtion of the same name.
3109
3110 #### `is_numeric(Any $scope, Any *$args)`
3111
3112 The is_numeric function.
3113
3114 Returns: `Boolea` A boolean value returned from the called 3.x function.
3115
3116 ##### `scope`
3117
3118 Data type: `Any`
3119
3120 The main value that will be passed to the wrapped method
3121
3122 ##### `*args`
3123
3124 Data type: `Any`
3125
3126 Any additional values that are to be passed to the wrapped method
3127
3128 ### is_numeric
3129
3130 Type: Ruby 3.x API
3131
3132 Returns true if the given argument is a Numeric (Integer or Float),
3133 or a String containing either a valid integer in decimal base 10 form, or
3134 a valid floating point string representation.
3135
3136 The function recognizes only decimal (base 10) integers and float but not
3137 integers in hex (base 16) or octal (base 8) form.
3138
3139 The string representation may start with a '-' (minus). If a decimal '.' is used,
3140 it must be followed by at least one digit.
3141
3142 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3143 [`validate_legacy`](#validate_legacy).
3144
3145 #### `is_numeric()`
3146
3147 Returns true if the given argument is a Numeric (Integer or Float),
3148 or a String containing either a valid integer in decimal base 10 form, or
3149 a valid floating point string representation.
3150
3151 The function recognizes only decimal (base 10) integers and float but not
3152 integers in hex (base 16) or octal (base 8) form.
3153
3154 The string representation may start with a '-' (minus). If a decimal '.' is used,
3155 it must be followed by at least one digit.
3156
3157 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3158 [`validate_legacy`](#validate_legacy).
3159
3160 Returns: `Boolean` Returns `true` or `false`
3161
3162 ### is_string
3163
3164 Type: Ruby 3.x API
3165
3166 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3167 [`validate_legacy`](#validate_legacy).
3168
3169 #### `is_string()`
3170
3171 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3172 [`validate_legacy`](#validate_legacy).
3173
3174 Returns: `Boolean` Returns `true` or `false`
3175
3176 ### is_string
3177
3178 Type: Ruby 4.x API
3179
3180 Wrapper that calls the Puppet 3.x funtion of the same name.
3181
3182 #### `is_string(Any $scope, Any *$args)`
3183
3184 The is_string function.
3185
3186 Returns: `Boolean` A boolean value returned from the called 3.x function.
3187
3188 ##### `scope`
3189
3190 Data type: `Any`
3191
3192 The main value that will be passed to the wrapped method
3193
3194 ##### `*args`
3195
3196 Data type: `Any`
3197
3198 Any additional values that are to be passed to the wrapped method
3199
3200 ### join
3201
3202 Type: Ruby 3.x API
3203
3204 > **Note:** **Deprecated** from Puppet 5.4.0 this function has been replaced
3205 with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function.
3206
3207 #### Examples
3208
3209 ##### Example Usage:
3210
3211 ```puppet
3212 join(['a','b','c'], ",") # Results in: "a,b,c"
3213 ```
3214
3215 #### `join()`
3216
3217 > **Note:** **Deprecated** from Puppet 5.4.0 this function has been replaced
3218 with a built-in [`join`](https://puppet.com/docs/puppet/latest/function.html#join) function.
3219
3220 Returns: `String` The String containing each of the array values
3221
3222 ##### Examples
3223
3224 ###### Example Usage:
3225
3226 ```puppet
3227 join(['a','b','c'], ",") # Results in: "a,b,c"
3228 ```
3229
3230 ### join_keys_to_values
3231
3232 Type: Ruby 3.x API
3233
3234 Keys are cast to strings. If values are arrays, multiple keys
3235 are added for each element. The return value is an array in
3236 which each element is one joined key/value pair.
3237
3238 > **Note:** Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and
3239 line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual
3240 formatting of values in the array) - see the `new` function for `String` and its formatting
3241 options for `Array` and `Hash`.
3242
3243 #### Examples
3244
3245 ##### Example Usage:
3246
3247 ```puppet
3248 join_keys_to_values({'a'=>1,'b'=>2}, " is ") # Results in: ["a is 1","b is 2"]
3249 join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") # Results in: ["a is 1","b is 2","b is 3"]
3250 ```
3251
3252 #### `join_keys_to_values()`
3253
3254 Keys are cast to strings. If values are arrays, multiple keys
3255 are added for each element. The return value is an array in
3256 which each element is one joined key/value pair.
3257
3258 > **Note:** Since Puppet 5.0.0 - for more detailed control over the formatting (including indentations and
3259 line breaks, delimiters around arrays and hash entries, between key/values in hash entries, and individual
3260 formatting of values in the array) - see the `new` function for `String` and its formatting
3261 options for `Array` and `Hash`.
3262
3263 Returns: `Hash` The joined hash
3264
3265 ##### Examples
3266
3267 ###### Example Usage:
3268
3269 ```puppet
3270 join_keys_to_values({'a'=>1,'b'=>2}, " is ") # Results in: ["a is 1","b is 2"]
3271 join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") # Results in: ["a is 1","b is 2","b is 3"]
3272 ```
3273
3274 ### keys
3275
3276 Type: Ruby 3.x API
3277
3278 > **Note:** **Deprecated** from Puppet 5.5.0, the built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys)
3279 function will be used instead of this function.
3280
3281 #### `keys()`
3282
3283 > **Note:** **Deprecated** from Puppet 5.5.0, the built-in [`keys`](https://puppet.com/docs/puppet/latest/function.html#keys)
3284 function will be used instead of this function.
3285
3286 Returns: `Array` An array containing each of the hashes key values.
3287
3288 ### length
3289
3290 Type: Ruby 4.x API
3291
3292 The original size() function did not handle Puppets new type capabilities, so this function
3293 is a Puppet 4 compatible solution.
3294
3295 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3296 built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function.
3297
3298 #### `length(Variant[String,Array,Hash] $value)`
3299
3300 The original size() function did not handle Puppets new type capabilities, so this function
3301 is a Puppet 4 compatible solution.
3302
3303 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3304 built-in [`length`](https://puppet.com/docs/puppet/latest/function.html#length) function.
3305
3306 Returns: `Integer` The length of the given object
3307
3308 ##### `value`
3309
3310 Data type: `Variant[String,Array,Hash]`
3311
3312 The value whose length is to be found
3313
3314 ### load_module_metadata
3315
3316 Type: Ruby 3.x API
3317
3318 This function loads the metadata of a given module.
3319
3320 #### Examples
3321
3322 ##### Example USage:
3323
3324 ```puppet
3325 $metadata = load_module_metadata('archive')
3326 notify { $metadata['author']: }
3327 ```
3328
3329 #### `load_module_metadata()`
3330
3331 The load_module_metadata function.
3332
3333 Returns: `Any` The modules metadata
3334
3335 ##### Examples
3336
3337 ###### Example USage:
3338
3339 ```puppet
3340 $metadata = load_module_metadata('archive')
3341 notify { $metadata['author']: }
3342 ```
3343
3344 ### loadjson
3345
3346 Type: Ruby 3.x API
3347
3348 The first parameter can be a file path or a URL.
3349 The second parameter is the default value. It will be returned if the file
3350 was not found or could not be parsed.
3351
3352 #### Examples
3353
3354 ##### Example Usage:
3355
3356 ```puppet
3357 $myhash = loadjson('/etc/puppet/data/myhash.json')
3358 $myhash = loadjson('https://example.local/my_hash.json')
3359 $myhash = loadjson('https://username:password@example.local/my_hash.json')
3360 $myhash = loadjson('no-file.json', {'default' => 'val
3361 ```
3362
3363 #### `loadjson()`
3364
3365 The first parameter can be a file path or a URL.
3366 The second parameter is the default value. It will be returned if the file
3367 was not found or could not be parsed.
3368
3369 Returns: `Array|String|Hash` The data stored in the JSON file, the type depending on the type of data that was stored.
3370
3371 ##### Examples
3372
3373 ###### Example Usage:
3374
3375 ```puppet
3376 $myhash = loadjson('/etc/puppet/data/myhash.json')
3377 $myhash = loadjson('https://example.local/my_hash.json')
3378 $myhash = loadjson('https://username:password@example.local/my_hash.json')
3379 $myhash = loadjson('no-file.json', {'default' => 'val
3380 ```
3381
3382 ### loadyaml
3383
3384 Type: Ruby 3.x API
3385
3386 The first parameter can be a file path or a URL.
3387 The second parameter is the default value. It will be returned if the file
3388 was not found or could not be parsed.
3389
3390 #### Examples
3391
3392 ##### Example Usage:
3393
3394 ```puppet
3395 $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
3396 $myhash = loadyaml('https://example.local/my_hash.yaml')
3397 $myhash = loadyaml('https://username:password@example.local/my_hash.yaml')
3398 $myhash = loadyaml('no-file.yaml', {'default' => 'val
3399 ```
3400
3401 #### `loadyaml()`
3402
3403 The first parameter can be a file path or a URL.
3404 The second parameter is the default value. It will be returned if the file
3405 was not found or could not be parsed.
3406
3407 Returns: `Array|String|Hash` The data stored in the YAML file, the type depending on the type of data that was stored.
3408
3409 ##### Examples
3410
3411 ###### Example Usage:
3412
3413 ```puppet
3414 $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
3415 $myhash = loadyaml('https://example.local/my_hash.yaml')
3416 $myhash = loadyaml('https://username:password@example.local/my_hash.yaml')
3417 $myhash = loadyaml('no-file.yaml', {'default' => 'val
3418 ```
3419
3420 ### lstrip
3421
3422 Type: Ruby 3.x API
3423
3424 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3425 built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function.
3426
3427 #### `lstrip()`
3428
3429 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3430 built-in [`max`](https://puppet.com/docs/puppet/latest/function.html#max) function.
3431
3432 Returns: `String` The stripped string
3433
3434 ### max
3435
3436 Type: Ruby 3.x API
3437
3438 Requires at least one argument.
3439
3440 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3441 built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function.
3442
3443 #### `max()`
3444
3445 Requires at least one argument.
3446
3447 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3448 built-in [`lstrip`](https://puppet.com/docs/puppet/latest/function.html#lstrip) function.
3449
3450 Returns: `Any` The highest value among those passed in
3451
3452 ### member
3453
3454 Type: Ruby 3.x API
3455
3456 The variable can be a string, fixnum, or array.
3457
3458 > **Note**: This function does not support nested arrays. If the first argument contains
3459 nested arrays, it will not recurse through them.
3460
3461 > *Note:*
3462 Since Puppet 4.0.0 the same can be performed in the Puppet language.
3463 For single values the operator `in` can be used:
3464 `'a' in ['a', 'b']  # true`
3465 For arrays by using operator `-` to compute a diff:
3466 `['d', 'b'] - ['a', 'b', 'c'] == []  # false because 'd' is not subtracted`
3467 `['a', 'b'] - ['a', 'b', 'c'] == []  # true because both 'a' and 'b' are subtracted`
3468
3469 > **Note** that since Puppet 5.2.0, the general form to test the content of an array or
3470 hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any)
3471 and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions.
3472
3473 #### Examples
3474
3475 ##### **Usage**
3476
3477 ```puppet
3478 member(['a','b'], 'b') # Returns: true
3479 member(['a', 'b', 'c'], ['a', 'b']) # Returns: true
3480 member(['a','b'], 'c') # Returns: false
3481 member(['a', 'b', 'c'], ['d', 'b']) # Returns: false
3482 ```
3483
3484 #### `member()`
3485
3486 The variable can be a string, fixnum, or array.
3487
3488 > **Note**: This function does not support nested arrays. If the first argument contains
3489 nested arrays, it will not recurse through them.
3490
3491 > *Note:*
3492 Since Puppet 4.0.0 the same can be performed in the Puppet language.
3493 For single values the operator `in` can be used:
3494 `'a' in ['a', 'b']  # true`
3495 For arrays by using operator `-` to compute a diff:
3496 `['d', 'b'] - ['a', 'b', 'c'] == []  # false because 'd' is not subtracted`
3497 `['a', 'b'] - ['a', 'b', 'c'] == []  # true because both 'a' and 'b' are subtracted`
3498
3499 > **Note** that since Puppet 5.2.0, the general form to test the content of an array or
3500 hash is to use the built-in [`any`](https://puppet.com/docs/puppet/latest/function.html#any)
3501 and [`all`](https://puppet.com/docs/puppet/latest/function.html#all) functions.
3502
3503 Returns: `Any` Returns whether the given value was a member of the array
3504
3505 ##### Examples
3506
3507 ###### **Usage**
3508
3509 ```puppet
3510 member(['a','b'], 'b') # Returns: true
3511 member(['a', 'b', 'c'], ['a', 'b']) # Returns: true
3512 member(['a','b'], 'c') # Returns: false
3513 member(['a', 'b', 'c'], ['d', 'b']) # Returns: false
3514 ```
3515
3516 ### merge
3517
3518 Type: Ruby 3.x API
3519
3520 When there is a duplicate key, the key in the rightmost hash will "win."
3521
3522 Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
3523   `$merged_hash = $hash1 + $has
3524
3525 #### Examples
3526
3527 ##### **Usage**
3528
3529 ```puppet
3530 $hash1 = {'one' => 1, 'two', => 2}
3531 $hash2 = {'two' => 'dos', 'three', => 'tres'}
3532 $merged_hash = merge($hash1, $hash2) # $merged_hash =  {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
3533 ```
3534
3535 #### `merge()`
3536
3537 When there is a duplicate key, the key in the rightmost hash will "win."
3538
3539 Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
3540   `$merged_hash = $hash1 + $has
3541
3542 Returns: `Hash` The merged hash
3543
3544 ##### Examples
3545
3546 ###### **Usage**
3547
3548 ```puppet
3549 $hash1 = {'one' => 1, 'two', => 2}
3550 $hash2 = {'two' => 'dos', 'three', => 'tres'}
3551 $merged_hash = merge($hash1, $hash2) # $merged_hash =  {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
3552 ```
3553
3554 ### merge
3555
3556 Type: Ruby 4.x API
3557
3558 When there is a duplicate key, the key in the rightmost hash will "win."
3559
3560 Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
3561  `$merged_hash = $hash1 + $hash2`
3562
3563 If merge is given a single Iterable (Array, Hash, etc.) it will call a given block with
3564 up to three parameters, and merge each resulting Hash into the accumulated result. All other types
3565 of values returned from the block (typically undef) are skipped (not merged).
3566
3567 The codeblock can take 2 or three parameters:
3568 * with two, it gets the current hash (as built to this point), and each value (for hash the value is a [key, value] tuple)
3569 * with three, it gets the current hash (as built to this point), the key/index of each value, and then the value
3570
3571 If the iterable is empty, or no hash was returned from the given block, an empty hash is returned. In the given block, a call to `next()`
3572 will skip that entry, and a call to `break()` will end the iteration.
3573
3574 The iterative `merge()` has an advantage over doing the same with a general `reduce()` in that the constructed hash
3575 does not have to be copied in each iteration and thus will perform much better with large inputs.
3576
3577 #### Examples
3578
3579 ##### Using merge()
3580
3581 ```puppet
3582 $hash1 = {'one' => 1, 'two', => 2}
3583 $hash2 = {'two' => 'dos', 'three', => 'tres'}
3584 $merged_hash = merge($hash1, $hash2) # $merged_hash =  {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
3585 ```
3586
3587 ##### counting occurrences of strings in an array
3588
3589 ```puppet
3590 ['a', 'b', 'c', 'c', 'd', 'b'].merge | $hsh, $v | { { $v => $hsh[$v].lest || { 0 } + 1 } } # results in { a => 1, b => 2, c => 2, d => 1 }
3591 ```
3592
3593 ##### skipping values for entries that are longer than 1 char
3594
3595 ```puppet
3596 ['a', 'b', 'c', 'c', 'd', 'b', 'blah', 'blah'].merge | $hsh, $v | { if $v =~ String[1,1] { { $v => $hsh[$v].lest || { 0 } + 1 } } } # results in { a => 1, b => 2, c => 2, d => 1 }
3597 ```
3598
3599 #### `merge(Variant[Hash, Undef, String[0,0]] *$args)`
3600
3601 The merge function.
3602
3603 Returns: `Hash` The merged hash
3604
3605 ##### `*args`
3606
3607 Data type: `Variant[Hash, Undef, String[0,0]]`
3608
3609 Repeated Param - The hashes that are to be merged
3610
3611 #### `merge(Iterable *$args, Callable[3,3] &$block)`
3612
3613 The merge function.
3614
3615 Returns: `Hash` The merged hash
3616
3617 ##### `*args`
3618
3619 Data type: `Iterable`
3620
3621 Repeated Param - The hashes that are to be merged
3622
3623 ##### `&block`
3624
3625 Data type: `Callable[3,3]`
3626
3627 A block placed on the repeatable param `args`
3628
3629 #### `merge(Iterable *$args, Callable[2,2] &$block)`
3630
3631 The merge function.
3632
3633 Returns: `Hash` The merged hash
3634
3635 ##### `*args`
3636
3637 Data type: `Iterable`
3638
3639 Repeated Param - The hashes that are to be merged
3640
3641 ##### `&block`
3642
3643 Data type: `Callable[2,2]`
3644
3645 A block placed on the repeatable param `args`
3646
3647 ### min
3648
3649 Type: Ruby 3.x API
3650
3651 Requires at least one argument.
3652
3653 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3654 built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function.
3655
3656 #### `min()`
3657
3658 Requires at least one argument.
3659
3660 > **Note:** **Deprecated** from Puppet 6.0.0, this function has been replaced with a
3661 built-in [`min`](https://puppet.com/docs/puppet/latest/function.html#min) function.
3662
3663 Returns: `Any` The lowest value among the given arguments
3664
3665 ### num2bool
3666
3667 Type: Ruby 3.x API
3668
3669 > *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System.
3670 See the new() function in Puppet for the many available type conversions.
3671
3672 #### `num2bool()`
3673
3674 > *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System.
3675 See the new() function in Puppet for the many available type conversions.
3676
3677 Returns: `Boolean` Boolean(0) # false for any zero or negative number
3678 Boolean(1) # true for any positive number
3679
3680 ### os_version_gte
3681
3682 Type: Ruby 4.x API
3683
3684 > *Note:*
3685 Only the major version is taken into account.
3686
3687 #### Examples
3688
3689 ##### Example usage:#
3690
3691 ```puppet
3692 if os_version_gte('Debian', '9') { }
3693 if os_version_gte('Ubuntu', '18.04') { }
3694 ```
3695
3696 #### `os_version_gte(String[1] $os, String[1] $version)`
3697
3698 > *Note:*
3699 Only the major version is taken into account.
3700
3701 Returns: `Boolean` `true` or `false
3702
3703 ##### Examples
3704
3705 ###### Example usage:#
3706
3707 ```puppet
3708 if os_version_gte('Debian', '9') { }
3709 if os_version_gte('Ubuntu', '18.04') { }
3710 ```
3711
3712 ##### `os`
3713
3714 Data type: `String[1]`
3715
3716 operating system
3717
3718 ##### `version`
3719
3720 Data type: `String[1]`
3721
3722
3723
3724 ### parsejson
3725
3726 Type: Ruby 3.x API
3727
3728 > *Note:*
3729   The optional second argument can be used to pass a default value that will
3730   be returned if the parsing of YAML string have failed.
3731
3732 #### `parsejson()`
3733
3734 > *Note:*
3735   The optional second argument can be used to pass a default value that will
3736   be returned if the parsing of YAML string have failed.
3737
3738 Returns: `Any` convert JSON into Puppet structure
3739
3740 ### parseyaml
3741
3742 Type: Ruby 3.x API
3743
3744 > *Note:*
3745   The optional second argument can be used to pass a default value that will
3746   be returned if the parsing of YAML string have failed.
3747
3748 #### `parseyaml()`
3749
3750 > *Note:*
3751   The optional second argument can be used to pass a default value that will
3752   be returned if the parsing of YAML string have failed.
3753
3754 Returns: `Any` converted YAML into Puppet structure
3755
3756 ### pick
3757
3758 Type: Ruby 3.x API
3759
3760 Typically, this function is used to check for a value in the Puppet
3761 Dashboard/Enterprise Console, and failover to a default value like the following:
3762
3763 ```$real_jenkins_version = pick($::jenkins_version, '1.449')```
3764
3765 > *Note:*
3766   The value of $real_jenkins_version will first look for a top-scope variable
3767   called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
3768   Enterprise Console are brought into Puppet as top-scope variables), and,
3769   failing that, will use a default value of 1.449.
3770
3771 #### `pick()`
3772
3773 Typically, this function is used to check for a value in the Puppet
3774 Dashboard/Enterprise Console, and failover to a default value like the following:
3775
3776 ```$real_jenkins_version = pick($::jenkins_version, '1.449')```
3777
3778 > *Note:*
3779   The value of $real_jenkins_version will first look for a top-scope variable
3780   called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
3781   Enterprise Console are brought into Puppet as top-scope variables), and,
3782   failing that, will use a default value of 1.449.
3783
3784 Returns: `Any` the first value in a list of values that is not undefined or an empty string.
3785
3786 ### pick_default
3787
3788 Type: Ruby 3.x API
3789
3790 Typically, this function is used to check for a value in the Puppet
3791 Dashboard/Enterprise Console, and failover to a default value like the
3792 following:
3793
3794   $real_jenkins_version = pick_default($::jenkins_version, '1.449')
3795
3796 > *Note:*
3797   The value of $real_jenkins_version will first look for a top-scope variable
3798   called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
3799   Enterprise Console are brought into Puppet as top-scope variables), and,
3800   failing that, will use a default value of 1.449.
3801
3802   Contrary to the pick() function, the pick_default does not fail if
3803   all arguments are empty. This allows pick_default to use an empty value as
3804   default.
3805
3806 #### `pick_default()`
3807
3808 Typically, this function is used to check for a value in the Puppet
3809 Dashboard/Enterprise Console, and failover to a default value like the
3810 following:
3811
3812   $real_jenkins_version = pick_default($::jenkins_version, '1.449')
3813
3814 > *Note:*
3815   The value of $real_jenkins_version will first look for a top-scope variable
3816   called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
3817   Enterprise Console are brought into Puppet as top-scope variables), and,
3818   failing that, will use a default value of 1.449.
3819
3820   Contrary to the pick() function, the pick_default does not fail if
3821   all arguments are empty. This allows pick_default to use an empty value as
3822   default.
3823
3824 Returns: `Any` This function is similar to a coalesce function in SQL in that it will return
3825 the first value in a list of values that is not undefined or an empty string
3826 If no value is found, it will return the last argument.
3827
3828 ### prefix
3829
3830 Type: Ruby 3.x API
3831
3832 > *Note:* since Puppet 4.0.0 the general way to modify values is in array is by using the map
3833 function in Puppet. This example does the same as the example above:
3834 ['a', 'b', 'c'].map |$x| { "p${x}" }
3835
3836 #### Examples
3837
3838 ##### **Usage**
3839
3840 ```puppet
3841
3842 prefix(['a','b','c'], 'p')
3843 Will return: ['pa','pb','pc']
3844 ```
3845
3846 #### `prefix()`
3847
3848 > *Note:* since Puppet 4.0.0 the general way to modify values is in array is by using the map
3849 function in Puppet. This example does the same as the example above:
3850 ['a', 'b', 'c'].map |$x| { "p${x}" }
3851
3852 Returns: `Hash` or [Array] The passed values now contains the passed prefix
3853
3854 ##### Examples
3855
3856 ###### **Usage**
3857
3858 ```puppet
3859
3860 prefix(['a','b','c'], 'p')
3861 Will return: ['pa','pb','pc']
3862 ```
3863
3864 ### private
3865
3866 Type: Ruby 3.x API
3867
3868 **Deprecated:** Sets the current class or definition as private.
3869 Calling the class or definition from outside the current module will fail.
3870
3871 #### `private()`
3872
3873 The private function.
3874
3875 Returns: `Any` Sets the current class or definition as private
3876
3877 ### pry
3878
3879 Type: Ruby 3.x API
3880
3881 This is useful for debugging manifest code at specific points during a compilation.
3882
3883 #### Examples
3884
3885 ##### **Usage**
3886
3887 ```puppet
3888
3889 `pry()`
3890 ```
3891
3892 #### `pry()`
3893
3894 This is useful for debugging manifest code at specific points during a compilation.
3895
3896 Returns: `Any` debugging information
3897
3898 ##### Examples
3899
3900 ###### **Usage**
3901
3902 ```puppet
3903
3904 `pry()`
3905 ```
3906
3907 ### pw_hash
3908
3909 Type: Ruby 3.x API
3910
3911 The first argument to this function is the password to hash. If it is
3912 undef or an empty string, this function returns undef.
3913
3914 The second argument to this function is which type of hash to use. It
3915 will be converted into the appropriate crypt(3) hash specifier. Valid
3916 hash types are:
3917
3918 |Hash type            |Specifier|
3919 |---------------------|---------|
3920 |MD5                  |1        |
3921 |SHA-256              |5        |
3922 |SHA-512 (recommended)|6        |
3923
3924 The third argument to this function is the salt to use.
3925
3926 > *Note:*: this uses the Puppet Master's implementation of crypt(3). If your
3927   environment contains several different operating systems, ensure that they
3928   are compatible before using this function.
3929
3930 #### `pw_hash()`
3931
3932 The first argument to this function is the password to hash. If it is
3933 undef or an empty string, this function returns undef.
3934
3935 The second argument to this function is which type of hash to use. It
3936 will be converted into the appropriate crypt(3) hash specifier. Valid
3937 hash types are:
3938
3939 |Hash type            |Specifier|
3940 |---------------------|---------|
3941 |MD5                  |1        |
3942 |SHA-256              |5        |
3943 |SHA-512 (recommended)|6        |
3944
3945 The third argument to this function is the salt to use.
3946
3947 > *Note:*: this uses the Puppet Master's implementation of crypt(3). If your
3948   environment contains several different operating systems, ensure that they
3949   are compatible before using this function.
3950
3951 Returns: `Hash` Provides a hash usable on most POSIX systems.
3952
3953 ### range
3954
3955 Type: Ruby 3.x API
3956
3957 NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail.
3958
3959 > *Note:*
3960   Passing a third argument will cause the generated range to step by that
3961   interval, e.g.
3962
3963 The Puppet Language support Integer and Float ranges by using the type system. Those are suitable for
3964 iterating a given number of times.
3965
3966  Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9
3967
3968 #### Examples
3969
3970 ##### **Usage**
3971
3972 ```puppet
3973 range("0", "9")
3974 Will return: [0,1,2,3,4,5,6,7,8,9]
3975
3976 range("00", "09")
3977 Will return: [0,1,2,3,4,5,6,7,8,9]
3978 (Zero padded strings are converted to integers automatically)
3979
3980 range("a", "c")
3981 Will return: ["a","b","c"]
3982
3983 range("host01", "host10")
3984 Will return: ["host01", "host02", ..., "host09", "host10"]
3985
3986 range("0", "9", "2")
3987 Will return: [0,2,4,6,8]
3988 ```
3989
3990 #### `range()`
3991
3992 NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail.
3993
3994 > *Note:*
3995   Passing a third argument will cause the generated range to step by that
3996   interval, e.g.
3997
3998 The Puppet Language support Integer and Float ranges by using the type system. Those are suitable for
3999 iterating a given number of times.
4000
4001  Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9
4002
4003 Returns: `Any` the range is extrapolated as an array
4004
4005 ##### Examples
4006
4007 ###### **Usage**
4008
4009 ```puppet
4010 range("0", "9")
4011 Will return: [0,1,2,3,4,5,6,7,8,9]
4012
4013 range("00", "09")
4014 Will return: [0,1,2,3,4,5,6,7,8,9]
4015 (Zero padded strings are converted to integers automatically)
4016
4017 range("a", "c")
4018 Will return: ["a","b","c"]
4019
4020 range("host01", "host10")
4021 Will return: ["host01", "host02", ..., "host09", "host10"]
4022
4023 range("0", "9", "2")
4024 Will return: [0,2,4,6,8]
4025 ```
4026
4027 ### regexpescape
4028
4029 Type: Ruby 3.x API
4030
4031 Regexp escape a string or array of strings.
4032 Requires either a single string or an array as an input.
4033
4034 #### `regexpescape()`
4035
4036 The regexpescape function.
4037
4038 Returns: `String` A string of characters with metacharacters converted to their escaped form.
4039
4040 ### reject
4041
4042 Type: Ruby 3.x API
4043
4044 > *Note:*
4045 Since Puppet 4.0.0 the same is in general done with the filter function. Here is the equivalence of the reject() function:
4046 ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~
4047
4048 #### Examples
4049
4050 ##### **Usage**
4051
4052 ```puppet
4053
4054 reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
4055
4056 Would return: ['bbb','ccc']
4057 ```
4058
4059 #### `reject()`
4060
4061 > *Note:*
4062 Since Puppet 4.0.0 the same is in general done with the filter function. Here is the equivalence of the reject() function:
4063 ['aaa','bbb','ccc','aaaddd'].filter |$x| { $x !~
4064
4065 Returns: `Any` an array containing all the elements which doesn'' match the provided regular expression
4066
4067 ##### Examples
4068
4069 ###### **Usage**
4070
4071 ```puppet
4072
4073 reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
4074
4075 Would return: ['bbb','ccc']
4076 ```
4077
4078 ### reverse
4079
4080 Type: Ruby 3.x API
4081
4082 > *Note:* that the same can be done with the reverse_each() function in Puppet.
4083
4084 #### `reverse()`
4085
4086 > *Note:* that the same can be done with the reverse_each() function in Puppet.
4087
4088 Returns: `Any` reversed string or array
4089
4090 ### round
4091
4092 Type: Ruby 3.x API
4093
4094 ```round(2.9)``` returns ```3```
4095
4096 ```round(2.4)``` returns ```2```
4097
4098 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
4099   will be used instead of this function.
4100
4101 #### `round()`
4102
4103 ```round(2.9)``` returns ```3```
4104
4105 ```round(2.4)``` returns ```2```
4106
4107 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
4108   will be used instead of this function.
4109
4110 Returns: `Any` the rounded value as integer
4111
4112 ### rstrip
4113
4114 Type: Ruby 3.x API
4115
4116 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
4117 will be used instead of this function.
4118
4119 #### `rstrip()`
4120
4121 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
4122 will be used instead of this function.
4123
4124 Returns: `Any` the string with leading spaces removed
4125
4126 ### seeded_rand
4127
4128 Type: Ruby 3.x API
4129
4130 Generates a random whole number greater than or equal to 0 and less
4131 than MAX, using the value of SEED for repeatable randomness.  If SEED
4132 starts with "$fqdn:", this is behaves the same as `fqdn_rand`.
4133
4134 #### Examples
4135
4136 ##### **Usage:**
4137
4138 ```puppet
4139 seeded_rand(MAX, SEED).
4140 MAX must be a positive integer; SEED is any string.
4141 ```
4142
4143 #### `seeded_rand()`
4144
4145 Generates a random whole number greater than or equal to 0 and less
4146 than MAX, using the value of SEED for repeatable randomness.  If SEED
4147 starts with "$fqdn:", this is behaves the same as `fqdn_rand`.
4148
4149 Returns: `Any` random number greater than or equal to 0 and less than MAX
4150
4151 ##### Examples
4152
4153 ###### **Usage:**
4154
4155 ```puppet
4156 seeded_rand(MAX, SEED).
4157 MAX must be a positive integer; SEED is any string.
4158 ```
4159
4160 ### seeded_rand_string
4161
4162 Type: Ruby 4.x API
4163
4164 Generates a consistent random string of specific length based on provided seed.
4165
4166 #### Examples
4167
4168 ##### Generate a consistently random string of length 8 with a seed:
4169
4170 ```puppet
4171 seeded_rand_string(8, "${module_name}::redis_password")
4172 ```
4173
4174 ##### Generate a random string from a specific set of characters:
4175
4176 ```puppet
4177 seeded_rand_string(5, '', 'abcdef')
4178 ```
4179
4180 #### `seeded_rand_string(Integer[1] $length, String $seed, Optional[String[2]] $charset)`
4181
4182 The seeded_rand_string function.
4183
4184 Returns: `String` Random string.
4185
4186 ##### Examples
4187
4188 ###### Generate a consistently random string of length 8 with a seed:
4189
4190 ```puppet
4191 seeded_rand_string(8, "${module_name}::redis_password")
4192 ```
4193
4194 ###### Generate a random string from a specific set of characters:
4195
4196 ```puppet
4197 seeded_rand_string(5, '', 'abcdef')
4198 ```
4199
4200 ##### `length`
4201
4202 Data type: `Integer[1]`
4203
4204 Length of string to be generated.
4205
4206 ##### `seed`
4207
4208 Data type: `String`
4209
4210 Seed string.
4211
4212 ##### `charset`
4213
4214 Data type: `Optional[String[2]]`
4215
4216 String that contains characters to use for the random string.
4217
4218 ### shell_escape
4219
4220 Type: Ruby 3.x API
4221
4222 >* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single
4223 quotes.
4224
4225 This function behaves the same as ruby's Shellwords.shellescape() function.
4226
4227 #### `shell_escape()`
4228
4229 >* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single
4230 quotes.
4231
4232 This function behaves the same as ruby's Shellwords.shellescape() function.
4233
4234 Returns: `Any` A string of characters with metacharacters converted to their escaped form.
4235
4236 ### shell_join
4237
4238 Type: Ruby 3.x API
4239
4240 Builds a command line string from the given array of strings.
4241 Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between.
4242 This function behaves the same as ruby's Shellwords.shelljoin() function
4243
4244 #### `shell_join()`
4245
4246 Builds a command line string from the given array of strings.
4247 Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between.
4248 This function behaves the same as ruby's Shellwords.shelljoin() function
4249
4250 Returns: `Any` a command line string
4251
4252 ### shell_split
4253
4254 Type: Ruby 3.x API
4255
4256 This function behaves the same as ruby's Shellwords.shellsplit() function
4257
4258 #### `shell_split()`
4259
4260 This function behaves the same as ruby's Shellwords.shellsplit() function
4261
4262 Returns: `Any` array of tokens
4263
4264 ### shuffle
4265
4266 Type: Ruby 3.x API
4267
4268 @summary
4269  Randomizes the order of a string or array elements.
4270
4271 #### `shuffle()`
4272
4273 @summary
4274  Randomizes the order of a string or array elements.
4275
4276 Returns: `Any` randomized string or array
4277
4278 ### size
4279
4280 Type: Ruby 3.x API
4281
4282 > *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions
4283 of Puppet < 5.4.0 use the stdlib length() function.
4284
4285 #### `size()`
4286
4287 > *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions
4288 of Puppet < 5.4.0 use the stdlib length() function.
4289
4290 Returns: `Any` the number of elements in a string, an array or a hash
4291
4292 ### sort
4293
4294 Type: Ruby 3.x API
4295
4296 Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this.
4297
4298 #### `sort()`
4299
4300 Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this.
4301
4302 Returns: `Any` sorted string or array
4303
4304 ### sprintf_hash
4305
4306 Type: Ruby 4.x API
4307
4308 The first parameter is format string describing how the rest of the parameters in the hash
4309 should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for
4310 all the details.
4311
4312 In the given argument hash with parameters, all keys are converted to symbols so they work
4313 with the `sprintf` function.
4314
4315 Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the
4316 `sprintf` function in puppet core.
4317
4318 #### Examples
4319
4320 ##### Format a string and number
4321
4322 ```puppet
4323 $output = sprintf_hash('String: %<foo>s / number converted to binary: %<number>b',
4324                        { 'foo' => 'a string', 'number' => 5 })
4325 # $output = 'String: a string / number converted to binary: 101'
4326 ```
4327
4328 #### `sprintf_hash(String $format, Hash $arguments)`
4329
4330 The first parameter is format string describing how the rest of the parameters in the hash
4331 should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for
4332 all the details.
4333
4334 In the given argument hash with parameters, all keys are converted to symbols so they work
4335 with the `sprintf` function.
4336
4337 Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the
4338 `sprintf` function in puppet core.
4339
4340 Returns: `Any` The formatted string.
4341
4342 ##### Examples
4343
4344 ###### Format a string and number
4345
4346 ```puppet
4347 $output = sprintf_hash('String: %<foo>s / number converted to binary: %<number>b',
4348                        { 'foo' => 'a string', 'number' => 5 })
4349 # $output = 'String: a string / number converted to binary: 101'
4350 ```
4351
4352 ##### `format`
4353
4354 Data type: `String`
4355
4356 The format to use.
4357
4358 ##### `arguments`
4359
4360 Data type: `Hash`
4361
4362 Hash with parameters.
4363
4364 ### squeeze
4365
4366 Type: Ruby 3.x API
4367
4368 Returns a new string where runs of the same character that occur in this set are replaced by a single character.
4369
4370 #### `squeeze()`
4371
4372 The squeeze function.
4373
4374 Returns: `Any` a new string where runs of the same character that occur in this set are replaced by a single character.
4375
4376 ### stdlib::extname
4377
4378 Type: Ruby 4.x API
4379
4380 If Path is a Dotfile, or starts with a Period, then the starting Dot is not
4381 dealt with the Start of the Extension.
4382
4383 An empty String will also be returned, when the Period is the last Character
4384 in Path.
4385
4386 #### Examples
4387
4388 ##### Determining the Extension of a Filename
4389
4390 ```puppet
4391 stdlib::extname('test.rb')       => '.rb'
4392 stdlib::extname('a/b/d/test.rb') => '.rb'
4393 stdlib::extname('test')          => ''
4394 stdlib::extname('.profile')      => ''
4395 ```
4396
4397 #### `stdlib::extname(String $filename)`
4398
4399 If Path is a Dotfile, or starts with a Period, then the starting Dot is not
4400 dealt with the Start of the Extension.
4401
4402 An empty String will also be returned, when the Period is the last Character
4403 in Path.
4404
4405 Returns: `String` The Extension starting from the last Period
4406
4407 ##### Examples
4408
4409 ###### Determining the Extension of a Filename
4410
4411 ```puppet
4412 stdlib::extname('test.rb')       => '.rb'
4413 stdlib::extname('a/b/d/test.rb') => '.rb'
4414 stdlib::extname('test')          => ''
4415 stdlib::extname('.profile')      => ''
4416 ```
4417
4418 ##### `filename`
4419
4420 Data type: `String`
4421
4422 The Filename
4423
4424 ### stdlib::ip_in_range
4425
4426 Type: Ruby 4.x API
4427
4428 Returns true if the ipaddress is within the given CIDRs
4429
4430 #### Examples
4431
4432 ##### ip_in_range(<IPv4 Address>, <IPv4 CIDR>)
4433
4434 ```puppet
4435 stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true
4436 ```
4437
4438 #### `stdlib::ip_in_range(String $ipaddress, Variant[String, Array] $range)`
4439
4440 The stdlib::ip_in_range function.
4441
4442 Returns: `Boolean` True or False
4443
4444 ##### Examples
4445
4446 ###### ip_in_range(<IPv4 Address>, <IPv4 CIDR>)
4447
4448 ```puppet
4449 stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true
4450 ```
4451
4452 ##### `ipaddress`
4453
4454 Data type: `String`
4455
4456 The IP address to check
4457
4458 ##### `range`
4459
4460 Data type: `Variant[String, Array]`
4461
4462 One CIDR or an array of CIDRs
4463 defining the range(s) to check against
4464
4465 ### str2bool
4466
4467 Type: Ruby 3.x API
4468
4469 > *Note:* that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value.
4470 See the function new() in Puppet for details what the Boolean data type supports.
4471
4472 #### `str2bool()`
4473
4474 > *Note:* that since Puppet 5.0.0 the Boolean data type can convert strings to a Boolean value.
4475 See the function new() in Puppet for details what the Boolean data type supports.
4476
4477 Returns: `Any` This attempt to convert to boolean strings that contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things
4478 like: 0, F,f, N,n, false, FALSE, no to 'false'.
4479
4480 ### str2saltedsha512
4481
4482 Type: Ruby 3.x API
4483
4484 Given any simple string, you will get a hex version
4485 of a salted-SHA512 password hash that can be inserted into your Puppet
4486 manifests as a valid password attribute.
4487
4488 #### `str2saltedsha512()`
4489
4490 Given any simple string, you will get a hex version
4491 of a salted-SHA512 password hash that can be inserted into your Puppet
4492 manifests as a valid password attribute.
4493
4494 Returns: `Any` converted string as a hex version of a salted-SHA512 password hash
4495
4496 ### strftime
4497
4498 Type: Ruby 3.x API
4499
4500 > *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this
4501 function. It also supports the Timestamp and Timespan data types in the Puppet language.
4502
4503 **Format meaning:**
4504
4505     %a - The abbreviated weekday name (``Sun'')
4506     %A - The  full  weekday  name (``Sunday'')
4507     %b - The abbreviated month name (``Jan'')
4508     %B - The  full  month  name (``January'')
4509     %c - The preferred local date and time representation
4510     %C - Century (20 in 2009)
4511     %d - Day of the month (01..31)
4512     %D - Date (%m/%d/%y)
4513     %e - Day of the month, blank-padded ( 1..31)
4514     %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
4515     %h - Equivalent to %b
4516     %H - Hour of the day, 24-hour clock (00..23)
4517     %I - Hour of the day, 12-hour clock (01..12)
4518     %j - Day of the year (001..366)
4519     %k - hour, 24-hour clock, blank-padded ( 0..23)
4520     %l - hour, 12-hour clock, blank-padded ( 0..12)
4521     %L - Millisecond of the second (000..999)
4522     %m - Month of the year (01..12)
4523     %M - Minute of the hour (00..59)
4524     %n - Newline (\n)
4525     %N - Fractional seconds digits, default is 9 digits (nanosecond)
4526             %3N  millisecond (3 digits)
4527             %6N  microsecond (6 digits)
4528             %9N  nanosecond (9 digits)
4529     %p - Meridian indicator (``AM''  or  ``PM'')
4530     %P - Meridian indicator (``am''  or  ``pm'')
4531     %r - time, 12-hour (same as %I:%M:%S %p)
4532     %R - time, 24-hour (%H:%M)
4533     %s - Number of seconds since 1970-01-01 00:00:00 UTC.
4534     %S - Second of the minute (00..60)
4535     %t - Tab character (\t)
4536     %T - time, 24-hour (%H:%M:%S)
4537     %u - Day of the week as a decimal, Monday being 1. (1..7)
4538     %U - Week  number  of the current year,
4539             starting with the first Sunday as the first
4540             day of the first week (00..53)
4541     %v - VMS date (%e-%b-%Y)
4542     %V - Week number of year according to ISO 8601 (01..53)
4543     %W - Week  number  of the current year,
4544             starting with the first Monday as the first
4545             day of the first week (00..53)
4546     %w - Day of the week (Sunday is 0, 0..6)
4547     %x - Preferred representation for the date alone, no time
4548     %X - Preferred representation for the time alone, no date
4549     %y - Year without a century (00..99)
4550     %Y - Year with century
4551     %z - Time zone as  hour offset from UTC (e.g. +0900)
4552     %Z - Time zone name
4553     %% - Literal ``%'' character
4554
4555 #### Examples
4556
4557 ##### **Usage**
4558
4559 ```puppet
4560
4561 To return the time since epoch: strftime("%s")
4562 To return the date: strftime("%Y-%m-%d")
4563 ```
4564
4565 #### `strftime()`
4566
4567 > *Note:* that since Puppet 4.8.0 the function with the same name in Puppet will be used instead of this
4568 function. It also supports the Timestamp and Timespan data types in the Puppet language.
4569
4570 **Format meaning:**
4571
4572     %a - The abbreviated weekday name (``Sun'')
4573     %A - The  full  weekday  name (``Sunday'')
4574     %b - The abbreviated month name (``Jan'')
4575     %B - The  full  month  name (``January'')
4576     %c - The preferred local date and time representation
4577     %C - Century (20 in 2009)
4578     %d - Day of the month (01..31)
4579     %D - Date (%m/%d/%y)
4580     %e - Day of the month, blank-padded ( 1..31)
4581     %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
4582     %h - Equivalent to %b
4583     %H - Hour of the day, 24-hour clock (00..23)
4584     %I - Hour of the day, 12-hour clock (01..12)
4585     %j - Day of the year (001..366)
4586     %k - hour, 24-hour clock, blank-padded ( 0..23)
4587     %l - hour, 12-hour clock, blank-padded ( 0..12)
4588     %L - Millisecond of the second (000..999)
4589     %m - Month of the year (01..12)
4590     %M - Minute of the hour (00..59)
4591     %n - Newline (\n)
4592     %N - Fractional seconds digits, default is 9 digits (nanosecond)
4593             %3N  millisecond (3 digits)
4594             %6N  microsecond (6 digits)
4595             %9N  nanosecond (9 digits)
4596     %p - Meridian indicator (``AM''  or  ``PM'')
4597     %P - Meridian indicator (``am''  or  ``pm'')
4598     %r - time, 12-hour (same as %I:%M:%S %p)
4599     %R - time, 24-hour (%H:%M)
4600     %s - Number of seconds since 1970-01-01 00:00:00 UTC.
4601     %S - Second of the minute (00..60)
4602     %t - Tab character (\t)
4603     %T - time, 24-hour (%H:%M:%S)
4604     %u - Day of the week as a decimal, Monday being 1. (1..7)
4605     %U - Week  number  of the current year,
4606             starting with the first Sunday as the first
4607             day of the first week (00..53)
4608     %v - VMS date (%e-%b-%Y)
4609     %V - Week number of year according to ISO 8601 (01..53)
4610     %W - Week  number  of the current year,
4611             starting with the first Monday as the first
4612             day of the first week (00..53)
4613     %w - Day of the week (Sunday is 0, 0..6)
4614     %x - Preferred representation for the date alone, no time
4615     %X - Preferred representation for the time alone, no date
4616     %y - Year without a century (00..99)
4617     %Y - Year with century
4618     %z - Time zone as  hour offset from UTC (e.g. +0900)
4619     %Z - Time zone name
4620     %% - Literal ``%'' character
4621
4622 Returns: `Any` converted time according to the directives in the given format string
4623
4624 ##### Examples
4625
4626 ###### **Usage**
4627
4628 ```puppet
4629
4630 To return the time since epoch: strftime("%s")
4631 To return the date: strftime("%Y-%m-%d")
4632 ```
4633
4634 ### strip
4635
4636 Type: Ruby 3.x API
4637
4638 > *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core
4639 will be used instead of this function.
4640
4641 #### Examples
4642
4643 ##### **Usage**
4644
4645 ```puppet
4646
4647 strip("    aaa   ")
4648 Would result in: "aaa"
4649 ```
4650
4651 #### `strip()`
4652
4653 > *Note:*: from Puppet 6.0.0, the compatible function with the same name in Puppet core
4654 will be used instead of this function.
4655
4656 Returns: `Any` String or Array converted
4657
4658 ##### Examples
4659
4660 ###### **Usage**
4661
4662 ```puppet
4663
4664 strip("    aaa   ")
4665 Would result in: "aaa"
4666 ```
4667
4668 ### suffix
4669
4670 Type: Ruby 3.x API
4671
4672 > *Note:* that since Puppet 4.0.0 the general way to modify values is in array is by using the map
4673 function in Puppet. This example does the same as the example above:
4674
4675 ```['a', 'b', 'c'].map |$x| { "${x}p" }```
4676
4677 #### Examples
4678
4679 ##### **Usage**
4680
4681 ```puppet
4682
4683 suffix(['a','b','c'], 'p')
4684 Will return: ['ap','bp','cp']
4685 ```
4686
4687 #### `suffix()`
4688
4689 > *Note:* that since Puppet 4.0.0 the general way to modify values is in array is by using the map
4690 function in Puppet. This example does the same as the example above:
4691
4692 ```['a', 'b', 'c'].map |$x| { "${x}p" }```
4693
4694 Returns: `Any` Array or Hash with updated elements containing the passed suffix
4695
4696 ##### Examples
4697
4698 ###### **Usage**
4699
4700 ```puppet
4701
4702 suffix(['a','b','c'], 'p')
4703 Will return: ['ap','bp','cp']
4704 ```
4705
4706 ### swapcase
4707
4708 Type: Ruby 3.x API
4709
4710 This function will swap the existing case of a string.
4711
4712 #### Examples
4713
4714 ##### **Usage**
4715
4716 ```puppet
4717
4718 swapcase("aBcD")
4719 Would result in: "AbCd"
4720 ```
4721
4722 #### `swapcase()`
4723
4724 The swapcase function.
4725
4726 Returns: `Any` string with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase
4727
4728 ##### Examples
4729
4730 ###### **Usage**
4731
4732 ```puppet
4733
4734 swapcase("aBcD")
4735 Would result in: "AbCd"
4736 ```
4737
4738 ### time
4739
4740 Type: Ruby 3.x API
4741
4742 > *Note:* that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and
4743 Timespan (a duration). The following example is equivalent to calling time() without
4744 any arguments:
4745
4746 ```Timestamp()```
4747
4748 #### Examples
4749
4750 ##### **Usage**
4751
4752 ```puppet
4753
4754 time()
4755 Will return something like: 1311972653
4756 ```
4757
4758 #### `time()`
4759
4760 > *Note:* that since Puppet 4.8.0 the Puppet language has the data types Timestamp (a point in time) and
4761 Timespan (a duration). The following example is equivalent to calling time() without
4762 any arguments:
4763
4764 ```Timestamp()```
4765
4766 Returns: `Any` the current time since epoch as an integer.
4767
4768 ##### Examples
4769
4770 ###### **Usage**
4771
4772 ```puppet
4773
4774 time()
4775 Will return something like: 1311972653
4776 ```
4777
4778 ### to_bytes
4779
4780 Type: Ruby 3.x API
4781
4782 Takes a single string value as an argument.
4783 These conversions reflect a layperson's understanding of
4784 1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB.
4785
4786 #### `to_bytes()`
4787
4788 Takes a single string value as an argument.
4789 These conversions reflect a layperson's understanding of
4790 1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB.
4791
4792 Returns: `Any` converted value into bytes
4793
4794 ### to_json
4795
4796 Type: Ruby 4.x API
4797
4798 Convert a data structure and output to JSON
4799
4800 #### Examples
4801
4802 ##### how to output JSON
4803
4804 ```puppet
4805 # output json to a file
4806   file { '/tmp/my.json':
4807     ensure  => file,
4808     content => to_json($myhash),
4809   }
4810 ```
4811
4812 #### `to_json(Any $data)`
4813
4814 The to_json function.
4815
4816 Returns: `Any` converted data to json
4817
4818 ##### Examples
4819
4820 ###### how to output JSON
4821
4822 ```puppet
4823 # output json to a file
4824   file { '/tmp/my.json':
4825     ensure  => file,
4826     content => to_json($myhash),
4827   }
4828 ```
4829
4830 ##### `data`
4831
4832 Data type: `Any`
4833
4834 data structure which needs to be converted into JSON
4835
4836 ### to_json_pretty
4837
4838 Type: Ruby 4.x API
4839
4840 Convert data structure and output to pretty JSON
4841
4842 #### Examples
4843
4844 ##### **Usage**
4845
4846 ```puppet
4847 * how to output pretty JSON to file
4848   file { '/tmp/my.json':
4849     ensure  => file,
4850     content => to_json_pretty($myhash),
4851   }
4852
4853 * how to output pretty JSON skipping over keys with undef values
4854   file { '/tmp/my.json':
4855     ensure  => file,
4856     content => to_json_pretty({
4857       param_one => 'value',
4858       param_two => undef,
4859     }),
4860   }
4861 ```
4862
4863 #### `to_json_pretty(Variant[Hash, Array] $data, Optional[Boolean] $skip_undef)`
4864
4865 The to_json_pretty function.
4866
4867 Returns: `Any` converted data to pretty json
4868
4869 ##### Examples
4870
4871 ###### **Usage**
4872
4873 ```puppet
4874 * how to output pretty JSON to file
4875   file { '/tmp/my.json':
4876     ensure  => file,
4877     content => to_json_pretty($myhash),
4878   }
4879
4880 * how to output pretty JSON skipping over keys with undef values
4881   file { '/tmp/my.json':
4882     ensure  => file,
4883     content => to_json_pretty({
4884       param_one => 'value',
4885       param_two => undef,
4886     }),
4887   }
4888 ```
4889
4890 ##### `data`
4891
4892 Data type: `Variant[Hash, Array]`
4893
4894 data structure which needs to be converted to pretty json
4895
4896 ##### `skip_undef`
4897
4898 Data type: `Optional[Boolean]`
4899
4900 value `true` or `false`
4901
4902 ### to_yaml
4903
4904 Type: Ruby 4.x API
4905
4906 Convert a data structure and output it as YAML
4907
4908 #### Examples
4909
4910 ##### how to output YAML
4911
4912 ```puppet
4913 # output yaml to a file
4914   file { '/tmp/my.yaml':
4915     ensure  => file,
4916     content => to_yaml($myhash),
4917   }
4918 ```
4919
4920 #### `to_yaml(Any $data)`
4921
4922 The to_yaml function.
4923
4924 Returns: `String`
4925
4926 ##### Examples
4927
4928 ###### how to output YAML
4929
4930 ```puppet
4931 # output yaml to a file
4932   file { '/tmp/my.yaml':
4933     ensure  => file,
4934     content => to_yaml($myhash),
4935   }
4936 ```
4937
4938 ##### `data`
4939
4940 Data type: `Any`
4941
4942
4943
4944 ### try_get_value
4945
4946 Type: Ruby 3.x API
4947
4948 Key can contain slashes to describe path components. The function will go down
4949 the structure and try to extract the required value.
4950 ``
4951 $data = {
4952   'a' => {
4953     'b' => [
4954       'b1',
4955       'b2',
4956       'b3',
4957     ]
4958   }
4959 }
4960
4961 $value = try_get_value($data, 'a/b/2', 'not_found', '/')
4962 => $value = 'b3'
4963 ```
4964 ```
4965 a -> first hash key
4966 b -> second hash key
4967 2 -> array index starting with 0
4968
4969 not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil.
4970 / -> (optional) path delimiter. Defaults to '/'.
4971 ```
4972
4973 In addition to the required "key" argument, "try_get_value" accepts default
4974 argument. It will be returned if no value was found or a path component is
4975 missing. And the fourth argument can set a variable path separator.
4976
4977 #### `try_get_value()`
4978
4979 Key can contain slashes to describe path components. The function will go down
4980 the structure and try to extract the required value.
4981 ``
4982 $data = {
4983   'a' => {
4984     'b' => [
4985       'b1',
4986       'b2',
4987       'b3',
4988     ]
4989   }
4990 }
4991
4992 $value = try_get_value($data, 'a/b/2', 'not_found', '/')
4993 => $value = 'b3'
4994 ```
4995 ```
4996 a -> first hash key
4997 b -> second hash key
4998 2 -> array index starting with 0
4999
5000 not_found -> (optional) will be returned if there is no value or the path did not match. Defaults to nil.
5001 / -> (optional) path delimiter. Defaults to '/'.
5002 ```
5003
5004 In addition to the required "key" argument, "try_get_value" accepts default
5005 argument. It will be returned if no value was found or a path component is
5006 missing. And the fourth argument can set a variable path separator.
5007
5008 Returns: `Any` Looks up into a complex structure of arrays and hashes and returns a value
5009 or the default value if nothing was found.
5010
5011 ### type
5012
5013 Type: Ruby 3.x API
5014
5015 please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.
5016
5017 * string
5018 * array
5019 * hash
5020 * float
5021 * integer
5022 * boolean
5023
5024 #### `type()`
5025
5026 please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.
5027
5028 * string
5029 * array
5030 * hash
5031 * float
5032 * integer
5033 * boolean
5034
5035 Returns: `Any` the type when passed a value. Type can be one of:
5036
5037 ### type3x
5038
5039 Type: Ruby 3.x API
5040
5041 * string
5042 * array
5043 * hash
5044 * float
5045 * integer
5046 * boolean
5047
5048 #### `type3x()`
5049
5050 * string
5051 * array
5052 * hash
5053 * float
5054 * integer
5055 * boolean
5056
5057 Returns: `Any` the type when passed a value. Type can be one of:
5058
5059 ### type_of
5060
5061 Type: Ruby 4.x API
5062
5063 See the documentation for "The Puppet Type System" for more information about types.
5064 See the `assert_type()` function for flexible ways to assert the type of a value.
5065
5066 The built-in type() function in puppet is generally preferred over this function
5067 this function is provided for backwards compatibility.
5068
5069 #### Examples
5070
5071 ##### how to compare values' types
5072
5073 ```puppet
5074 # compare the types of two values
5075 if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") }
5076 ```
5077
5078 ##### how to compare against an abstract type
5079
5080 ```puppet
5081 unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") }
5082 unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") }
5083 ```
5084
5085 #### `type_of(Any $value)`
5086
5087 See the documentation for "The Puppet Type System" for more information about types.
5088 See the `assert_type()` function for flexible ways to assert the type of a value.
5089
5090 The built-in type() function in puppet is generally preferred over this function
5091 this function is provided for backwards compatibility.
5092
5093 Returns: `String` the type of the passed value
5094
5095 ##### Examples
5096
5097 ###### how to compare values' types
5098
5099 ```puppet
5100 # compare the types of two values
5101 if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") }
5102 ```
5103
5104 ###### how to compare against an abstract type
5105
5106 ```puppet
5107 unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") }
5108 unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") }
5109 ```
5110
5111 ##### `value`
5112
5113 Data type: `Any`
5114
5115
5116
5117 ### union
5118
5119 Type: Ruby 3.x API
5120
5121 This function returns a union of two or more arrays.
5122
5123 #### Examples
5124
5125 ##### **Usage**
5126
5127 ```puppet
5128
5129 union(["a","b","c"],["b","c","d"])
5130 Would return: ["a","b","c","d"]
5131 ```
5132
5133 #### `union()`
5134
5135 The union function.
5136
5137 Returns: `Any` a unionized array of two or more arrays
5138
5139 ##### Examples
5140
5141 ###### **Usage**
5142
5143 ```puppet
5144
5145 union(["a","b","c"],["b","c","d"])
5146 Would return: ["a","b","c","d"]
5147 ```
5148
5149 ### unique
5150
5151 Type: Ruby 3.x API
5152
5153 This function will remove duplicates from strings and arrays.
5154
5155 #### Examples
5156
5157 ##### **Usage**
5158
5159 ```puppet
5160
5161 unique("aabbcc")
5162 Will return: abc
5163
5164 You can also use this with arrays:
5165
5166 unique(["a","a","b","b","c","c"])
5167 This returns: ["a","b","c"]
5168 ```
5169
5170 #### `unique()`
5171
5172 The unique function.
5173
5174 Returns: `Any` String or array with duplicates removed
5175
5176 ##### Examples
5177
5178 ###### **Usage**
5179
5180 ```puppet
5181
5182 unique("aabbcc")
5183 Will return: abc
5184
5185 You can also use this with arrays:
5186
5187 unique(["a","a","b","b","c","c"])
5188 This returns: ["a","b","c"]
5189 ```
5190
5191 ### unix2dos
5192
5193 Type: Ruby 3.x API
5194
5195 Takes a single string argument.
5196
5197 #### `unix2dos()`
5198
5199 Takes a single string argument.
5200
5201 Returns: `Any` the DOS version of the given string.
5202
5203 ### upcase
5204
5205 Type: Ruby 3.x API
5206
5207 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
5208 will be used instead of this function.
5209
5210 #### Examples
5211
5212 ##### **Usage**
5213
5214 ```puppet
5215
5216 upcase("abcd")
5217 Will return ABCD
5218 ```
5219
5220 #### `upcase()`
5221
5222 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
5223 will be used instead of this function.
5224
5225 Returns: `Any` converted string ot array of strings to uppercase
5226
5227 ##### Examples
5228
5229 ###### **Usage**
5230
5231 ```puppet
5232
5233 upcase("abcd")
5234 Will return ABCD
5235 ```
5236
5237 ### uriescape
5238
5239 Type: Ruby 3.x API
5240
5241 Urlencodes a string or array of strings.
5242 Requires either a single string or an array as an input.
5243
5244 #### `uriescape()`
5245
5246 The uriescape function.
5247
5248 Returns: `String` a string that contains the converted value
5249
5250 ### validate_absolute_path
5251
5252 Type: Ruby 3.x API
5253
5254 Validate the string represents an absolute path in the filesystem.  This function works
5255 for windows and unix style paths.
5256
5257 #### Examples
5258
5259 ##### **Usage**
5260
5261 ```puppet
5262
5263 The following values will pass:
5264
5265     $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
5266     validate_absolute_path($my_path)
5267     $my_path2 = '/var/lib/puppet'
5268     validate_absolute_path($my_path2)
5269     $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet']
5270     validate_absolute_path($my_path3)
5271     $my_path4 = ['/var/lib/puppet','/usr/share/puppet']
5272     validate_absolute_path($my_path4)
5273
5274 The following values will fail, causing compilation to abort:
5275
5276     validate_absolute_path(true)
5277     validate_absolute_path('../var/lib/puppet')
5278     validate_absolute_path('var/lib/puppet')
5279     validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
5280     validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
5281     $undefined = undef
5282     validate_absolute_path($undefin
5283 ```
5284
5285 #### `validate_absolute_path()`
5286
5287 The validate_absolute_path function.
5288
5289 Returns: `Any` passes when the string is an absolute path or raise an error when it is not and fails compilation
5290
5291 ##### Examples
5292
5293 ###### **Usage**
5294
5295 ```puppet
5296
5297 The following values will pass:
5298
5299     $my_path = 'C:/Program Files (x86)/Puppet Labs/Puppet'
5300     validate_absolute_path($my_path)
5301     $my_path2 = '/var/lib/puppet'
5302     validate_absolute_path($my_path2)
5303     $my_path3 = ['C:/Program Files (x86)/Puppet Labs/Puppet','C:/Program Files/Puppet Labs/Puppet']
5304     validate_absolute_path($my_path3)
5305     $my_path4 = ['/var/lib/puppet','/usr/share/puppet']
5306     validate_absolute_path($my_path4)
5307
5308 The following values will fail, causing compilation to abort:
5309
5310     validate_absolute_path(true)
5311     validate_absolute_path('../var/lib/puppet')
5312     validate_absolute_path('var/lib/puppet')
5313     validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
5314     validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
5315     $undefined = undef
5316     validate_absolute_path($undefin
5317 ```
5318
5319 ### validate_absolute_path
5320
5321 Type: Ruby 4.x API
5322
5323 Validate the string represents an absolute path in the filesystem.
5324
5325 #### `validate_absolute_path(Any $scope, Any *$args)`
5326
5327 The validate_absolute_path function.
5328
5329 Returns: `Boolean` A boolean value returned from the called function.
5330
5331 ##### `scope`
5332
5333 Data type: `Any`
5334
5335 The main value that will be passed to the method
5336
5337 ##### `*args`
5338
5339 Data type: `Any`
5340
5341 Any additional values that are to be passed to the method
5342
5343 ### validate_array
5344
5345 Type: Ruby 4.x API
5346
5347 Validate the passed value represents an array.
5348
5349 #### `validate_array(Any $scope, Any *$args)`
5350
5351 The validate_array function.
5352
5353 Returns: `Any` A boolean value (`true` or `false`) returned from the called function.
5354
5355 ##### `scope`
5356
5357 Data type: `Any`
5358
5359 The main value that will be passed to the method
5360
5361 ##### `*args`
5362
5363 Data type: `Any`
5364
5365 Any additional values that are to be passed to the method
5366
5367 ### validate_array
5368
5369 Type: Ruby 3.x API
5370
5371 Validate that all passed values are array data structures. Abort catalog
5372 compilation if any value fails this check.
5373
5374 #### Examples
5375
5376 ##### **Usage**
5377
5378 ```puppet
5379 The following values will pass:
5380
5381     $my_array = [ 'one', 'two' ]
5382     validate_array($my_array)
5383
5384 The following values will fail, causing compilation to abort:
5385
5386     validate_array(true)
5387     validate_array('some_string')
5388     $undefined = undef
5389     validate_array($undefined
5390 ```
5391
5392 #### `validate_array()`
5393
5394 The validate_array function.
5395
5396 Returns: `Any` validate array
5397
5398 ##### Examples
5399
5400 ###### **Usage**
5401
5402 ```puppet
5403 The following values will pass:
5404
5405     $my_array = [ 'one', 'two' ]
5406     validate_array($my_array)
5407
5408 The following values will fail, causing compilation to abort:
5409
5410     validate_array(true)
5411     validate_array('some_string')
5412     $undefined = undef
5413     validate_array($undefined
5414 ```
5415
5416 ### validate_augeas
5417
5418 Type: Ruby 3.x API
5419
5420 The first argument of this function should be a string to
5421 test, and the second argument should be the name of the Augeas lens to use.
5422 If Augeas fails to parse the string with the lens, the compilation will
5423 abort with a parse error.
5424
5425 A third argument can be specified, listing paths which should
5426 not be found in the file. The `$file` variable points to the location
5427 of the temporary file being tested in the Augeas tree.
5428
5429 #### Examples
5430
5431 ##### **Usage**
5432
5433 ```puppet
5434
5435 If you want to make sure your passwd content never contains
5436 a user `foo`, you could write:
5437
5438   validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
5439
5440 If you wanted to ensure that no users used the '/bin/barsh' shell,
5441 you could use:
5442
5443   validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
5444
5445 If a fourth argument is specified, this will be the error message raised and
5446 seen by the user.
5447
5448 A helpful error message can be returned like this:
5449
5450   validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
5451 ```
5452
5453 #### `validate_augeas()`
5454
5455 The first argument of this function should be a string to
5456 test, and the second argument should be the name of the Augeas lens to use.
5457 If Augeas fails to parse the string with the lens, the compilation will
5458 abort with a parse error.
5459
5460 A third argument can be specified, listing paths which should
5461 not be found in the file. The `$file` variable points to the location
5462 of the temporary file being tested in the Augeas tree.
5463
5464 Returns: `Any` validate string using an Augeas lens
5465
5466 ##### Examples
5467
5468 ###### **Usage**
5469
5470 ```puppet
5471
5472 If you want to make sure your passwd content never contains
5473 a user `foo`, you could write:
5474
5475   validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
5476
5477 If you wanted to ensure that no users used the '/bin/barsh' shell,
5478 you could use:
5479
5480   validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
5481
5482 If a fourth argument is specified, this will be the error message raised and
5483 seen by the user.
5484
5485 A helpful error message can be returned like this:
5486
5487   validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
5488 ```
5489
5490 ### validate_bool
5491
5492 Type: Ruby 3.x API
5493
5494 Validate that all passed values are either true or false. Abort catalog
5495 compilation if any value fails this check.
5496
5497 #### Examples
5498
5499 ##### **Usage**
5500
5501 ```puppet
5502
5503 The following values will pass:
5504
5505     $iamtrue = true
5506     validate_bool(true)
5507     validate_bool(true, true, false, $iamtrue)
5508
5509 The following values will fail, causing compilation to abort:
5510
5511     $some_array = [ true ]
5512     validate_bool("false")
5513     validate_bool("true")
5514     validate_bool($some_array)
5515 ```
5516
5517 #### `validate_bool()`
5518
5519 The validate_bool function.
5520
5521 Returns: `Any` validate boolean
5522
5523 ##### Examples
5524
5525 ###### **Usage**
5526
5527 ```puppet
5528
5529 The following values will pass:
5530
5531     $iamtrue = true
5532     validate_bool(true)
5533     validate_bool(true, true, false, $iamtrue)
5534
5535 The following values will fail, causing compilation to abort:
5536
5537     $some_array = [ true ]
5538     validate_bool("false")
5539     validate_bool("true")
5540     validate_bool($some_array)
5541 ```
5542
5543 ### validate_bool
5544
5545 Type: Ruby 4.x API
5546
5547 Validate the passed value represents a boolean.
5548
5549 #### `validate_bool(Any $scope, Any *$args)`
5550
5551 The validate_bool function.
5552
5553 Returns: `Boolean` `true` or `false`
5554 A boolean value returned from the called function.
5555
5556 ##### `scope`
5557
5558 Data type: `Any`
5559
5560 The main value that will be passed to the method
5561
5562 ##### `*args`
5563
5564 Data type: `Any`
5565
5566 Any additional values that are to be passed to the method
5567
5568 ### validate_cmd
5569
5570 Type: Ruby 3.x API
5571
5572 The first argument of this function should be a string to
5573 test, and the second argument should be a path to a test command
5574 taking a % as a placeholder for the file path (will default to the end).
5575 If the command, launched against a tempfile containing the passed string,
5576 returns a non-null value, compilation will abort with a parse error.
5577 If a third argument is specified, this will be the error message raised and
5578 seen by the user.
5579
5580 A helpful error message can be returned like this:
5581
5582 #### Examples
5583
5584 ##### **Usage**
5585
5586 ```puppet
5587
5588 Defaults to end of path
5589   validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
5590
5591 % as file location
5592   validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
5593 ```
5594
5595 #### `validate_cmd()`
5596
5597 The first argument of this function should be a string to
5598 test, and the second argument should be a path to a test command
5599 taking a % as a placeholder for the file path (will default to the end).
5600 If the command, launched against a tempfile containing the passed string,
5601 returns a non-null value, compilation will abort with a parse error.
5602 If a third argument is specified, this will be the error message raised and
5603 seen by the user.
5604
5605 A helpful error message can be returned like this:
5606
5607 Returns: `Any` validate of a string with an external command
5608
5609 ##### Examples
5610
5611 ###### **Usage**
5612
5613 ```puppet
5614
5615 Defaults to end of path
5616   validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
5617
5618 % as file location
5619   validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
5620 ```
5621
5622 ### validate_domain_name
5623
5624 Type: Ruby 3.x API
5625
5626 Validate that all values passed are syntactically correct domain names.
5627 Fail compilation if any value fails this check.
5628
5629 #### Examples
5630
5631 ##### **Usage**
5632
5633 ```puppet
5634
5635 The following values will pass:
5636
5637     $my_domain_name = 'server.domain.tld'
5638     validate_domain_name($my_domain_name)
5639     validate_domain_name('domain.tld', 'puppet.com', $my_domain_name)
5640
5641 The following values will fail, causing compilation to abort:
5642
5643     validate_domain_name(1)
5644     validate_domain_name(true)
5645     validate_domain_name('invalid domain')
5646     validate_domain_name('-foo.example.com')
5647     validate_domain_name('www.example.2com')
5648 ```
5649
5650 #### `validate_domain_name()`
5651
5652 The validate_domain_name function.
5653
5654 Returns: `Any` passes when the given values are syntactically correct domain names or raise an error when they are not and fails compilation
5655
5656 ##### Examples
5657
5658 ###### **Usage**
5659
5660 ```puppet
5661
5662 The following values will pass:
5663
5664     $my_domain_name = 'server.domain.tld'
5665     validate_domain_name($my_domain_name)
5666     validate_domain_name('domain.tld', 'puppet.com', $my_domain_name)
5667
5668 The following values will fail, causing compilation to abort:
5669
5670     validate_domain_name(1)
5671     validate_domain_name(true)
5672     validate_domain_name('invalid domain')
5673     validate_domain_name('-foo.example.com')
5674     validate_domain_name('www.example.2com')
5675 ```
5676
5677 ### validate_email_address
5678
5679 Type: Ruby 3.x API
5680
5681 Validate that all values passed are valid email addresses.
5682 Fail compilation if any value fails this check.
5683
5684 #### Examples
5685
5686 ##### **Usage**
5687
5688 ```puppet
5689
5690 The following values will pass:
5691
5692   $my_email = "waldo@gmail.com"
5693   validate_email_address($my_email)
5694   validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
5695
5696 The following values will fail, causing compilation to abort:
5697
5698   $some_array = [ 'bad_email@/d/efdf.com' ]
5699   validate_email_address($some_array)
5700 ```
5701
5702 #### `validate_email_address()`
5703
5704 The validate_email_address function.
5705
5706 Returns: `Any` Fail compilation if any value fails this check.
5707
5708 ##### Examples
5709
5710 ###### **Usage**
5711
5712 ```puppet
5713
5714 The following values will pass:
5715
5716   $my_email = "waldo@gmail.com"
5717   validate_email_address($my_email)
5718   validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
5719
5720 The following values will fail, causing compilation to abort:
5721
5722   $some_array = [ 'bad_email@/d/efdf.com' ]
5723   validate_email_address($some_array)
5724 ```
5725
5726 ### validate_hash
5727
5728 Type: Ruby 4.x API
5729
5730 Validate the passed value represents a hash.
5731
5732 #### `validate_hash(Any $scope, Any *$args)`
5733
5734 The validate_hash function.
5735
5736 Returns: `Any` A boolean value (`true` or `false`) returned from the called function.
5737
5738 ##### `scope`
5739
5740 Data type: `Any`
5741
5742 The main value that will be passed to the method
5743
5744 ##### `*args`
5745
5746 Data type: `Any`
5747
5748 Any additional values that are to be passed to the method
5749
5750 ### validate_hash
5751
5752 Type: Ruby 3.x API
5753
5754 Validate that all passed values are hash data structures. Abort catalog
5755 compilation if any value fails this check.
5756
5757 #### Examples
5758
5759 ##### **Usage**
5760
5761 ```puppet
5762
5763 The following values will pass:
5764
5765     $my_hash = { 'one' => 'two' }
5766     validate_hash($my_hash)
5767
5768 The following values will fail, causing compilation to abort:
5769
5770     validate_hash(true)
5771     validate_hash('some_string')
5772     $undefined = undef
5773     validate_hash($undefined)
5774 ```
5775
5776 #### `validate_hash()`
5777
5778 The validate_hash function.
5779
5780 Returns: `Any` validate hash
5781
5782 ##### Examples
5783
5784 ###### **Usage**
5785
5786 ```puppet
5787
5788 The following values will pass:
5789
5790     $my_hash = { 'one' => 'two' }
5791     validate_hash($my_hash)
5792
5793 The following values will fail, causing compilation to abort:
5794
5795     validate_hash(true)
5796     validate_hash('some_string')
5797     $undefined = undef
5798     validate_hash($undefined)
5799 ```
5800
5801 ### validate_integer
5802
5803 Type: Ruby 3.x API
5804
5805 The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
5806 The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
5807 If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check
5808 if (all elements of) the first argument are greater or equal to the given minimum.
5809 It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer.
5810
5811 #### Examples
5812
5813 ##### **Usage**
5814
5815 ```puppet
5816
5817 The following values will pass:
5818
5819   validate_integer(1)
5820   validate_integer(1, 2)
5821   validate_integer(1, 1)
5822   validate_integer(1, 2, 0)
5823   validate_integer(2, 2, 2)
5824   validate_integer(2, '', 0)
5825   validate_integer(2, undef, 0)
5826   $foo = undef
5827   validate_integer(2, $foo, 0)
5828   validate_integer([1,2,3,4,5], 6)
5829   validate_integer([1,2,3,4,5], 6, 0)
5830
5831 Plus all of the above, but any combination of values passed as strings ('1' or "1").
5832 Plus all of the above, but with (correct) combinations of negative integer values.
5833
5834 The following values will not:
5835
5836   validate_integer(true)
5837   validate_integer(false)
5838   validate_integer(7.0)
5839   validate_integer({ 1 => 2 })
5840   $foo = undef
5841   validate_integer($foo)
5842   validate_integer($foobaridontexist)
5843
5844   validate_integer(1, 0)
5845   validate_integer(1, true)
5846   validate_integer(1, '')
5847   validate_integer(1, undef)
5848   validate_integer(1, , 0)
5849   validate_integer(1, 2, 3)
5850   validate_integer(1, 3, 2)
5851   validate_integer(1, 3, true)
5852
5853 Plus all of the above, but any combination of values passed as strings ('false' or "false").
5854 Plus all of the above, but with incorrect combinations of negative integer values.
5855 Plus all of the above, but with non-integer items in arrays or maximum / minimum argument.
5856 ```
5857
5858 #### `validate_integer()`
5859
5860 The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
5861 The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
5862 If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check
5863 if (all elements of) the first argument are greater or equal to the given minimum.
5864 It will fail if the first argument is not an integer or array of integers, and if arg 2 and arg 3 are not convertable to an integer.
5865
5866 Returns: `Any` Validate that the first argument is an integer (or an array of integers). Fail compilation if any of the checks fail.
5867
5868 ##### Examples
5869
5870 ###### **Usage**
5871
5872 ```puppet
5873
5874 The following values will pass:
5875
5876   validate_integer(1)
5877   validate_integer(1, 2)
5878   validate_integer(1, 1)
5879   validate_integer(1, 2, 0)
5880   validate_integer(2, 2, 2)
5881   validate_integer(2, '', 0)
5882   validate_integer(2, undef, 0)
5883   $foo = undef
5884   validate_integer(2, $foo, 0)
5885   validate_integer([1,2,3,4,5], 6)
5886   validate_integer([1,2,3,4,5], 6, 0)
5887
5888 Plus all of the above, but any combination of values passed as strings ('1' or "1").
5889 Plus all of the above, but with (correct) combinations of negative integer values.
5890
5891 The following values will not:
5892
5893   validate_integer(true)
5894   validate_integer(false)
5895   validate_integer(7.0)
5896   validate_integer({ 1 => 2 })
5897   $foo = undef
5898   validate_integer($foo)
5899   validate_integer($foobaridontexist)
5900
5901   validate_integer(1, 0)
5902   validate_integer(1, true)
5903   validate_integer(1, '')
5904   validate_integer(1, undef)
5905   validate_integer(1, , 0)
5906   validate_integer(1, 2, 3)
5907   validate_integer(1, 3, 2)
5908   validate_integer(1, 3, true)
5909
5910 Plus all of the above, but any combination of values passed as strings ('false' or "false").
5911 Plus all of the above, but with incorrect combinations of negative integer values.
5912 Plus all of the above, but with non-integer items in arrays or maximum / minimum argument.
5913 ```
5914
5915 ### validate_integer
5916
5917 Type: Ruby 4.x API
5918
5919 Validate the passed value represents an integer.
5920
5921 #### `validate_integer(Any $scope, Any *$args)`
5922
5923 The validate_integer function.
5924
5925 Returns: `Boolean` `true` or `false`
5926 A boolean value returned from the called function.
5927
5928 ##### `scope`
5929
5930 Data type: `Any`
5931
5932 The main value that will be passed to the method
5933
5934 ##### `*args`
5935
5936 Data type: `Any`
5937
5938 Any additional values that are to be passed to the method
5939
5940 ### validate_ip_address
5941
5942 Type: Ruby 4.x API
5943
5944 Validate the passed value represents an ip_address.
5945
5946 #### `validate_ip_address(Any $scope, Any *$args)`
5947
5948 The validate_ip_address function.
5949
5950 Returns: `Boolean` `true` or `false`
5951 A boolean value returned from the called function.
5952
5953 ##### `scope`
5954
5955 Data type: `Any`
5956
5957 The main value that will be passed to the method
5958
5959 ##### `*args`
5960
5961 Data type: `Any`
5962
5963 Any additional values that are to be passed to the method
5964
5965 ### validate_ip_address
5966
5967 Type: Ruby 3.x API
5968
5969 Validate that all values passed are valid IP addresses,
5970 regardless they are IPv4 or IPv6
5971 Fail compilation if any value fails this check.
5972
5973 #### Examples
5974
5975 ##### **Usage**
5976
5977 ```puppet
5978 The following values will pass:
5979
5980   $my_ip = "1.2.3.4"
5981   validate_ip_address($my_ip)
5982   validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip)
5983
5984   $my_ip = "3ffe:505:2"
5985   validate_ip_address(1)
5986   validate_ip_address($my_ip)
5987   validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip)
5988
5989 The following values will fail, causing compilation to abort:
5990
5991   $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
5992   validate_ip_address($some_array)
5993 ```
5994
5995 #### `validate_ip_address()`
5996
5997 The validate_ip_address function.
5998
5999 Returns: `Any` passes when the given values are valid IP addresses or raise an error when they are not and fails compilation
6000
6001 ##### Examples
6002
6003 ###### **Usage**
6004
6005 ```puppet
6006 The following values will pass:
6007
6008   $my_ip = "1.2.3.4"
6009   validate_ip_address($my_ip)
6010   validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip)
6011
6012   $my_ip = "3ffe:505:2"
6013   validate_ip_address(1)
6014   validate_ip_address($my_ip)
6015   validate_ip_address("fe80::baf6:b1ff:fe19:7507", $my_ip)
6016
6017 The following values will fail, causing compilation to abort:
6018
6019   $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
6020   validate_ip_address($some_array)
6021 ```
6022
6023 ### validate_ipv4_address
6024
6025 Type: Ruby 4.x API
6026
6027 Validate the passed value represents an ipv4_address.
6028
6029 #### `validate_ipv4_address(Any $scope, Any *$args)`
6030
6031 The validate_ipv4_address function.
6032
6033 Returns: `Boolean` `true` or `false`
6034 A boolean value returned from the called function.
6035
6036 ##### `scope`
6037
6038 Data type: `Any`
6039
6040 The main value that will be passed to the method
6041
6042 ##### `*args`
6043
6044 Data type: `Any`
6045
6046 Any additional values that are to be passed to the method
6047
6048 ### validate_ipv4_address
6049
6050 Type: Ruby 3.x API
6051
6052 Validate that all values passed are valid IPv4 addresses.
6053 Fail compilation if any value fails this check.
6054
6055 #### Examples
6056
6057 ##### **Usage**
6058
6059 ```puppet
6060 The following values will pass:
6061
6062   $my_ip = "1.2.3.4"
6063   validate_ipv4_address($my_ip)
6064   validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip)
6065
6066 The following values will fail, causing compilation to abort:
6067
6068   $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
6069   validate_ipv4_address($some_array)
6070 ```
6071
6072 #### `validate_ipv4_address()`
6073
6074 The validate_ipv4_address function.
6075
6076 Returns: `Any` passes when the given values are valid IPv4 addresses or raise an error when they are not and fails compilation
6077
6078 ##### Examples
6079
6080 ###### **Usage**
6081
6082 ```puppet
6083 The following values will pass:
6084
6085   $my_ip = "1.2.3.4"
6086   validate_ipv4_address($my_ip)
6087   validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip)
6088
6089 The following values will fail, causing compilation to abort:
6090
6091   $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
6092   validate_ipv4_address($some_array)
6093 ```
6094
6095 ### validate_ipv6_address
6096
6097 Type: Ruby 4.x API
6098
6099 Validate the passed value represents an ipv6_address.
6100
6101 #### `validate_ipv6_address(Any $scope, Any *$args)`
6102
6103 The validate_ipv6_address function.
6104
6105 Returns: `Boolean` `true` or `false`
6106 A boolean value returned from the called function.
6107
6108 ##### `scope`
6109
6110 Data type: `Any`
6111
6112 The main value that will be passed to the method
6113
6114 ##### `*args`
6115
6116 Data type: `Any`
6117
6118 Any additional values that are to be passed to the method
6119
6120 ### validate_ipv6_address
6121
6122 Type: Ruby 3.x API
6123
6124 Validate that all values passed are valid IPv6 addresses.
6125 Fail compilation if any value fails this check.
6126
6127 #### Examples
6128
6129 ##### **Usage**
6130
6131 ```puppet
6132 The following values will pass:
6133
6134   $my_ip = "3ffe:505:2"
6135   validate_ipv6_address(1)
6136   validate_ipv6_address($my_ip)
6137   validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip)
6138
6139 The following values will fail, causing compilation to abort:
6140
6141   $some_array = [ true, false, "garbage string", "1.2.3.4" ]
6142   validate_ipv6_address($some_array)
6143 ```
6144
6145 #### `validate_ipv6_address()`
6146
6147 The validate_ipv6_address function.
6148
6149 Returns: `Any` passes when the given values are valid IPv6 addresses or raise an error when they are not and fails compilation
6150
6151 ##### Examples
6152
6153 ###### **Usage**
6154
6155 ```puppet
6156 The following values will pass:
6157
6158   $my_ip = "3ffe:505:2"
6159   validate_ipv6_address(1)
6160   validate_ipv6_address($my_ip)
6161   validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip)
6162
6163 The following values will fail, causing compilation to abort:
6164
6165   $some_array = [ true, false, "garbage string", "1.2.3.4" ]
6166   validate_ipv6_address($some_array)
6167 ```
6168
6169 ### validate_legacy
6170
6171 Type: Ruby 4.x API
6172
6173 Validate a value against both the target_type (new) and the previous_validation function (old).
6174
6175 #### `validate_legacy(Any $scope, Type $target_type, String $function_name, Any $value, Any *$args)`
6176
6177 The function checks a value against both the target_type (new) and the previous_validation function (old).
6178
6179 Returns: `Any` A boolean value (`true` or `false`) returned from the called function.
6180
6181 ##### `scope`
6182
6183 Data type: `Any`
6184
6185 The main value that will be passed to the method
6186
6187 ##### `target_type`
6188
6189 Data type: `Type`
6190
6191
6192
6193 ##### `function_name`
6194
6195 Data type: `String`
6196
6197
6198
6199 ##### `value`
6200
6201 Data type: `Any`
6202
6203
6204
6205 ##### `*args`
6206
6207 Data type: `Any`
6208
6209 Any additional values that are to be passed to the method
6210
6211 #### `validate_legacy(Any $scope, String $type_string, String $function_name, Any $value, Any *$args)`
6212
6213 The validate_legacy function.
6214
6215 Returns: `Any` Legacy validation method
6216
6217 ##### `scope`
6218
6219 Data type: `Any`
6220
6221 The main value that will be passed to the method
6222
6223 ##### `type_string`
6224
6225 Data type: `String`
6226
6227
6228
6229 ##### `function_name`
6230
6231 Data type: `String`
6232
6233
6234
6235 ##### `value`
6236
6237 Data type: `Any`
6238
6239
6240
6241 ##### `*args`
6242
6243 Data type: `Any`
6244
6245 Any additional values that are to be passed to the method
6246
6247 ### validate_numeric
6248
6249 Type: Ruby 3.x API
6250
6251 The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
6252 The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
6253 If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check
6254 if (all elements of) the first argument are greater or equal to the given minimum.
6255 It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric.
6256
6257 For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too.
6258
6259 #### `validate_numeric()`
6260
6261 The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max.
6262 The third argument is optional and passes a minimum.  (All elements of) the first argument has to be greater or equal to this min.
6263 If, and only if, a minimum is given, the second argument may be an empty string or undef, which will be handled to just check
6264 if (all elements of) the first argument are greater or equal to the given minimum.
6265 It will fail if the first argument is not a numeric (Integer or Float) or array of numerics, and if arg 2 and arg 3 are not convertable to a numeric.
6266
6267 For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too.
6268
6269 Returns: `Any` Validate that the first argument is a numeric value (or an array of numeric values). Fail compilation if any of the checks fail.
6270
6271 ### validate_numeric
6272
6273 Type: Ruby 4.x API
6274
6275 Validate the passed value represents a numeric value.
6276
6277 #### `validate_numeric(Any $scope, Any *$args)`
6278
6279 The validate_numeric function.
6280
6281 Returns: `Boolean` `true` or `false`
6282 A boolean value returned from the called function.
6283
6284 ##### `scope`
6285
6286 Data type: `Any`
6287
6288 The main value that will be passed to the method
6289
6290 ##### `*args`
6291
6292 Data type: `Any`
6293
6294 Any additional values that are to be passed to the method
6295
6296 ### validate_re
6297
6298 Type: Ruby 3.x API
6299
6300 The first argument of this function should be a string to
6301 test, and the second argument should be a stringified regular expression
6302 (without the // delimiters) or an array of regular expressions.  If none
6303 of the regular expressions match the string passed in, compilation will
6304 abort with a parse error.
6305 If a third argument is specified, this will be the error message raised and
6306 seen by the user.
6307
6308 > *Note:*
6309 Compilation will also abort, if the first argument is not a String. Always use
6310 quotes to force stringification:
6311 validate_re("${::operatingsystemmajrelease}", '^[57]$')
6312
6313 #### Examples
6314
6315 ##### **Usage**
6316
6317 ```puppet
6318 The following strings will validate against the regular expressions:
6319
6320     validate_re('one', '^one$')
6321     validate_re('one', [ '^one', '^two' ])
6322
6323 The following strings will fail to validate, causing compilation to abort:
6324
6325     validate_re('one', [ '^two', '^three' ])
6326
6327 A helpful error message can be returned like this:
6328
6329     validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
6330 ```
6331
6332 #### `validate_re()`
6333
6334 The first argument of this function should be a string to
6335 test, and the second argument should be a stringified regular expression
6336 (without the // delimiters) or an array of regular expressions.  If none
6337 of the regular expressions match the string passed in, compilation will
6338 abort with a parse error.
6339 If a third argument is specified, this will be the error message raised and
6340 seen by the user.
6341
6342 > *Note:*
6343 Compilation will also abort, if the first argument is not a String. Always use
6344 quotes to force stringification:
6345 validate_re("${::operatingsystemmajrelease}", '^[57]$')
6346
6347 Returns: `Any` validation of a string against one or more regular expressions.
6348
6349 ##### Examples
6350
6351 ###### **Usage**
6352
6353 ```puppet
6354 The following strings will validate against the regular expressions:
6355
6356     validate_re('one', '^one$')
6357     validate_re('one', [ '^one', '^two' ])
6358
6359 The following strings will fail to validate, causing compilation to abort:
6360
6361     validate_re('one', [ '^two', '^three' ])
6362
6363 A helpful error message can be returned like this:
6364
6365     validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
6366 ```
6367
6368 ### validate_re
6369
6370 Type: Ruby 4.x API
6371
6372 Perform validation of a string against one or more regular
6373 expressions.
6374
6375 #### `validate_re(Any $scope, Any *$args)`
6376
6377 The validate_re function.
6378
6379 Returns: `Boolean` `true` or `false` returned from the called function.
6380
6381 ##### `scope`
6382
6383 Data type: `Any`
6384
6385 The main value that will be passed to the method
6386
6387 ##### `*args`
6388
6389 Data type: `Any`
6390
6391 Any additional values that are to be passed to the method
6392 The first argument of this function should be a string to
6393 test, and the second argument should be a stringified regular expression
6394 (without the // delimiters) or an array of regular expressions
6395
6396 ### validate_slength
6397
6398 Type: Ruby 3.x API
6399
6400 Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument.
6401 An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings,
6402 and if arg 2 and arg 3 are not convertable to a number.
6403
6404 #### Examples
6405
6406 ##### **Usage**
6407
6408 ```puppet
6409 The following values will pass:
6410
6411   validate_slength("discombobulate",17)
6412   validate_slength(["discombobulate","moo"],17)
6413   validate_slength(["discombobulate","moo"],17,3)
6414
6415 The following valueis will not:
6416
6417   validate_slength("discombobulate",1)
6418   validate_slength(["discombobulate","thermometer"],5)
6419   validate_slength(["discombobulate","moo"],17,10)
6420 ```
6421
6422 #### `validate_slength()`
6423
6424 The validate_slength function.
6425
6426 Returns: `Any` validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. Fail compilation if any of the checks fail.
6427
6428 ##### Examples
6429
6430 ###### **Usage**
6431
6432 ```puppet
6433 The following values will pass:
6434
6435   validate_slength("discombobulate",17)
6436   validate_slength(["discombobulate","moo"],17)
6437   validate_slength(["discombobulate","moo"],17,3)
6438
6439 The following valueis will not:
6440
6441   validate_slength("discombobulate",1)
6442   validate_slength(["discombobulate","thermometer"],5)
6443   validate_slength(["discombobulate","moo"],17,10)
6444 ```
6445
6446 ### validate_slength
6447
6448 Type: Ruby 4.x API
6449
6450 Validate that a passed string has length less/equal with the passed value
6451
6452 #### `validate_slength(Any $scope, Any *$args)`
6453
6454 Validate that a passed string has length less/equal with the passed value
6455
6456 Returns: `Boolean` `true` or `false`
6457 A boolean value returned from the called function.
6458
6459 ##### `scope`
6460
6461 Data type: `Any`
6462
6463 The main value that will be passed to the method
6464
6465 ##### `*args`
6466
6467 Data type: `Any`
6468
6469 Any additional values that are to be passed to the method
6470
6471 ### validate_string
6472
6473 Type: Ruby 4.x API
6474
6475 Validate that all passed values are string data structures.
6476
6477 #### `validate_string(Any $scope, Any *$args)`
6478
6479 The validate_string function.
6480
6481 Returns: `Boolean` `true` or `false`
6482 A boolean value returned from the called function.
6483
6484 ##### `scope`
6485
6486 Data type: `Any`
6487
6488 The main value that will be passed to the method
6489
6490 ##### `*args`
6491
6492 Data type: `Any`
6493
6494 Any additional values that are to be passed to the method
6495
6496 ### validate_string
6497
6498 Type: Ruby 3.x API
6499
6500 > *Note:*
6501 Validate_string(undef) will not fail in this version of the
6502 functions API (incl. current and future parser). Instead, use:
6503 ```
6504   if $var == undef {
6505      fail('...')
6506     }
6507 ```
6508
6509 #### Examples
6510
6511 ##### **Usage**
6512
6513 ```puppet
6514 The following values will pass:
6515
6516     $my_string = "one two"
6517     validate_string($my_string, 'three')
6518
6519 The following values will fail, causing compilation to abort:
6520
6521     validate_string(true)
6522     validate_string([ 'some', 'array' ])
6523 ```
6524
6525 #### `validate_string()`
6526
6527 > *Note:*
6528 Validate_string(undef) will not fail in this version of the
6529 functions API (incl. current and future parser). Instead, use:
6530 ```
6531   if $var == undef {
6532      fail('...')
6533     }
6534 ```
6535
6536 Returns: `Any` Validate that all passed values are string data structures. Failed
6537 compilation if any value fails this check.
6538
6539 ##### Examples
6540
6541 ###### **Usage**
6542
6543 ```puppet
6544 The following values will pass:
6545
6546     $my_string = "one two"
6547     validate_string($my_string, 'three')
6548
6549 The following values will fail, causing compilation to abort:
6550
6551     validate_string(true)
6552     validate_string([ 'some', 'array' ])
6553 ```
6554
6555 ### validate_x509_rsa_key_pair
6556
6557 Type: Ruby 3.x API
6558
6559 ```validate_x509_rsa_key_pair($cert, $key)```
6560
6561 #### `validate_x509_rsa_key_pair()`
6562
6563 ```validate_x509_rsa_key_pair($cert, $key)```
6564
6565 Returns: `Any` Fail compilation if any value fails this check.
6566
6567 ### values
6568
6569 Type: Ruby 3.x API
6570
6571 > *Note:*
6572 From Puppet 5.5.0, the compatible function with the same name in Puppet core
6573 will be used instead of this function.
6574
6575 #### Examples
6576
6577 ##### **Usage**
6578
6579 ```puppet
6580 $hash = {
6581   'a' => 1,
6582   'b' => 2,
6583   'c' => 3,
6584 }
6585 values($hash)
6586
6587 This example would return: ```[1,2,3]```
6588 ```
6589
6590 #### `values()`
6591
6592 > *Note:*
6593 From Puppet 5.5.0, the compatible function with the same name in Puppet core
6594 will be used instead of this function.
6595
6596 Returns: `Any` array of values
6597
6598 ##### Examples
6599
6600 ###### **Usage**
6601
6602 ```puppet
6603 $hash = {
6604   'a' => 1,
6605   'b' => 2,
6606   'c' => 3,
6607 }
6608 values($hash)
6609
6610 This example would return: ```[1,2,3]```
6611 ```
6612
6613 ### values_at
6614
6615 Type: Ruby 3.x API
6616
6617 The first argument is the array you want to analyze, and the second element can
6618 be a combination of:
6619
6620 * A single numeric index
6621 * A range in the form of 'start-stop' (eg. 4-9)
6622 * An array combining the above
6623
6624 > *Note:*
6625 Since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language.
6626 A negative value is taken to be "from the end" of the array:
6627
6628 `['a', 'b', 'c', 'd'][1, 2]`   results in `['b', 'c']`
6629 `['a', 'b', 'c', 'd'][2, -1]`  results in `['c', 'd']`
6630 `['a', 'b', 'c', 'd'][1, -2]`  results in `['b', 'c']`
6631
6632 #### Examples
6633
6634 ##### **Usage**
6635
6636 ```puppet
6637
6638 values_at(['a','b','c'], 2)
6639 Would return ['c']
6640
6641 values_at(['a','b','c'], ["0-1"])
6642 Would return ['a','b']
6643
6644 values_at(['a','b','c','d','e'], [0, "2-3"])
6645 Would return ['a','c','d']
6646 ```
6647
6648 #### `values_at()`
6649
6650 The first argument is the array you want to analyze, and the second element can
6651 be a combination of:
6652
6653 * A single numeric index
6654 * A range in the form of 'start-stop' (eg. 4-9)
6655 * An array combining the above
6656
6657 > *Note:*
6658 Since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language.
6659 A negative value is taken to be "from the end" of the array:
6660
6661 `['a', 'b', 'c', 'd'][1, 2]`   results in `['b', 'c']`
6662 `['a', 'b', 'c', 'd'][2, -1]`  results in `['c', 'd']`
6663 `['a', 'b', 'c', 'd'][1, -2]`  results in `['b', 'c']`
6664
6665 Returns: `Any` an array of values identified by location
6666
6667 ##### Examples
6668
6669 ###### **Usage**
6670
6671 ```puppet
6672
6673 values_at(['a','b','c'], 2)
6674 Would return ['c']
6675
6676 values_at(['a','b','c'], ["0-1"])
6677 Would return ['a','b']
6678
6679 values_at(['a','b','c','d','e'], [0, "2-3"])
6680 Would return ['a','c','d']
6681 ```
6682
6683 ### zip
6684
6685 Type: Ruby 3.x API
6686
6687 Takes one element from first array and merges corresponding elements from second array.
6688
6689 #### Examples
6690
6691 ##### 
6692
6693 ```puppet
6694 zip(['1','2','3'],['4','5','6'])
6695 Would result in: ["1", "4"], ["2", "5"], ["3", "6"]
6696 ```
6697
6698 #### `zip()`
6699
6700 The zip function.
6701
6702 Returns: `Any` This generates a sequence of n-element arrays, where n is one more than the count of arguments.
6703
6704 ##### Examples
6705
6706 ###### 
6707
6708 ```puppet
6709 zip(['1','2','3'],['4','5','6'])
6710 Would result in: ["1", "4"], ["2", "5"], ["3", "6"]
6711 ```
6712
6713 ## Data types
6714
6715 ### Stdlib::Absolutepath
6716
6717 A strict absolutepath type
6718
6719 Alias of `Variant[Stdlib::Windowspath, Stdlib::Unixpath]`
6720
6721 ### Stdlib::Base32
6722
6723 Type to match base32 String
6724
6725 Alias of `Pattern[/^[a-z2-7]+={,6}$/, /^[A-Z2-7]+={,6}$/]`
6726
6727 ### Stdlib::Base64
6728
6729 Type to match base64 String
6730
6731 Alias of `Pattern[/^[a-zA-Z0-9\/\+]+={,2}$/]`
6732
6733 ### Stdlib::Compat::Absolute_path
6734
6735 Emulate the is_absolute_path and validate_absolute_path functions
6736
6737 The first pattern is originally from is_absolute_path, which had it from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path?
6738 slash = '[\\\\/]'
6739 name = '[^\\\\/]+'
6740 %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
6741
6742 Alias of `Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]]`
6743
6744 ### Stdlib::Compat::Array
6745
6746 Emulate the is_array and validate_array functions
6747
6748 Alias of `Array[Any]`
6749
6750 ### Stdlib::Compat::Bool
6751
6752 Emulate the is_bool and validate_bool functions
6753
6754 Alias of `Boolean`
6755
6756 ### Stdlib::Compat::Float
6757
6758 Emulate the is_float function
6759 The regex is what's currently used in is_float
6760 To keep your development moving forward, you can also add a deprecation warning using the Integer type:
6761
6762 ```class example($value) { validate_float($value,) }```
6763
6764 would turn into
6765
6766 ```
6767 class example(Stdlib::Compat::Float $value) {
6768   validate_float($value, 10, 0)
6769   assert_type(Integer[0, 10], $value) |$expected, $actual| {
6770     warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
6771   }
6772 }
6773 ```
6774
6775 This allows you to find all places where a consumers of your code call it with unexpected values.
6776
6777 Alias of `Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]]`
6778
6779 ### Stdlib::Compat::Hash
6780
6781 Emulate the is_hash and validate_hash functions
6782
6783 Alias of `Hash[Any, Any]`
6784
6785 ### Stdlib::Compat::Integer
6786
6787 Emulate the is_integer and validate_integer functions
6788 The regex is what's currently used in is_integer
6789 validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function.
6790 For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything.
6791 To keep your development moving forward, you can also add a deprecation warning using the Integer type:
6792
6793 ```class example($value) { validate_integer($value, 10, 0) }```
6794
6795 would turn into
6796
6797 ```
6798 class example(Stdlib::Compat::Integer $value) {
6799   validate_numeric($value, 10, 0)
6800   assert_type(Integer[0, 10], $value) |$expected, $actual| {
6801     warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
6802   }
6803 }
6804 ```
6805
6806 > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers.
6807
6808 This allows you to find all places where a consumers of your code call it with unexpected values.
6809
6810 Alias of `Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]]`
6811
6812 ### Stdlib::Compat::Ip_address
6813
6814 The Stdlib::Compat::Ip_address data type.
6815
6816 Alias of `Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]`
6817
6818 ### Stdlib::Compat::Ipv4
6819
6820 Emulate the validate_ipv4_address and is_ipv4_address functions
6821
6822 Alias of `Pattern[/^((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d)))(\/((([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]){3}([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))|[0-9]+))?$/]`
6823
6824 ### Stdlib::Compat::Ipv6
6825
6826 The Stdlib::Compat::Ipv6 data type.
6827
6828 Alias of `Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/]`
6829
6830 ### Stdlib::Compat::Numeric
6831
6832 Emulate the is_numeric and validate_numeric functions
6833 The regex is what's currently used in is_numeric
6834 validate_numeric also allows range checking, which cannot be mapped to the string parsing inside the function.
6835 For full backwards compatibility, you will need to keep the validate_numeric call around to catch everything.
6836 To keep your development moving forward, you can also add a deprecation warning using the Integer type:
6837
6838 ```class example($value) { validate_numeric($value, 10, 0) }```
6839
6840 would turn into
6841
6842 ```
6843 class example(Stdlib::Compat::Numeric $value) {
6844   validate_numeric($value, 10, 0)
6845   assert_type(Integer[0, 10], $value) |$expected, $actual| {
6846     warning("The 'value' parameter for the 'ntp' class has type ${actual}, but should be ${expected}.")
6847   }
6848 }
6849 ```
6850
6851 > Note that you need to use Variant[Integer[0, 10], Float[0, 10]] if you want to match both integers and floating point numbers.
6852
6853 This allows you to find all places where a consumers of your code call it with unexpected values.
6854
6855 Alias of `Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]]`
6856
6857 ### Stdlib::Compat::String
6858
6859 Emulate the is_string and validate_string functions
6860
6861 Alias of `Optional[String]`
6862
6863 ### Stdlib::Ensure::Service
6864
6865 The Stdlib::Ensure::Service data type.
6866
6867 Alias of `Enum['stopped', 'running']`
6868
6869 ### Stdlib::Filemode
6870
6871 See `man chmod.1` for the regular expression for symbolic mode
6872
6873 Alias of `Pattern[/^(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))$/]`
6874
6875 ### Stdlib::Filesource
6876
6877 Validate the source parameter on file types
6878
6879 Alias of `Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[
6880     /^file:\/\/\/([^\/\0]+(\/)?)+$/,
6881     /^puppet:\/\/(([\w-]+\.?)+)?\/([^\/\0]+(\/)?)+$/,
6882   ]]`
6883
6884 ### Stdlib::Fqdn
6885
6886 The Stdlib::Fqdn data type.
6887
6888 Alias of `Pattern[/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/]`
6889
6890 ### Stdlib::HTTPSUrl
6891
6892 The Stdlib::HTTPSUrl data type.
6893
6894 Alias of `Pattern[/(?i:^https:\/\/)/]`
6895
6896 ### Stdlib::HTTPUrl
6897
6898 The Stdlib::HTTPUrl data type.
6899
6900 Alias of `Pattern[/(?i:^https?:\/\/)/]`
6901
6902 ### Stdlib::Host
6903
6904 The Stdlib::Host data type.
6905
6906 Alias of `Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]`
6907
6908 ### Stdlib::IP::Address
6909
6910 The Stdlib::IP::Address data type.
6911
6912 Alias of `Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6]`
6913
6914 ### Stdlib::IP::Address::Nosubnet
6915
6916 The Stdlib::IP::Address::Nosubnet data type.
6917
6918 Alias of `Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet]`
6919
6920 ### Stdlib::IP::Address::V4
6921
6922 The Stdlib::IP::Address::V4 data type.
6923
6924 Alias of `Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet]`
6925
6926 ### Stdlib::IP::Address::V4::CIDR
6927
6928 The Stdlib::IP::Address::V4::CIDR data type.
6929
6930 Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([0-9]|[12][0-9]|3[0-2])\z/]`
6931
6932 ### Stdlib::IP::Address::V4::Nosubnet
6933
6934 The Stdlib::IP::Address::V4::Nosubnet data type.
6935
6936 Alias of `Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]`
6937
6938 ### Stdlib::IP::Address::V6
6939
6940 The Stdlib::IP::Address::V6 data type.
6941
6942 Alias of `Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet]`
6943
6944 ### Stdlib::IP::Address::V6::Alternative
6945
6946 The Stdlib::IP::Address::V6::Alternative data type.
6947
6948 Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]`
6949
6950 ### Stdlib::IP::Address::V6::CIDR
6951
6952 The Stdlib::IP::Address::V6::CIDR data type.
6953
6954 Alias of `Pattern[/\A((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])?\z/]`
6955
6956 ### Stdlib::IP::Address::V6::Compressed
6957
6958 The Stdlib::IP::Address::V6::Compressed data type.
6959
6960 Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/, /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]`
6961
6962 ### Stdlib::IP::Address::V6::Full
6963
6964 The Stdlib::IP::Address::V6::Full data type.
6965
6966 Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9]))?\z/]`
6967
6968 ### Stdlib::IP::Address::V6::Nosubnet
6969
6970 The Stdlib::IP::Address::V6::Nosubnet data type.
6971
6972 Alias of `Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative]`
6973
6974 ### Stdlib::IP::Address::V6::Nosubnet::Alternative
6975
6976 The Stdlib::IP::Address::V6::Nosubnet::Alternative data type.
6977
6978 Alias of `Pattern[/\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/]`
6979
6980 ### Stdlib::IP::Address::V6::Nosubnet::Compressed
6981
6982 The Stdlib::IP::Address::V6::Nosubnet::Compressed data type.
6983
6984 Alias of `Pattern[/\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, /\A([[:xdigit:]]{1,4}:){7}:\z/]`
6985
6986 ### Stdlib::IP::Address::V6::Nosubnet::Full
6987
6988 The Stdlib::IP::Address::V6::Nosubnet::Full data type.
6989
6990 Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/]`
6991
6992 ### Stdlib::MAC
6993
6994 A type for a MAC address
6995
6996 Alias of `Pattern[/^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/, /^([0-9A-Fa-f]{2}[:-]){19}([0-9A-Fa-f]{2})$/]`
6997
6998 ### Stdlib::ObjectStore
6999
7000 The Stdlib::ObjectStore data type.
7001
7002 Alias of `Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri]`
7003
7004 ### Stdlib::ObjectStore::GSUri
7005
7006 The Stdlib::ObjectStore::GSUri data type.
7007
7008 Alias of `Pattern[/^gs:\/\//]`
7009
7010 ### Stdlib::ObjectStore::S3Uri
7011
7012 The Stdlib::ObjectStore::S3Uri data type.
7013
7014 Alias of `Pattern[/^s3:\/\//]`
7015
7016 ### Stdlib::Port
7017
7018 The Stdlib::Port data type.
7019
7020 Alias of `Integer[0, 65535]`
7021
7022 ### Stdlib::Port::Privileged
7023
7024 The Stdlib::Port::Privileged data type.
7025
7026 Alias of `Integer[1, 1023]`
7027
7028 ### Stdlib::Port::Unprivileged
7029
7030 The Stdlib::Port::Unprivileged data type.
7031
7032 Alias of `Integer[1024, 65535]`
7033
7034 ### Stdlib::Syslogfacility
7035
7036 The Stdlib::Syslogfacility data type.
7037
7038 Alias of `Enum['kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'solaris-cron', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7']`
7039
7040 ### Stdlib::Unixpath
7041
7042 this regex rejects any path component that does not start with "/" or is NUL
7043
7044 Alias of `Pattern[/^\/([^\/\0]+\/*)*$/]`
7045
7046 ### Stdlib::Windowspath
7047
7048 The Stdlib::Windowspath data type.
7049
7050 Alias of `Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/]`
7051
7052 ### Stdlib::Yes_no
7053
7054 The Stdlib::Yes_no data type.
7055
7056 Alias of `Pattern[/\A(?i:(yes|no))\z/]`
7057