2 <!-- DO NOT EDIT: This document was generated by Puppet Strings -->
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.
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.
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
62 * [`ensure_resources`](#ensure_resources): Takes a resource type, title (only hash), and a list of attributes that describe a
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
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
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
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
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
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
137 * [`parseyaml`](#parseyaml): This function accepts YAML as a string and converts it into the correct
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
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
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
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
229 * [`validate_re`](#validate_re): Perform validation of a string against one or more regular
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
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.
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):
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.
300 Declares all other classes in the stdlib module. Currently, this consists
305 Declares various run-stages for deploying infrastructure,
306 language runtimes, and application layers.
308 The high level stages are (in order):
325 class { java: stage => 'runtime' }
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.
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.
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': }
352 # These two resources "anchor" the composed classes within the ntp
354 anchor { 'ntp::begin': } -> Class['ntp::package']
355 Class['ntp::service'] -> anchor { 'ntp::end': }
359 This allows the end user of the ntp module to establish require and before
360 relationships with Class['ntp']:
363 class { 'ntp': } -> class { 'mcollective': }
364 class { 'mcollective': } -> class { 'ntp': }
369 The following parameters are available in the `anchor` type.
375 The name of the anchor resource.
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.
386 file_line { 'sudo_rule':
387 path => '/etc/sudoers',
388 line => '%sudo ALL=(ALL) ALL',
391 file_line { 'sudo_rule_nopw':
392 path => '/etc/sudoers',
393 line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
396 In this example, Puppet will ensure both of the specified lines are
397 contained in the file /etc/sudoers.
402 file_line { 'bashrc_proxy':
404 path => '/etc/bashrc',
405 line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
406 match => '^export\ HTTP_PROXY\=',
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.
413 * Examples With `ensure => absent`:
415 This type has two behaviors when `ensure => absent` is set.
417 One possibility is to set `match => ...` and `match_for_absence => true`,
418 as in the following example:
421 file_line { 'bashrc_proxy':
423 path => '/etc/bashrc',
424 match => '^export\ HTTP_PROXY\=',
425 match_for_absence => true,
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.
433 Note that the `line => ...` parameter would be accepted BUT IGNORED in
436 The second way of using `ensure => absent` is to specify a `line => ...`,
440 file_line { 'bashrc_proxy':
442 path => '/etc/bashrc',
443 line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
448 When ensuring lines are absent this way, the default behavior
449 this time is to always remove all lines matching, and this behavior
455 file_line { "XScreenSaver":
457 path => '/root/XScreenSaver',
458 line => "*lock: 10:00:00",
460 encoding => "iso-8859-1",
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
470 **Autorequires:** If Puppet is managing the file that will contain the line
471 being managed, the file_line resource will autorequire that file.
475 The following properties are available in the `file_line` type.
479 Valid values: present, absent
481 Manage the state of this type.
483 Default value: present
487 The line to be appended to the file or used to replace matches found by the match attribute.
491 The following parameters are available in the `file_line` type.
497 An arbitrary name used as the identity of the resource.
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.
506 ##### `match_for_absence`
508 Valid values: `true`, `false`
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.
515 Default value: `false`
519 Valid values: `true`, `false`
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
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.
531 The file Puppet will ensure contains the line specified by the line parameter.
535 Valid values: `true`, `false`
537 If true, replace line that matches. If false, do not write line if a match is found
539 Default value: `true`
541 ##### `replace_all_matches_not_matching_line`
543 Valid values: `true`, `false`
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.
547 Default value: `false`
551 For files that are not UTF-8 encoded, specify encoding such as iso-8859-1
555 ##### `append_on_no_match`
557 Valid values: `true`, `false`
559 If true, append line if match is not found. If false, do not append line if a match is not found
561 Default value: `true`
569 For example -34.56 becomes 34.56.
570 Takes a single integer or float value as an argument.
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.
578 For example -34.56 becomes 34.56.
579 Takes a single integer or float value as an argument.
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.
585 Returns: `Any` The absolute value of the given number if it was an Integer
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.
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..
601 $hsh = {'key' => 42, 'another-key' => 100}
605 Would notice `[['key', 42], ['another-key', 100]]`
607 The Array data type also has a special mode to "create an array if not already an array"
610 notice(Array({'key' => 42, 'another-key' => 100}, true))
613 Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being
614 transformed into an array.
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.
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..
628 $hsh = {'key' => 42, 'another-key' => 100}
632 Would notice `[['key', 42], ['another-key', 100]]`
634 The Array data type also has a special mode to "create an array if not already an array"
637 notice(Array({'key' => 42, 'another-key' => 100}, true))
640 Would notice `[{'key' => 42, 'another-key' => 100}]`, as the `true` flag prevents the hash from being
641 transformed into an array.
643 Returns: `Array` The new array containing the given object
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
657 Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
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
670 Also see the built-in [`Boolean.new`](https://puppet.com/docs/puppet/latest/function.html#conversion-to-boolean)
673 Returns: `Boolean` The boolean value of the object that was given
679 Calling the class or definition from outside the current module will fail.
681 #### `assert_private()`
683 Calling the class or definition from outside the current module will fail.
685 Returns: `Any` set the current class or definition as private.
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.
702 Encode and decode a string
704 $encodestring = base64('encode', 'thestring')
705 $decodestring = base64('decode', 'dGhlc3RyaW5n')
707 Explicitly define encode/decode method: default, strict, urlsafe
710 $encodestring = base64('encode', 'thestring', $method)
711 $decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
713 Encode a string as if it was binary
715 $encodestring = String(Binary('thestring', '%s'))
717 Decode a Binary assuming it is an UTF-8 String
719 $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
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.
729 Returns: `String` The encoded/decoded va
737 Encode and decode a string
739 $encodestring = base64('encode', 'thestring')
740 $decodestring = base64('decode', 'dGhlc3RyaW5n')
742 Explicitly define encode/decode method: default, strict, urlsafe
745 $encodestring = base64('encode', 'thestring', $method)
746 $decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
748 Encode a string as if it was binary
750 $encodestring = String(Binary('thestring', '%s'))
752 Decode a Binary assuming it is an UTF-8 String
754 $decodestring = String(Binary("dGhlc3RyaW5n"), "%s")
761 Strips directory (and optional suffix) from a filename
765 The basename function.
767 Returns: `String` The stripped filename
775 false, f, 0, n, and no to 0
776 true, t, 1, y, and yes to 1
778 Requires a single boolean or string as an input.
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.
788 notice(Integer(false)) # Notices 0
789 notice(Float(true)) # Notices 1.0
796 false, f, 0, n, and no to 0
797 true, t, 1, y, and yes to 1
799 Requires a single boolean or string as an input.
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.
809 notice(Integer(false)) # Notices 0
810 notice(Float(true)) # Notices 1.0
813 Returns: `Integer` The converted value as a number
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'.
823 **Examples of usage**
826 bool2str(true) => 'true'
827 bool2str(true, 'yes', 'no') => 'yes'
828 bool2str(false, 't', 'f') => 'f'
831 Requires a single boolean as an input.
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.
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'
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'.
852 **Examples of usage**
855 bool2str(true) => 'true'
856 bool2str(true, 'yes', 'no') => 'yes'
857 bool2str(false, 't', 'f') => 'f'
860 Requires a single boolean as an input.
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.
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'
875 Returns: `Any` The converted value to string of the given Boolean
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)
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)
893 Returns: `String` The converted String, if it was a String that was given
899 Requires either a single string or an array as an input.
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)
908 Requires either a single string or an array as an input.
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)
915 Returns: `String` The converted String, if it was a String that was given
921 Takes a single numeric value as an argument.
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.
929 Takes a single numeric value as an argument.
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.
935 Returns: `Integer` The rounded value
941 For example `hello\n` becomes `hello`.
942 Requires a single string or array as an input.
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.
950 For example `hello\n` becomes `hello`.
951 Requires a single string or array as an input.
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.
957 Returns: `String` The converted String, if it was a String that was given
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.
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.
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.
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.
981 Returns: `String` The given String, sans the last character.
987 Strings are converted and compared numerically. Arrays of values are flattened
988 into a list for further handling.
991 From Puppet 6.0.0 this can be done with only core Puppet like this:
992 `[$minval, $maxval, $value_to_clamp].sort[1]`
1000 clamp('24', [575, 187])` returns 187.
1001 clamp(16, 88, 661)` returns 88.
1002 clamp([4, 3, '99'])` returns 4.
1007 Strings are converted and compared numerically. Arrays of values are flattened
1008 into a list for further handling.
1011 From Puppet 6.0.0 this can be done with only core Puppet like this:
1012 `[$minval, $maxval, $value_to_clamp].sort[1]`
1014 Returns: `Array[Integer]` The sorted Array
1018 ###### Example usage
1022 clamp('24', [575, 187])` returns 187.
1023 clamp(16, 88, 661)` returns 88.
1024 clamp([4, 3, '99'])` returns 4.
1032 Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and
1033 merge of hashes, and the `<<`` operator for appending:
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]]`
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']
1052 Since Puppet 4.0, you can use the `+`` operator for concatenation of arrays and
1053 merge of hashes, and the `<<`` operator for appending:
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]]`
1059 Returns: `Array` The single concatenated array
1063 ###### Example usage
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']
1075 convert_base(5, 2)` results in: `'101'`
1076 convert_base('254', '16')` results in: `'fe'`
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:
1083 `$binary_repr = String(5, '%b')` return `"101"`
1084 `$hex_repr = String(254, "%x")` return `"fe"`
1085 `$hex_repr = String(254, "%#x")` return `"0xfe"`
1087 @return [String] The converted value as a Str
1097 #### `convert_base()`
1099 convert_base(5, 2)` results in: `'101'`
1100 convert_base('254', '16')` results in: `'fe'`
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:
1107 `$binary_repr = String(5, '%b')` return `"101"`
1108 `$hex_repr = String(254, "%x")` return `"fe"`
1109 `$hex_repr = String(254, "%#x")` return `"0xfe"`
1111 @return [String] The converted value as a Str
1113 Returns: `Any` converted value as a string
1117 ###### Example usage
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.
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.
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).
1137 Example below shows counting values that are not undef.
1139 ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)```
1141 Would notice the value 2.
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.
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.
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).
1155 Example below shows counting values that are not undef.
1157 ```notice([42, "hello", undef].filter |$x| { $x =~ NotUndef }.length)```
1159 Would notice the value 2.
1161 Returns: `Integer` The amount of elements counted within the array
1167 Recursively merges two or more hashes together and returns the resulting hash.
1175 $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
1176 $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
1177 $merged_hash = deep_merge($hash1, $hash2)
1179 The resulting hash is equivalent to:
1181 $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
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."
1189 The deep_merge function.
1191 Returns: `Hash` The merged h
1195 ###### Example usage
1199 $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
1200 $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
1201 $merged_hash = deep_merge($hash1, $hash2)
1203 The resulting hash is equivalent to:
1205 $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
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."
1211 ### defined_with_params
1215 Returns `true` if a resource with the specified attributes has already been added
1216 to the catalog, and `false` otherwise.
1223 if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
1224 user { 'dan': ensure => present, }
1228 #### `defined_with_params()`
1230 Returns `true` if a resource with the specified attributes has already been added
1231 to the catalog, and `false` otherwise.
1238 if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
1239 user { 'dan': ensure => present, }
1243 Returns: `Boolean` returns `true` or `false`
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'])`
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')`
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.
1266 delete(['a','b','c','b'], 'b')
1267 Would return: ['a','c']
1269 delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
1270 Would return: {'a'=>1,'c'=>3}
1272 delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
1273 Would return: {'a'=>1}
1275 delete('abracadabra', 'bra')
1276 Would return: 'acada'
1278 ['a', 'b', 'c', 'b'] - 'b'
1279 Would return: ['a', 'c']
1281 {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
1282 Would return: {'a' => '1'}
1284 'abracadabra'.regsubst(/bra/, '', 'G')
1285 Would return: 'acada'
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'])`
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')`
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.
1301 Returns: `String` The filtered String, if one was given.
1305 ###### Example usage
1309 delete(['a','b','c','b'], 'b')
1310 Would return: ['a','c']
1312 delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
1313 Would return: {'a'=>1,'c'=>3}
1315 delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
1316 Would return: {'a'=>1}
1318 delete('abracadabra', 'bra')
1319 Would return: 'acada'
1321 ['a', 'b', 'c', 'b'] - 'b'
1322 Would return: ['a', 'c']
1324 {'a'=>1,'b'=>2,'c'=>3} - ['b','c'])
1325 Would return: {'a' => '1'}
1327 'abracadabra'.regsubst(/bra/, '', 'G')
1328 Would return: 'acada'
1336 ```delete_at(['a','b','c'], 1)```
1338 Would return: `['a','c']`
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:
1344 ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }```
1346 Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]:
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
1357 ```delete_at(['a','b','c'], 1)```
1359 Would return: `['a','c']`
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:
1365 ```['a', 'b', 'c'].filter |$pos, $val | { $pos != 1 }```
1367 Or if a delete is wanted from the beginning or end of the array, by using the slice operator [ ]:
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
1375 Returns: `Array` The given array, now missing the tar
1381 Multiple regular expressions are assumed to be matched as an OR.
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']
1395 delete_regex(['a','b','c','b'], 'b')
1396 Would return: ['a','c']
1398 delete_regex(['a','b','c','b'], ['b', 'c'])
1401 delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
1402 Would return: {'a'=>1,'c'=>3}
1404 delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
1405 Would return: {'b'=>2,'c'=>3}
1408 #### `delete_regex()`
1410 Multiple regular expressions are assumed to be matched as an OR.
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']
1418 Returns: `Array` The given array now missing all targeted values.
1422 ###### Example usage
1426 delete_regex(['a','b','c','b'], 'b')
1427 Would return: ['a','c']
1429 delete_regex(['a','b','c','b'], ['b', 'c'])
1432 delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
1433 Would return: {'a'=>1,'c'=>3}
1435 delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
1436 Would return: {'b'=>2,'c'=>3}
1439 ### delete_undef_values
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 }
1455 $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
1456 Would return: {a => 'A', b => '', d => false}
1459 $array = delete_undef_values(['A','',undef,false])
1460 Would return: ['A','',false]
1463 #### `delete_undef_values()`
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 }
1471 Returns: `Array` The given array now issing of undefined values.
1475 ###### Example usage
1479 $hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
1480 Would return: {a => 'A', b => '', d => false}
1483 $array = delete_undef_values(['A','',undef,false])
1484 Would return: ['A','',false]
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' }
1503 delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
1504 Would return: {'a'=>'A','c'=>'C','B'=>'D'}
1507 #### `delete_values()`
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' }
1515 Returns: `Hash` The given hash now missing all instances of the targeted value
1519 ###### Example usage
1523 delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
1524 Would return: {'a'=>'A','c'=>'C','B'=>'D'}
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.).
1534 #### `deprecation()`
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.).
1539 Returns: `String` return deprecation warnings
1545 Function to print deprecation warnings, Logs a warning once for a given key.
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.
1554 #### `deprecation(String $key, String $message)`
1556 Function to print deprecation warnings, Logs a warning once for a given key.
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.
1565 Returns: `Any` deprecated warnings
1583 The returned array is a copy of the original array, removing any items that
1584 also appear in the second array.
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']`
1597 difference(["a","b","c"],["b","c","d"])
1598 Would return: `["a"]`
1603 The returned array is a copy of the original array, removing any items that
1604 also appear in the second array.
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']`
1611 Returns: `Array` The difference between the two given arrays
1615 ###### Example usage
1619 difference(["a","b","c"],["b","c","d"])
1620 Would return: `["a"]`
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
1642 $value = dig($data, ['a', 'b', 2])
1645 # with all possible options
1646 $value = dig($data, ['a', 'b', 2], 'not_found')
1649 # using the default value
1650 $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
1651 # $value = 'not_found'
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.
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.
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
1680 $value = dig($data, ['a', 'b', 2])
1683 # with all possible options
1684 $value = dig($data, ['a', 'b', 2], 'not_found')
1687 # using the default value
1688 $value = dig($data, ['a', 'b', 'c', 'd'], 'not_found')
1689 # $value = 'not_found'
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.
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.
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.
1708 Key can contain slashes to describe path components. The function will go down
1709 the structure and try to extract the required value.
1722 $value = dig44($data, ['a', 'b', 2])
1725 # with all possible options
1726 $value = dig44($data, ['a', 'b', 2], 'not_found')
1729 # using the default value
1730 $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
1731 # $value = 'not_found'
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
1740 Key can contain slashes to describe path components. The function will go down
1741 the structure and try to extract the required value.
1754 $value = dig44($data, ['a', 'b', 2])
1757 # with all possible options
1758 $value = dig44($data, ['a', 'b', 2], 'not_found')
1761 # using the default value
1762 $value = dig44($data, ['a', 'b', 'c', 'd'], 'not_found')
1763 # $value = 'not_found'
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
1770 Returns: `String` 'not_found' will be returned if nothing is found
1776 Returns the dirname of a path.
1780 The dirname function.
1782 Returns: `String` the given path's dirname
1788 Takes a single string argument.
1792 Takes a single string argument.
1794 Returns: `Any` The retrieved version
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.
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.
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.
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.
1814 Returns: `String` The converted String, if it was a String that was given
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.
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.
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.
1835 Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
1837 #### `enclose_ipv6()`
1839 The enclose_ipv6 function.
1841 Returns: `Any` encloses the ipv6 addresses with square brackets.
1847 It optionally takes a hash as a second parameter that will be passed as the
1848 third argument to the ensure_resource() function.
1850 #### `ensure_packages()`
1852 It optionally takes a hash as a second parameter that will be passed as the
1853 third argument to the ensure_resource() function.
1855 Returns: `Any` install the passed packages
1871 Creates the resource if it does not already exist:
1873 ensure_resource('user', 'dan', {'ensure' => 'present' })
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.
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.
1882 ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
1885 #### `ensure_resource()`
1891 Returns: `Any` created or recreated the passed resource with the passed type and attributes
1895 ###### Example usage
1899 Creates the resource if it does not already exist:
1901 ensure_resource('user', 'dan', {'ensure' => 'present' })
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.
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.
1910 ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
1913 ### ensure_resources
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.
1920 ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
1932 ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
1946 #### `ensure_resources()`
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.
1951 ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' }, 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
1963 ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
1965 Returns: `Any` created resources with the passed type and attributes
1969 ###### Example usage
1983 Supports the use of dot-notation for referring to structured facts. If a fact requested
1984 does not exist, returns Undef.
1988 ##### Example usage:
1992 fact('os.architecture')
1995 ##### Array indexing:
1998 fact('mountpoints."/dev".options.1')
2001 ##### Fact containing a "." in the name:
2004 fact('vmware."VRA.version"')
2007 #### `fact(String $fact_name)`
2009 Supports the use of dot-notation for referring to structured facts. If a fact requested
2010 does not exist, returns Undef.
2012 Returns: `Any` All information retrieved on the given fact_name
2016 ###### Example usage:
2020 fact('os.architecture')
2023 ###### Array indexing:
2026 fact('mountpoints."/dev".options.1')
2029 ###### Fact containing a "." in the name:
2032 fact('vmware."VRA.version"')
2039 The name of the fact to check
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.
2054 flatten(['a', ['b', ['c']]])` returns: `['a','b','c']
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.
2062 Returns: `Any` convert nested arrays into a single flat array
2066 ###### Example usage
2070 flatten(['a', ['b', ['c']]])` returns: `['a','b','c']
2077 Takes a single numeric value as an argument.
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.
2084 Takes a single numeric value as an argument.
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.
2089 Returns: `Any` the largest integer less or equal to the argument.
2091 ### fqdn_rand_string
2095 Optionally, you can specify a character set for the function (defaults to alphanumeric).
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.
2104 ##### Example Usage:
2107 fqdn_rand_string(10)
2108 fqdn_rand_string(10, 'ABCDEF!@$%^')
2109 fqdn_rand_string(10, '', 'custom seed')
2112 #### `fqdn_rand_string()`
2114 Optionally, you can specify a character set for the function (defaults to alphanumeric).
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.
2125 ###### Example Usage:
2128 fqdn_rand_string(10)
2129 fqdn_rand_string(10, 'ABCDEF!@$%^')
2130 fqdn_rand_string(10, '', 'custom seed')
2137 Rotates an array or string a random number of times, combining the `$fqdn` fact
2138 and an optional seed for repeatable randomness.
2142 ##### Example Usage:
2145 fqdn_rotate(['a', 'b', 'c', 'd'])
2147 fqdn_rotate([1, 2, 3], 'custom seed')
2150 #### `fqdn_rotate()`
2152 The fqdn_rotate function.
2154 Returns: `Any` rotated array or string
2158 ###### Example Usage:
2161 fqdn_rotate(['a', 'b', 'c', 'd'])
2163 fqdn_rotate([1, 2, 3], 'custom seed')
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
2175 ##### Example Usage:
2178 fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c'
2179 fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09
2184 The fqdn_uuid function.
2186 Returns: `Any` Returns a [RFC 4122](https://tools.ietf.org/html/rfc4122) valid version 5 UUID
2190 ###### Example Usage:
2193 fqdn_uuid('puppetlabs.com') # Returns '9c70320f-6815-5fc5-ab0f-debe68bf764c'
2194 fqdn_uuid('google.com') # Returns '64ee70a4-8cc1-5d25-abf2-dea6c79a09
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.
2209 ##### Example Usage:
2212 $module_path = get_module_path('stdlib')
2215 #### `get_module_path()`
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.
2223 Returns: `Any` Returns the absolute path of the specified module for the current
2228 ###### Example Usage:
2231 $module_path = get_module_path('stdlib')
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.
2242 Would notice: 'the value we are getting in this example'
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']``
2250 ##### Example Usage:
2254 # define a resource type with a parameter
2255 define example_resource($param) {
2258 # declare an instance of that type
2259 example_resource { "example_resource_instance":
2260 param => "'the value we are getting in this example''"
2263 # Because of order of evaluation, a second definition is needed
2264 # that will be evaluated after the first resource has been declared
2266 define example_get_param {
2267 # This will notice the value of the parameter
2268 notice(getparam(Example_resource["example_resource_instance"], "param"))
2271 # Declare an instance of the second resource type - this will call notice
2272 example_get_param { 'show_notify': }
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.
2281 Would notice: 'the value we are getting in this example'
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']``
2287 Returns: `Any` value of a resource's parameter.
2291 ###### Example Usage:
2295 # define a resource type with a parameter
2296 define example_resource($param) {
2299 # declare an instance of that type
2300 example_resource { "example_resource_instance":
2301 param => "'the value we are getting in this example''"
2304 # Because of order of evaluation, a second definition is needed
2305 # that will be evaluated after the first resource has been declared
2307 define example_get_param {
2308 # This will notice the value of the parameter
2309 notice(getparam(Example_resource["example_resource_instance"], "param"))
2312 # Declare an instance of the second resource type - this will call notice
2313 example_get_param { 'show_notify': }
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
2330 $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo
2333 ##### Where namespace is stored in a string
2336 $datalocation = 'site::data'
2337 $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar
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
2347 Returns: `Any` undef - if variable does not exist
2351 ###### Example usage
2354 $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo
2357 ###### Where namespace is stored in a string
2360 $datalocation = 'site::data'
2361 $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar
2368 Uses same patterns as Dir#glob.
2372 ##### Example Usage:
2375 $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
2382 Returns: `Any` Returns an Array of file entries of a directory or an Array of directories.
2386 ###### Example Usage:
2389 $confs = glob(['/etc/**/*.conf', '/opt/**/*.conf'])
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' }```
2403 ##### Example Usage:
2406 grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd']
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' }```
2416 Returns: `Any` array of elements that match the provided regular expression.
2420 ###### Example Usage:
2423 grep(['aaa','bbb','ccc','aaaddd'], 'aaa') # Returns ['aaa','aaaddd']
2426 ### has_interface_with
2430 Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`.
2437 has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false`
2438 has_interface_with("ipaddress", "127.0.0.1") # Returns `true`
2441 ##### If no "kind" is given, then the presence of the interface is checked:
2444 has_interface_with("lo") # Returns `true`
2447 #### `has_interface_with()`
2449 Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`.
2451 Returns: `Any` boolean values `true` or `false`
2458 has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false`
2459 has_interface_with("ipaddress", "127.0.0.1") # Returns `true`
2462 ###### If no "kind" is given, then the presence of the interface is checked:
2465 has_interface_with("lo") # Returns `true`
2472 This function iterates through the 'interfaces' fact and checks the
2473 'ipaddress_IFACE' facts, performing a simple string comparison.
2475 #### `has_ip_address()`
2477 This function iterates through the 'interfaces' fact and checks the
2478 'ipaddress_IFACE' facts, performing a simple string comparison.
2480 Returns: `Boolean` `true` or `false`
2486 This function iterates through the 'interfaces' fact and checks the
2487 'network_IFACE' facts, performing a simple string comparision.
2489 #### `has_ip_network()`
2491 This function iterates through the 'interfaces' fact and checks the
2492 'network_IFACE' facts, performing a simple string comparision.
2494 Returns: `Any` Boolean value, `true` if the client has an IP address within the requested network.
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')
2508 ##### Example Usage:
2512 $my_hash = {'key_one' => 'value_one'}
2513 if has_key($my_hash, 'key_two') {
2514 notice('we will not reach here')
2516 if has_key($my_hash, 'key_one') {
2517 notice('this will be printed')
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')
2529 Returns: `Any` Boolean value
2533 ###### Example Usage:
2537 $my_hash = {'key_one' => 'value_one'}
2538 if has_key($my_hash, 'key_two') {
2539 notice('we will not reach here')
2541 if has_key($my_hash, 'key_one') {
2542 notice('this will be printed')
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
2553 This example shows the equivalent expression in the Puppet language:
2555 Hash(['a',1,'b',2,'c',3])
2556 Hash([['a',1],['b',2],['c',3]])
2561 ##### Example Usage:
2564 hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3}
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
2572 This example shows the equivalent expression in the Puppet language:
2574 Hash(['a',1,'b',2,'c',3])
2575 Hash([['a',1],['b',2],['c',3]])
2578 Returns: `Any` the converted array as a hash
2582 ###### Example Usage:
2585 hash(['a',1,'b',2,'c',3]) # Returns: {'a'=>1,'b'=>2,'c'=>3}
2592 This function returns an array of the intersection of two.
2596 ##### Example Usage:
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)
2603 #### `intersection()`
2605 The intersection function.
2607 Returns: `Any` an array of the intersection of two.
2611 ###### Example Usage:
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)
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.
2627 ##### Example Usage:
2635 if $foo.is_a(Integer) {
2638 if $bar.is_a(Array) {
2641 if $baz.is_a(String) {
2646 #### `is_a(Any $value, Type $type)`
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.
2651 Returns: `Boolean` Return's `true` or `false`.
2655 ###### Example Usage:
2663 if $foo.is_a(Integer) {
2666 if $bar.is_a(Array) {
2669 if $baz.is_a(String) {
2678 The value to be checked
2686 ### is_absolute_path
2690 This function works for windows and unix style paths.
2692 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2693 [`validate_legacy`](#validate_leg
2697 ##### The following values will return true:
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)
2710 ##### The following values will return false:
2713 is_absolute_path(true)
2714 is_absolute_path('../var/lib/puppet')
2715 is_absolute_path('var/lib/puppet')
2717 is_absolute_path($undefined)
2720 #### `is_absolute_path()`
2722 This function works for windows and unix style paths.
2724 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2725 [`validate_legacy`](#validate_leg
2727 Returns: `Boolean` Returns `true` or `false`
2731 ###### The following values will return true:
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)
2744 ###### The following values will return false:
2747 is_absolute_path(true)
2748 is_absolute_path('../var/lib/puppet')
2749 is_absolute_path('var/lib/puppet')
2751 is_absolute_path($undefined)
2754 ### is_absolute_path
2758 Wrapper that calls the Puppet 3.x funtion of the same name.
2760 #### `is_absolute_path(Any $scope, Any *$args)`
2762 The is_absolute_path function.
2764 Returns: `Boolea` A boolean value returned from the called 3.x function.
2770 The main value that will be passed to the wrapped method
2776 Any additional values that are to be passed to the wrapped method
2782 Wrapper that calls the Puppet 3.x funtion of the same name.
2784 #### `is_array(Any $scope, Any *$args)`
2786 The is_array function.
2788 Returns: `Boolea` A boolean value returned from the called 3.x function.
2794 The main value that will be passed to the wrapped method
2800 Any additional values that are to be passed to the wrapped method
2806 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2807 [`validate_legacy`](#validate_legacy).
2811 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2812 [`validate_legacy`](#validate_legacy).
2814 Returns: `Boolean` Returns `true` or `false`
2820 Wrapper that calls the Puppet 3.x funtion of the same name.
2822 #### `is_bool(Any $scope, Any *$args)`
2824 The is_bool function.
2826 Returns: `Boolea` A boolean value returned from the called 3.x function.
2832 The main value that will be passed to the wrapped method
2838 Any additional values that are to be passed to the wrapped method
2844 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2845 [`validate_legacy`](#validate_legacy).
2849 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2850 [`validate_legacy`](#validate_legacy).
2852 Returns: `Boolean` Returns `true` or `false`
2858 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2859 [`validate_legacy`](#validate_legacy).
2861 #### `is_domain_name()`
2863 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2864 [`validate_legacy`](#validate_legacy).
2866 Returns: `Boolean` Returns `true` or `false`
2868 ### is_email_address
2872 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2873 [`validate_legacy`](#validate_legacy).
2875 #### `is_email_address()`
2877 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2878 [`validate_legacy`](#validate_legacy).
2880 Returns: `Boolean` Returns `true` or `false`
2886 Wrapper that calls the Puppet 3.x funtion of the same name.
2888 #### `is_float(Any $scope, Any *$args)`
2890 The is_float function.
2892 Returns: `Boolea` A boolean value returned from the called 3.x function.
2898 The main value that will be passed to the wrapped method
2904 Any additional values that are to be passed to the wrapped method
2910 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2911 [`validate_legacy`](#validate_legacy).
2915 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2916 [`validate_legacy`](#validate_legacy).
2918 Returns: `Boolean` Returns `true` or `false`
2920 ### is_function_available
2924 This function accepts a string as an argument.
2926 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2927 [`validate_legacy`](#validate_legacy).
2929 #### `is_function_available()`
2931 This function accepts a string as an argument.
2933 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2934 [`validate_legacy`](#validate_legacy).
2936 Returns: `Boolean` Returns `true` or `false`
2942 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2943 [`validate_legacy`](#validate_legacy).
2947 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2948 [`validate_legacy`](#validate_legacy).
2950 Returns: `Boolean` Returns `true` or `false`
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).
2959 If given any other argument `false` is returned.
2961 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2962 [`validate_legacy`](#validate_legacy).
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).
2969 If given any other argument `false` is returned.
2971 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2972 [`validate_legacy`](#validate_legacy).
2974 Returns: `Boolean` Returns `true` or `false`
2980 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2981 [`validate_legacy`](#validate_legacy).
2983 #### `is_ip_address()`
2985 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
2986 [`validate_legacy`](#validate_legacy).
2988 Returns: `Boolean` Returns `true` or `false`
2994 Wrapper that calls the Puppet 3.x funtion of the same name.
2996 #### `is_ip_address(Any $scope, Any *$args)`
2998 The is_ip_address function.
3000 Returns: `Boolea` A boolean value returned from the called 3.x function.
3006 The main value that will be passed to the wrapped method
3012 Any additional values that are to be passed to the wrapped method
3018 Wrapper that calls the Puppet 3.x funtion of the same name.
3020 #### `is_ipv4_address(Any $scope, Any *$args)`
3022 The is_ipv4_address function.
3024 Returns: `Boolea` A boolean value returned from the called 3.x function.
3030 The main value that will be passed to the wrapped method
3036 Any additional values that are to be passed to the wrapped method
3042 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3043 [`validate_legacy`](#validate_legacy).
3045 #### `is_ipv4_address()`
3047 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3048 [`validate_legacy`](#validate_legacy).
3050 Returns: `Boolean` Returns `true` or `false`
3056 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3057 [`validate_legacy`](#validate_legacy).
3059 #### `is_ipv6_address()`
3061 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3062 [`validate_legacy`](#validate_legacy).
3064 Returns: `Boolean` Returns `true` or `false`
3070 Wrapper that calls the Puppet 3.x funtion of the same name.
3072 #### `is_ipv6_address(Any $scope, Any *$args)`
3074 The is_ipv6_address function.
3076 Returns: `Boolea` A boolean value returned from the called 3.x function.
3082 The main value that will be passed to the wrapped method
3088 Any additional values that are to be passed to the wrapped method
3094 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3095 [`validate_legacy`](#validate_legacy).
3097 #### `is_mac_address()`
3099 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3100 [`validate_legacy`](#validate_legacy).
3102 Returns: `Boolean` Returns `true` or `false`
3108 Wrapper that calls the Puppet 3.x funtion of the same name.
3110 #### `is_numeric(Any $scope, Any *$args)`
3112 The is_numeric function.
3114 Returns: `Boolea` A boolean value returned from the called 3.x function.
3120 The main value that will be passed to the wrapped method
3126 Any additional values that are to be passed to the wrapped method
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.
3136 The function recognizes only decimal (base 10) integers and float but not
3137 integers in hex (base 16) or octal (base 8) form.
3139 The string representation may start with a '-' (minus). If a decimal '.' is used,
3140 it must be followed by at least one digit.
3142 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3143 [`validate_legacy`](#validate_legacy).
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.
3151 The function recognizes only decimal (base 10) integers and float but not
3152 integers in hex (base 16) or octal (base 8) form.
3154 The string representation may start with a '-' (minus). If a decimal '.' is used,
3155 it must be followed by at least one digit.
3157 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3158 [`validate_legacy`](#validate_legacy).
3160 Returns: `Boolean` Returns `true` or `false`
3166 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3167 [`validate_legacy`](#validate_legacy).
3171 > **Note:* **Deprecated** Will be removed in a future version of stdlib. See
3172 [`validate_legacy`](#validate_legacy).
3174 Returns: `Boolean` Returns `true` or `false`
3180 Wrapper that calls the Puppet 3.x funtion of the same name.
3182 #### `is_string(Any $scope, Any *$args)`
3184 The is_string function.
3186 Returns: `Boolean` A boolean value returned from the called 3.x function.
3192 The main value that will be passed to the wrapped method
3198 Any additional values that are to be passed to the wrapped method
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.
3209 ##### Example Usage:
3212 join(['a','b','c'], ",") # Results in: "a,b,c"
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.
3220 Returns: `String` The String containing each of the array values
3224 ###### Example Usage:
3227 join(['a','b','c'], ",") # Results in: "a,b,c"
3230 ### join_keys_to_values
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.
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`.
3245 ##### Example Usage:
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"]
3252 #### `join_keys_to_values()`
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.
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`.
3263 Returns: `Hash` The joined hash
3267 ###### Example Usage:
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"]
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.
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.
3286 Returns: `Array` An array containing each of the hashes key values.
3292 The original size() function did not handle Puppets new type capabilities, so this function
3293 is a Puppet 4 compatible solution.
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.
3298 #### `length(Variant[String,Array,Hash] $value)`
3300 The original size() function did not handle Puppets new type capabilities, so this function
3301 is a Puppet 4 compatible solution.
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.
3306 Returns: `Integer` The length of the given object
3310 Data type: `Variant[String,Array,Hash]`
3312 The value whose length is to be found
3314 ### load_module_metadata
3318 This function loads the metadata of a given module.
3322 ##### Example USage:
3325 $metadata = load_module_metadata('archive')
3326 notify { $metadata['author']: }
3329 #### `load_module_metadata()`
3331 The load_module_metadata function.
3333 Returns: `Any` The modules metadata
3337 ###### Example USage:
3340 $metadata = load_module_metadata('archive')
3341 notify { $metadata['author']: }
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.
3354 ##### Example Usage:
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
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.
3369 Returns: `Array|String|Hash` The data stored in the JSON file, the type depending on the type of data that was stored.
3373 ###### Example Usage:
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
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.
3392 ##### Example Usage:
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
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.
3407 Returns: `Array|String|Hash` The data stored in the YAML file, the type depending on the type of data that was stored.
3411 ###### Example Usage:
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
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.
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.
3432 Returns: `String` The stripped string
3438 Requires at least one argument.
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.
3445 Requires at least one argument.
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.
3450 Returns: `Any` The highest value among those passed in
3456 The variable can be a string, fixnum, or array.
3458 > **Note**: This function does not support nested arrays. If the first argument contains
3459 nested arrays, it will not recurse through them.
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`
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.
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
3486 The variable can be a string, fixnum, or array.
3488 > **Note**: This function does not support nested arrays. If the first argument contains
3489 nested arrays, it will not recurse through them.
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`
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.
3503 Returns: `Any` Returns whether the given value was a member of the array
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
3520 When there is a duplicate key, the key in the rightmost hash will "win."
3522 Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
3523 `$merged_hash = $hash1 + $has
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'}
3537 When there is a duplicate key, the key in the rightmost hash will "win."
3539 Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
3540 `$merged_hash = $hash1 + $has
3542 Returns: `Hash` The merged hash
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'}
3558 When there is a duplicate key, the key in the rightmost hash will "win."
3560 Note that since Puppet 4.0.0 the same merge can be achieved with the + operator.
3561 `$merged_hash = $hash1 + $hash2`
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).
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
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.
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.
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'}
3587 ##### counting occurrences of strings in an array
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 }
3593 ##### skipping values for entries that are longer than 1 char
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 }
3599 #### `merge(Variant[Hash, Undef, String[0,0]] *$args)`
3603 Returns: `Hash` The merged hash
3607 Data type: `Variant[Hash, Undef, String[0,0]]`
3609 Repeated Param - The hashes that are to be merged
3611 #### `merge(Iterable *$args, Callable[3,3] &$block)`
3615 Returns: `Hash` The merged hash
3619 Data type: `Iterable`
3621 Repeated Param - The hashes that are to be merged
3625 Data type: `Callable[3,3]`
3627 A block placed on the repeatable param `args`
3629 #### `merge(Iterable *$args, Callable[2,2] &$block)`
3633 Returns: `Hash` The merged hash
3637 Data type: `Iterable`
3639 Repeated Param - The hashes that are to be merged
3643 Data type: `Callable[2,2]`
3645 A block placed on the repeatable param `args`
3651 Requires at least one argument.
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.
3658 Requires at least one argument.
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.
3663 Returns: `Any` The lowest value among the given arguments
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.
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.
3677 Returns: `Boolean` Boolean(0) # false for any zero or negative number
3678 Boolean(1) # true for any positive number
3685 Only the major version is taken into account.
3689 ##### Example usage:#
3692 if os_version_gte('Debian', '9') { }
3693 if os_version_gte('Ubuntu', '18.04') { }
3696 #### `os_version_gte(String[1] $os, String[1] $version)`
3699 Only the major version is taken into account.
3701 Returns: `Boolean` `true` or `false
3705 ###### Example usage:#
3708 if os_version_gte('Debian', '9') { }
3709 if os_version_gte('Ubuntu', '18.04') { }
3714 Data type: `String[1]`
3720 Data type: `String[1]`
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.
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.
3738 Returns: `Any` convert JSON into Puppet structure
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.
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.
3754 Returns: `Any` converted YAML into Puppet structure
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:
3763 ```$real_jenkins_version = pick($::jenkins_version, '1.449')```
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.
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:
3776 ```$real_jenkins_version = pick($::jenkins_version, '1.449')```
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.
3784 Returns: `Any` the first value in a list of values that is not undefined or an empty string.
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
3794 $real_jenkins_version = pick_default($::jenkins_version, '1.449')
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.
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
3806 #### `pick_default()`
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
3812 $real_jenkins_version = pick_default($::jenkins_version, '1.449')
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.
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
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.
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}" }
3842 prefix(['a','b','c'], 'p')
3843 Will return: ['pa','pb','pc']
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}" }
3852 Returns: `Hash` or [Array] The passed values now contains the passed prefix
3860 prefix(['a','b','c'], 'p')
3861 Will return: ['pa','pb','pc']
3868 **Deprecated:** Sets the current class or definition as private.
3869 Calling the class or definition from outside the current module will fail.
3873 The private function.
3875 Returns: `Any` Sets the current class or definition as private
3881 This is useful for debugging manifest code at specific points during a compilation.
3894 This is useful for debugging manifest code at specific points during a compilation.
3896 Returns: `Any` debugging information
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.
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
3918 |Hash type |Specifier|
3919 |---------------------|---------|
3922 |SHA-512 (recommended)|6 |
3924 The third argument to this function is the salt to use.
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.
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.
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
3939 |Hash type |Specifier|
3940 |---------------------|---------|
3943 |SHA-512 (recommended)|6 |
3945 The third argument to this function is the salt to use.
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.
3951 Returns: `Hash` Provides a hash usable on most POSIX systems.
3957 NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail.
3960 Passing a third argument will cause the generated range to step by that
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.
3966 Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9
3974 Will return: [0,1,2,3,4,5,6,7,8,9]
3977 Will return: [0,1,2,3,4,5,6,7,8,9]
3978 (Zero padded strings are converted to integers automatically)
3981 Will return: ["a","b","c"]
3983 range("host01", "host10")
3984 Will return: ["host01", "host02", ..., "host09", "host10"]
3986 range("0", "9", "2")
3987 Will return: [0,2,4,6,8]
3992 NB Be explicit in including trailing zeros. Otherwise the underlying ruby function will fail.
3995 Passing a third argument will cause the generated range to step by that
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.
4001 Integer[0, 9].each |$x| { notice($x) } # notices 0, 1, 2, ... 9
4003 Returns: `Any` the range is extrapolated as an array
4011 Will return: [0,1,2,3,4,5,6,7,8,9]
4014 Will return: [0,1,2,3,4,5,6,7,8,9]
4015 (Zero padded strings are converted to integers automatically)
4018 Will return: ["a","b","c"]
4020 range("host01", "host10")
4021 Will return: ["host01", "host02", ..., "host09", "host10"]
4023 range("0", "9", "2")
4024 Will return: [0,2,4,6,8]
4031 Regexp escape a string or array of strings.
4032 Requires either a single string or an array as an input.
4034 #### `regexpescape()`
4036 The regexpescape function.
4038 Returns: `String` A string of characters with metacharacters converted to their escaped form.
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 !~
4054 reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
4056 Would return: ['bbb','ccc']
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 !~
4065 Returns: `Any` an array containing all the elements which doesn'' match the provided regular expression
4073 reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
4075 Would return: ['bbb','ccc']
4082 > *Note:* that the same can be done with the reverse_each() function in Puppet.
4086 > *Note:* that the same can be done with the reverse_each() function in Puppet.
4088 Returns: `Any` reversed string or array
4094 ```round(2.9)``` returns ```3```
4096 ```round(2.4)``` returns ```2```
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.
4103 ```round(2.9)``` returns ```3```
4105 ```round(2.4)``` returns ```2```
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.
4110 Returns: `Any` the rounded value as integer
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.
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.
4124 Returns: `Any` the string with leading spaces removed
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`.
4139 seeded_rand(MAX, SEED).
4140 MAX must be a positive integer; SEED is any string.
4143 #### `seeded_rand()`
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`.
4149 Returns: `Any` random number greater than or equal to 0 and less than MAX
4156 seeded_rand(MAX, SEED).
4157 MAX must be a positive integer; SEED is any string.
4160 ### seeded_rand_string
4164 Generates a consistent random string of specific length based on provided seed.
4168 ##### Generate a consistently random string of length 8 with a seed:
4171 seeded_rand_string(8, "${module_name}::redis_password")
4174 ##### Generate a random string from a specific set of characters:
4177 seeded_rand_string(5, '', 'abcdef')
4180 #### `seeded_rand_string(Integer[1] $length, String $seed, Optional[String[2]] $charset)`
4182 The seeded_rand_string function.
4184 Returns: `String` Random string.
4188 ###### Generate a consistently random string of length 8 with a seed:
4191 seeded_rand_string(8, "${module_name}::redis_password")
4194 ###### Generate a random string from a specific set of characters:
4197 seeded_rand_string(5, '', 'abcdef')
4202 Data type: `Integer[1]`
4204 Length of string to be generated.
4214 Data type: `Optional[String[2]]`
4216 String that contains characters to use for the random string.
4222 >* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single
4225 This function behaves the same as ruby's Shellwords.shellescape() function.
4227 #### `shell_escape()`
4229 >* Note:* that the resulting string should be used unquoted and is not intended for use in double quotes nor in single
4232 This function behaves the same as ruby's Shellwords.shellescape() function.
4234 Returns: `Any` A string of characters with metacharacters converted to their escaped form.
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
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
4250 Returns: `Any` a command line string
4256 This function behaves the same as ruby's Shellwords.shellsplit() function
4258 #### `shell_split()`
4260 This function behaves the same as ruby's Shellwords.shellsplit() function
4262 Returns: `Any` array of tokens
4269 Randomizes the order of a string or array elements.
4274 Randomizes the order of a string or array elements.
4276 Returns: `Any` randomized string or array
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.
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.
4290 Returns: `Any` the number of elements in a string, an array or a hash
4296 Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this.
4300 Note that from Puppet 6.0.0 the same function in Puppet will be used instead of this.
4302 Returns: `Any` sorted string or array
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
4312 In the given argument hash with parameters, all keys are converted to symbols so they work
4313 with the `sprintf` function.
4315 Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the
4316 `sprintf` function in puppet core.
4320 ##### Format a string and number
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'
4328 #### `sprintf_hash(String $format, Hash $arguments)`
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
4334 In the given argument hash with parameters, all keys are converted to symbols so they work
4335 with the `sprintf` function.
4337 Note that since Puppet 4.10.10, and 5.3.4 this functionality is supported by the
4338 `sprintf` function in puppet core.
4340 Returns: `Any` The formatted string.
4344 ###### Format a string and number
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'
4362 Hash with parameters.
4368 Returns a new string where runs of the same character that occur in this set are replaced by a single character.
4372 The squeeze function.
4374 Returns: `Any` a new string where runs of the same character that occur in this set are replaced by a single character.
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.
4383 An empty String will also be returned, when the Period is the last Character
4388 ##### Determining the Extension of a Filename
4391 stdlib::extname('test.rb') => '.rb'
4392 stdlib::extname('a/b/d/test.rb') => '.rb'
4393 stdlib::extname('test') => ''
4394 stdlib::extname('.profile') => ''
4397 #### `stdlib::extname(String $filename)`
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.
4402 An empty String will also be returned, when the Period is the last Character
4405 Returns: `String` The Extension starting from the last Period
4409 ###### Determining the Extension of a Filename
4412 stdlib::extname('test.rb') => '.rb'
4413 stdlib::extname('a/b/d/test.rb') => '.rb'
4414 stdlib::extname('test') => ''
4415 stdlib::extname('.profile') => ''
4424 ### stdlib::ip_in_range
4428 Returns true if the ipaddress is within the given CIDRs
4432 ##### ip_in_range(<IPv4 Address>, <IPv4 CIDR>)
4435 stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true
4438 #### `stdlib::ip_in_range(String $ipaddress, Variant[String, Array] $range)`
4440 The stdlib::ip_in_range function.
4442 Returns: `Boolean` True or False
4446 ###### ip_in_range(<IPv4 Address>, <IPv4 CIDR>)
4449 stdlib::ip_in_range('10.10.10.53', '10.10.10.0/24') => true
4456 The IP address to check
4460 Data type: `Variant[String, Array]`
4462 One CIDR or an array of CIDRs
4463 defining the range(s) to check against
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.
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.
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'.
4480 ### str2saltedsha512
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.
4488 #### `str2saltedsha512()`
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.
4494 Returns: `Any` converted string as a hex version of a salted-SHA512 password hash
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.
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)
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)
4553 %% - Literal ``%'' character
4561 To return the time since epoch: strftime("%s")
4562 To return the date: strftime("%Y-%m-%d")
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.
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)
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)
4620 %% - Literal ``%'' character
4622 Returns: `Any` converted time according to the directives in the given format string
4630 To return the time since epoch: strftime("%s")
4631 To return the date: strftime("%Y-%m-%d")
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.
4648 Would result in: "aaa"
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.
4656 Returns: `Any` String or Array converted
4665 Would result in: "aaa"
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:
4675 ```['a', 'b', 'c'].map |$x| { "${x}p" }```
4683 suffix(['a','b','c'], 'p')
4684 Will return: ['ap','bp','cp']
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:
4692 ```['a', 'b', 'c'].map |$x| { "${x}p" }```
4694 Returns: `Any` Array or Hash with updated elements containing the passed suffix
4702 suffix(['a','b','c'], 'p')
4703 Will return: ['ap','bp','cp']
4710 This function will swap the existing case of a string.
4719 Would result in: "AbCd"
4724 The swapcase function.
4726 Returns: `Any` string with uppercase alphabetic characters converted to lowercase and lowercase characters converted to uppercase
4735 Would result in: "AbCd"
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
4755 Will return something like: 1311972653
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
4766 Returns: `Any` the current time since epoch as an integer.
4775 Will return something like: 1311972653
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.
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.
4792 Returns: `Any` converted value into bytes
4798 Convert a data structure and output to JSON
4802 ##### how to output JSON
4805 # output json to a file
4806 file { '/tmp/my.json':
4808 content => to_json($myhash),
4812 #### `to_json(Any $data)`
4814 The to_json function.
4816 Returns: `Any` converted data to json
4820 ###### how to output JSON
4823 # output json to a file
4824 file { '/tmp/my.json':
4826 content => to_json($myhash),
4834 data structure which needs to be converted into JSON
4840 Convert data structure and output to pretty JSON
4847 * how to output pretty JSON to file
4848 file { '/tmp/my.json':
4850 content => to_json_pretty($myhash),
4853 * how to output pretty JSON skipping over keys with undef values
4854 file { '/tmp/my.json':
4856 content => to_json_pretty({
4857 param_one => 'value',
4863 #### `to_json_pretty(Variant[Hash, Array] $data, Optional[Boolean] $skip_undef)`
4865 The to_json_pretty function.
4867 Returns: `Any` converted data to pretty json
4874 * how to output pretty JSON to file
4875 file { '/tmp/my.json':
4877 content => to_json_pretty($myhash),
4880 * how to output pretty JSON skipping over keys with undef values
4881 file { '/tmp/my.json':
4883 content => to_json_pretty({
4884 param_one => 'value',
4892 Data type: `Variant[Hash, Array]`
4894 data structure which needs to be converted to pretty json
4898 Data type: `Optional[Boolean]`
4900 value `true` or `false`
4906 Convert a data structure and output it as YAML
4910 ##### how to output YAML
4913 # output yaml to a file
4914 file { '/tmp/my.yaml':
4916 content => to_yaml($myhash),
4920 #### `to_yaml(Any $data)`
4922 The to_yaml function.
4928 ###### how to output YAML
4931 # output yaml to a file
4932 file { '/tmp/my.yaml':
4934 content => to_yaml($myhash),
4948 Key can contain slashes to describe path components. The function will go down
4949 the structure and try to extract the required value.
4961 $value = try_get_value($data, 'a/b/2', 'not_found', '/')
4966 b -> second hash key
4967 2 -> array index starting with 0
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 '/'.
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.
4977 #### `try_get_value()`
4979 Key can contain slashes to describe path components. The function will go down
4980 the structure and try to extract the required value.
4992 $value = try_get_value($data, 'a/b/2', 'not_found', '/')
4997 b -> second hash key
4998 2 -> array index starting with 0
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 '/'.
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.
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.
5015 please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.
5026 please use type3x() before upgrading to Puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.
5035 Returns: `Any` the type when passed a value. Type can be one of:
5057 Returns: `Any` the type when passed a value. Type can be one of:
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.
5066 The built-in type() function in puppet is generally preferred over this function
5067 this function is provided for backwards compatibility.
5071 ##### how to compare values' types
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") }
5078 ##### how to compare against an abstract type
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") }
5085 #### `type_of(Any $value)`
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.
5090 The built-in type() function in puppet is generally preferred over this function
5091 this function is provided for backwards compatibility.
5093 Returns: `String` the type of the passed value
5097 ###### how to compare values' types
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") }
5104 ###### how to compare against an abstract type
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") }
5121 This function returns a union of two or more arrays.
5129 union(["a","b","c"],["b","c","d"])
5130 Would return: ["a","b","c","d"]
5137 Returns: `Any` a unionized array of two or more arrays
5145 union(["a","b","c"],["b","c","d"])
5146 Would return: ["a","b","c","d"]
5153 This function will remove duplicates from strings and arrays.
5164 You can also use this with arrays:
5166 unique(["a","a","b","b","c","c"])
5167 This returns: ["a","b","c"]
5172 The unique function.
5174 Returns: `Any` String or array with duplicates removed
5185 You can also use this with arrays:
5187 unique(["a","a","b","b","c","c"])
5188 This returns: ["a","b","c"]
5195 Takes a single string argument.
5199 Takes a single string argument.
5201 Returns: `Any` the DOS version of the given string.
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.
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.
5225 Returns: `Any` converted string ot array of strings to uppercase
5241 Urlencodes a string or array of strings.
5242 Requires either a single string or an array as an input.
5246 The uriescape function.
5248 Returns: `String` a string that contains the converted value
5250 ### validate_absolute_path
5254 Validate the string represents an absolute path in the filesystem. This function works
5255 for windows and unix style paths.
5263 The following values will pass:
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)
5274 The following values will fail, causing compilation to abort:
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' ])
5282 validate_absolute_path($undefin
5285 #### `validate_absolute_path()`
5287 The validate_absolute_path function.
5289 Returns: `Any` passes when the string is an absolute path or raise an error when it is not and fails compilation
5297 The following values will pass:
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)
5308 The following values will fail, causing compilation to abort:
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' ])
5316 validate_absolute_path($undefin
5319 ### validate_absolute_path
5323 Validate the string represents an absolute path in the filesystem.
5325 #### `validate_absolute_path(Any $scope, Any *$args)`
5327 The validate_absolute_path function.
5329 Returns: `Boolean` A boolean value returned from the called function.
5335 The main value that will be passed to the method
5341 Any additional values that are to be passed to the method
5347 Validate the passed value represents an array.
5349 #### `validate_array(Any $scope, Any *$args)`
5351 The validate_array function.
5353 Returns: `Any` A boolean value (`true` or `false`) returned from the called function.
5359 The main value that will be passed to the method
5365 Any additional values that are to be passed to the method
5371 Validate that all passed values are array data structures. Abort catalog
5372 compilation if any value fails this check.
5379 The following values will pass:
5381 $my_array = [ 'one', 'two' ]
5382 validate_array($my_array)
5384 The following values will fail, causing compilation to abort:
5386 validate_array(true)
5387 validate_array('some_string')
5389 validate_array($undefined
5392 #### `validate_array()`
5394 The validate_array function.
5396 Returns: `Any` validate array
5403 The following values will pass:
5405 $my_array = [ 'one', 'two' ]
5406 validate_array($my_array)
5408 The following values will fail, causing compilation to abort:
5410 validate_array(true)
5411 validate_array('some_string')
5413 validate_array($undefined
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.
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.
5435 If you want to make sure your passwd content never contains
5436 a user `foo`, you could write:
5438 validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
5440 If you wanted to ensure that no users used the '/bin/barsh' shell,
5443 validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
5445 If a fourth argument is specified, this will be the error message raised and
5448 A helpful error message can be returned like this:
5450 validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
5453 #### `validate_augeas()`
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.
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.
5464 Returns: `Any` validate string using an Augeas lens
5472 If you want to make sure your passwd content never contains
5473 a user `foo`, you could write:
5475 validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
5477 If you wanted to ensure that no users used the '/bin/barsh' shell,
5480 validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
5482 If a fourth argument is specified, this will be the error message raised and
5485 A helpful error message can be returned like this:
5487 validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
5494 Validate that all passed values are either true or false. Abort catalog
5495 compilation if any value fails this check.
5503 The following values will pass:
5507 validate_bool(true, true, false, $iamtrue)
5509 The following values will fail, causing compilation to abort:
5511 $some_array = [ true ]
5512 validate_bool("false")
5513 validate_bool("true")
5514 validate_bool($some_array)
5517 #### `validate_bool()`
5519 The validate_bool function.
5521 Returns: `Any` validate boolean
5529 The following values will pass:
5533 validate_bool(true, true, false, $iamtrue)
5535 The following values will fail, causing compilation to abort:
5537 $some_array = [ true ]
5538 validate_bool("false")
5539 validate_bool("true")
5540 validate_bool($some_array)
5547 Validate the passed value represents a boolean.
5549 #### `validate_bool(Any $scope, Any *$args)`
5551 The validate_bool function.
5553 Returns: `Boolean` `true` or `false`
5554 A boolean value returned from the called function.
5560 The main value that will be passed to the method
5566 Any additional values that are to be passed to the method
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
5580 A helpful error message can be returned like this:
5588 Defaults to end of path
5589 validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
5592 validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
5595 #### `validate_cmd()`
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
5605 A helpful error message can be returned like this:
5607 Returns: `Any` validate of a string with an external command
5615 Defaults to end of path
5616 validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
5619 validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content')
5622 ### validate_domain_name
5626 Validate that all values passed are syntactically correct domain names.
5627 Fail compilation if any value fails this check.
5635 The following values will pass:
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)
5641 The following values will fail, causing compilation to abort:
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')
5650 #### `validate_domain_name()`
5652 The validate_domain_name function.
5654 Returns: `Any` passes when the given values are syntactically correct domain names or raise an error when they are not and fails compilation
5662 The following values will pass:
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)
5668 The following values will fail, causing compilation to abort:
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')
5677 ### validate_email_address
5681 Validate that all values passed are valid email addresses.
5682 Fail compilation if any value fails this check.
5690 The following values will pass:
5692 $my_email = "waldo@gmail.com"
5693 validate_email_address($my_email)
5694 validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
5696 The following values will fail, causing compilation to abort:
5698 $some_array = [ 'bad_email@/d/efdf.com' ]
5699 validate_email_address($some_array)
5702 #### `validate_email_address()`
5704 The validate_email_address function.
5706 Returns: `Any` Fail compilation if any value fails this check.
5714 The following values will pass:
5716 $my_email = "waldo@gmail.com"
5717 validate_email_address($my_email)
5718 validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email)
5720 The following values will fail, causing compilation to abort:
5722 $some_array = [ 'bad_email@/d/efdf.com' ]
5723 validate_email_address($some_array)
5730 Validate the passed value represents a hash.
5732 #### `validate_hash(Any $scope, Any *$args)`
5734 The validate_hash function.
5736 Returns: `Any` A boolean value (`true` or `false`) returned from the called function.
5742 The main value that will be passed to the method
5748 Any additional values that are to be passed to the method
5754 Validate that all passed values are hash data structures. Abort catalog
5755 compilation if any value fails this check.
5763 The following values will pass:
5765 $my_hash = { 'one' => 'two' }
5766 validate_hash($my_hash)
5768 The following values will fail, causing compilation to abort:
5771 validate_hash('some_string')
5773 validate_hash($undefined)
5776 #### `validate_hash()`
5778 The validate_hash function.
5780 Returns: `Any` validate hash
5788 The following values will pass:
5790 $my_hash = { 'one' => 'two' }
5791 validate_hash($my_hash)
5793 The following values will fail, causing compilation to abort:
5796 validate_hash('some_string')
5798 validate_hash($undefined)
5801 ### validate_integer
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.
5817 The following values will pass:
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)
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)
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.
5834 The following values will not:
5836 validate_integer(true)
5837 validate_integer(false)
5838 validate_integer(7.0)
5839 validate_integer({ 1 => 2 })
5841 validate_integer($foo)
5842 validate_integer($foobaridontexist)
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)
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.
5858 #### `validate_integer()`
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.
5866 Returns: `Any` Validate that the first argument is an integer (or an array of integers). Fail compilation if any of the checks fail.
5874 The following values will pass:
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)
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)
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.
5891 The following values will not:
5893 validate_integer(true)
5894 validate_integer(false)
5895 validate_integer(7.0)
5896 validate_integer({ 1 => 2 })
5898 validate_integer($foo)
5899 validate_integer($foobaridontexist)
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)
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.
5915 ### validate_integer
5919 Validate the passed value represents an integer.
5921 #### `validate_integer(Any $scope, Any *$args)`
5923 The validate_integer function.
5925 Returns: `Boolean` `true` or `false`
5926 A boolean value returned from the called function.
5932 The main value that will be passed to the method
5938 Any additional values that are to be passed to the method
5940 ### validate_ip_address
5944 Validate the passed value represents an ip_address.
5946 #### `validate_ip_address(Any $scope, Any *$args)`
5948 The validate_ip_address function.
5950 Returns: `Boolean` `true` or `false`
5951 A boolean value returned from the called function.
5957 The main value that will be passed to the method
5963 Any additional values that are to be passed to the method
5965 ### validate_ip_address
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.
5978 The following values will pass:
5981 validate_ip_address($my_ip)
5982 validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip)
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)
5989 The following values will fail, causing compilation to abort:
5991 $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
5992 validate_ip_address($some_array)
5995 #### `validate_ip_address()`
5997 The validate_ip_address function.
5999 Returns: `Any` passes when the given values are valid IP addresses or raise an error when they are not and fails compilation
6006 The following values will pass:
6009 validate_ip_address($my_ip)
6010 validate_ip_address("8.8.8.8", "172.16.0.1", $my_ip)
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)
6017 The following values will fail, causing compilation to abort:
6019 $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
6020 validate_ip_address($some_array)
6023 ### validate_ipv4_address
6027 Validate the passed value represents an ipv4_address.
6029 #### `validate_ipv4_address(Any $scope, Any *$args)`
6031 The validate_ipv4_address function.
6033 Returns: `Boolean` `true` or `false`
6034 A boolean value returned from the called function.
6040 The main value that will be passed to the method
6046 Any additional values that are to be passed to the method
6048 ### validate_ipv4_address
6052 Validate that all values passed are valid IPv4 addresses.
6053 Fail compilation if any value fails this check.
6060 The following values will pass:
6063 validate_ipv4_address($my_ip)
6064 validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip)
6066 The following values will fail, causing compilation to abort:
6068 $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
6069 validate_ipv4_address($some_array)
6072 #### `validate_ipv4_address()`
6074 The validate_ipv4_address function.
6076 Returns: `Any` passes when the given values are valid IPv4 addresses or raise an error when they are not and fails compilation
6083 The following values will pass:
6086 validate_ipv4_address($my_ip)
6087 validate_ipv4_address("8.8.8.8", "172.16.0.1", $my_ip)
6089 The following values will fail, causing compilation to abort:
6091 $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
6092 validate_ipv4_address($some_array)
6095 ### validate_ipv6_address
6099 Validate the passed value represents an ipv6_address.
6101 #### `validate_ipv6_address(Any $scope, Any *$args)`
6103 The validate_ipv6_address function.
6105 Returns: `Boolean` `true` or `false`
6106 A boolean value returned from the called function.
6112 The main value that will be passed to the method
6118 Any additional values that are to be passed to the method
6120 ### validate_ipv6_address
6124 Validate that all values passed are valid IPv6 addresses.
6125 Fail compilation if any value fails this check.
6132 The following values will pass:
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)
6139 The following values will fail, causing compilation to abort:
6141 $some_array = [ true, false, "garbage string", "1.2.3.4" ]
6142 validate_ipv6_address($some_array)
6145 #### `validate_ipv6_address()`
6147 The validate_ipv6_address function.
6149 Returns: `Any` passes when the given values are valid IPv6 addresses or raise an error when they are not and fails compilation
6156 The following values will pass:
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)
6163 The following values will fail, causing compilation to abort:
6165 $some_array = [ true, false, "garbage string", "1.2.3.4" ]
6166 validate_ipv6_address($some_array)
6173 Validate a value against both the target_type (new) and the previous_validation function (old).
6175 #### `validate_legacy(Any $scope, Type $target_type, String $function_name, Any $value, Any *$args)`
6177 The function checks a value against both the target_type (new) and the previous_validation function (old).
6179 Returns: `Any` A boolean value (`true` or `false`) returned from the called function.
6185 The main value that will be passed to the method
6193 ##### `function_name`
6209 Any additional values that are to be passed to the method
6211 #### `validate_legacy(Any $scope, String $type_string, String $function_name, Any $value, Any *$args)`
6213 The validate_legacy function.
6215 Returns: `Any` Legacy validation method
6221 The main value that will be passed to the method
6229 ##### `function_name`
6245 Any additional values that are to be passed to the method
6247 ### validate_numeric
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.
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.
6259 #### `validate_numeric()`
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.
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.
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.
6271 ### validate_numeric
6275 Validate the passed value represents a numeric value.
6277 #### `validate_numeric(Any $scope, Any *$args)`
6279 The validate_numeric function.
6281 Returns: `Boolean` `true` or `false`
6282 A boolean value returned from the called function.
6288 The main value that will be passed to the method
6294 Any additional values that are to be passed to the method
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
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]$')
6318 The following strings will validate against the regular expressions:
6320 validate_re('one', '^one$')
6321 validate_re('one', [ '^one', '^two' ])
6323 The following strings will fail to validate, causing compilation to abort:
6325 validate_re('one', [ '^two', '^three' ])
6327 A helpful error message can be returned like this:
6329 validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
6332 #### `validate_re()`
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
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]$')
6347 Returns: `Any` validation of a string against one or more regular expressions.
6354 The following strings will validate against the regular expressions:
6356 validate_re('one', '^one$')
6357 validate_re('one', [ '^one', '^two' ])
6359 The following strings will fail to validate, causing compilation to abort:
6361 validate_re('one', [ '^two', '^three' ])
6363 A helpful error message can be returned like this:
6365 validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
6372 Perform validation of a string against one or more regular
6375 #### `validate_re(Any $scope, Any *$args)`
6377 The validate_re function.
6379 Returns: `Boolean` `true` or `false` returned from the called function.
6385 The main value that will be passed to the method
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
6396 ### validate_slength
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.
6409 The following values will pass:
6411 validate_slength("discombobulate",17)
6412 validate_slength(["discombobulate","moo"],17)
6413 validate_slength(["discombobulate","moo"],17,3)
6415 The following valueis will not:
6417 validate_slength("discombobulate",1)
6418 validate_slength(["discombobulate","thermometer"],5)
6419 validate_slength(["discombobulate","moo"],17,10)
6422 #### `validate_slength()`
6424 The validate_slength function.
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.
6433 The following values will pass:
6435 validate_slength("discombobulate",17)
6436 validate_slength(["discombobulate","moo"],17)
6437 validate_slength(["discombobulate","moo"],17,3)
6439 The following valueis will not:
6441 validate_slength("discombobulate",1)
6442 validate_slength(["discombobulate","thermometer"],5)
6443 validate_slength(["discombobulate","moo"],17,10)
6446 ### validate_slength
6450 Validate that a passed string has length less/equal with the passed value
6452 #### `validate_slength(Any $scope, Any *$args)`
6454 Validate that a passed string has length less/equal with the passed value
6456 Returns: `Boolean` `true` or `false`
6457 A boolean value returned from the called function.
6463 The main value that will be passed to the method
6469 Any additional values that are to be passed to the method
6475 Validate that all passed values are string data structures.
6477 #### `validate_string(Any $scope, Any *$args)`
6479 The validate_string function.
6481 Returns: `Boolean` `true` or `false`
6482 A boolean value returned from the called function.
6488 The main value that will be passed to the method
6494 Any additional values that are to be passed to the method
6501 Validate_string(undef) will not fail in this version of the
6502 functions API (incl. current and future parser). Instead, use:
6514 The following values will pass:
6516 $my_string = "one two"
6517 validate_string($my_string, 'three')
6519 The following values will fail, causing compilation to abort:
6521 validate_string(true)
6522 validate_string([ 'some', 'array' ])
6525 #### `validate_string()`
6528 Validate_string(undef) will not fail in this version of the
6529 functions API (incl. current and future parser). Instead, use:
6536 Returns: `Any` Validate that all passed values are string data structures. Failed
6537 compilation if any value fails this check.
6544 The following values will pass:
6546 $my_string = "one two"
6547 validate_string($my_string, 'three')
6549 The following values will fail, causing compilation to abort:
6551 validate_string(true)
6552 validate_string([ 'some', 'array' ])
6555 ### validate_x509_rsa_key_pair
6559 ```validate_x509_rsa_key_pair($cert, $key)```
6561 #### `validate_x509_rsa_key_pair()`
6563 ```validate_x509_rsa_key_pair($cert, $key)```
6565 Returns: `Any` Fail compilation if any value fails this check.
6572 From Puppet 5.5.0, the compatible function with the same name in Puppet core
6573 will be used instead of this function.
6587 This example would return: ```[1,2,3]```
6593 From Puppet 5.5.0, the compatible function with the same name in Puppet core
6594 will be used instead of this function.
6596 Returns: `Any` array of values
6610 This example would return: ```[1,2,3]```
6617 The first argument is the array you want to analyze, and the second element can
6618 be a combination of:
6620 * A single numeric index
6621 * A range in the form of 'start-stop' (eg. 4-9)
6622 * An array combining the above
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:
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']`
6638 values_at(['a','b','c'], 2)
6641 values_at(['a','b','c'], ["0-1"])
6642 Would return ['a','b']
6644 values_at(['a','b','c','d','e'], [0, "2-3"])
6645 Would return ['a','c','d']
6650 The first argument is the array you want to analyze, and the second element can
6651 be a combination of:
6653 * A single numeric index
6654 * A range in the form of 'start-stop' (eg. 4-9)
6655 * An array combining the above
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:
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']`
6665 Returns: `Any` an array of values identified by location
6673 values_at(['a','b','c'], 2)
6676 values_at(['a','b','c'], ["0-1"])
6677 Would return ['a','b']
6679 values_at(['a','b','c','d','e'], [0, "2-3"])
6680 Would return ['a','c','d']
6687 Takes one element from first array and merges corresponding elements from second array.
6694 zip(['1','2','3'],['4','5','6'])
6695 Would result in: ["1", "4"], ["2", "5"], ["3", "6"]
6702 Returns: `Any` This generates a sequence of n-element arrays, where n is one more than the count of arguments.
6709 zip(['1','2','3'],['4','5','6'])
6710 Would result in: ["1", "4"], ["2", "5"], ["3", "6"]
6715 ### Stdlib::Absolutepath
6717 A strict absolutepath type
6719 Alias of `Variant[Stdlib::Windowspath, Stdlib::Unixpath]`
6723 Type to match base32 String
6725 Alias of `Pattern[/^[a-z2-7]+={,6}$/, /^[A-Z2-7]+={,6}$/]`
6729 Type to match base64 String
6731 Alias of `Pattern[/^[a-zA-Z0-9\/\+]+={,2}$/]`
6733 ### Stdlib::Compat::Absolute_path
6735 Emulate the is_absolute_path and validate_absolute_path functions
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?
6740 %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
6742 Alias of `Variant[Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/], Pattern[/^\//]]`
6744 ### Stdlib::Compat::Array
6746 Emulate the is_array and validate_array functions
6748 Alias of `Array[Any]`
6750 ### Stdlib::Compat::Bool
6752 Emulate the is_bool and validate_bool functions
6756 ### Stdlib::Compat::Float
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:
6762 ```class example($value) { validate_float($value,) }```
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}.")
6775 This allows you to find all places where a consumers of your code call it with unexpected values.
6777 Alias of `Variant[Float, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)(?:[eE]-?\d+)?$/]]`
6779 ### Stdlib::Compat::Hash
6781 Emulate the is_hash and validate_hash functions
6783 Alias of `Hash[Any, Any]`
6785 ### Stdlib::Compat::Integer
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:
6793 ```class example($value) { validate_integer($value, 10, 0) }```
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}.")
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.
6808 This allows you to find all places where a consumers of your code call it with unexpected values.
6810 Alias of `Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/], Array[Variant[Integer, Pattern[/^-?(?:(?:[1-9]\d*)|0)$/]]]]`
6812 ### Stdlib::Compat::Ip_address
6814 The Stdlib::Compat::Ip_address data type.
6816 Alias of `Variant[Stdlib::Compat::Ipv4, Stdlib::Compat::Ipv6]`
6818 ### Stdlib::Compat::Ipv4
6820 Emulate the validate_ipv4_address and is_ipv4_address functions
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]+))?$/]`
6824 ### Stdlib::Compat::Ipv6
6826 The Stdlib::Compat::Ipv6 data type.
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*$/]`
6830 ### Stdlib::Compat::Numeric
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:
6838 ```class example($value) { validate_numeric($value, 10, 0) }```
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}.")
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.
6853 This allows you to find all places where a consumers of your code call it with unexpected values.
6855 Alias of `Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/], Array[Variant[Numeric, Pattern[/^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$/]]]]`
6857 ### Stdlib::Compat::String
6859 Emulate the is_string and validate_string functions
6861 Alias of `Optional[String]`
6863 ### Stdlib::Ensure::Service
6865 The Stdlib::Ensure::Service data type.
6867 Alias of `Enum['stopped', 'running']`
6869 ### Stdlib::Filemode
6871 See `man chmod.1` for the regular expression for symbolic mode
6873 Alias of `Pattern[/^(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))$/]`
6875 ### Stdlib::Filesource
6877 Validate the source parameter on file types
6879 Alias of `Variant[Stdlib::Absolutepath, Stdlib::HTTPUrl, Pattern[
6880 /^file:\/\/\/([^\/\0]+(\/)?)+$/,
6881 /^puppet:\/\/(([\w-]+\.?)+)?\/([^\/\0]+(\/)?)+$/,
6886 The Stdlib::Fqdn data type.
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])$/]`
6890 ### Stdlib::HTTPSUrl
6892 The Stdlib::HTTPSUrl data type.
6894 Alias of `Pattern[/(?i:^https:\/\/)/]`
6898 The Stdlib::HTTPUrl data type.
6900 Alias of `Pattern[/(?i:^https?:\/\/)/]`
6904 The Stdlib::Host data type.
6906 Alias of `Variant[Stdlib::Fqdn, Stdlib::Compat::Ip_address]`
6908 ### Stdlib::IP::Address
6910 The Stdlib::IP::Address data type.
6912 Alias of `Variant[Stdlib::IP::Address::V4, Stdlib::IP::Address::V6]`
6914 ### Stdlib::IP::Address::Nosubnet
6916 The Stdlib::IP::Address::Nosubnet data type.
6918 Alias of `Variant[Stdlib::IP::Address::V4::Nosubnet, Stdlib::IP::Address::V6::Nosubnet]`
6920 ### Stdlib::IP::Address::V4
6922 The Stdlib::IP::Address::V4 data type.
6924 Alias of `Variant[Stdlib::IP::Address::V4::CIDR, Stdlib::IP::Address::V4::Nosubnet]`
6926 ### Stdlib::IP::Address::V4::CIDR
6928 The Stdlib::IP::Address::V4::CIDR data type.
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/]`
6932 ### Stdlib::IP::Address::V4::Nosubnet
6934 The Stdlib::IP::Address::V4::Nosubnet data type.
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/]`
6938 ### Stdlib::IP::Address::V6
6940 The Stdlib::IP::Address::V6 data type.
6942 Alias of `Variant[Stdlib::IP::Address::V6::Full, Stdlib::IP::Address::V6::Compressed, Stdlib::IP::Address::V6::Alternative, Stdlib::IP::Address::V6::Nosubnet]`
6944 ### Stdlib::IP::Address::V6::Alternative
6946 The Stdlib::IP::Address::V6::Alternative data type.
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/]`
6950 ### Stdlib::IP::Address::V6::CIDR
6952 The Stdlib::IP::Address::V6::CIDR data type.
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/]`
6956 ### Stdlib::IP::Address::V6::Compressed
6958 The Stdlib::IP::Address::V6::Compressed data type.
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/]`
6962 ### Stdlib::IP::Address::V6::Full
6964 The Stdlib::IP::Address::V6::Full data type.
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/]`
6968 ### Stdlib::IP::Address::V6::Nosubnet
6970 The Stdlib::IP::Address::V6::Nosubnet data type.
6972 Alias of `Variant[Stdlib::IP::Address::V6::Nosubnet::Full, Stdlib::IP::Address::V6::Nosubnet::Compressed, Stdlib::IP::Address::V6::Nosubnet::Alternative]`
6974 ### Stdlib::IP::Address::V6::Nosubnet::Alternative
6976 The Stdlib::IP::Address::V6::Nosubnet::Alternative data type.
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/]`
6980 ### Stdlib::IP::Address::V6::Nosubnet::Compressed
6982 The Stdlib::IP::Address::V6::Nosubnet::Compressed data type.
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/]`
6986 ### Stdlib::IP::Address::V6::Nosubnet::Full
6988 The Stdlib::IP::Address::V6::Nosubnet::Full data type.
6990 Alias of `Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/]`
6994 A type for a MAC address
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})$/]`
6998 ### Stdlib::ObjectStore
7000 The Stdlib::ObjectStore data type.
7002 Alias of `Variant[Stdlib::ObjectStore::GSUri, Stdlib::ObjectStore::S3Uri]`
7004 ### Stdlib::ObjectStore::GSUri
7006 The Stdlib::ObjectStore::GSUri data type.
7008 Alias of `Pattern[/^gs:\/\//]`
7010 ### Stdlib::ObjectStore::S3Uri
7012 The Stdlib::ObjectStore::S3Uri data type.
7014 Alias of `Pattern[/^s3:\/\//]`
7018 The Stdlib::Port data type.
7020 Alias of `Integer[0, 65535]`
7022 ### Stdlib::Port::Privileged
7024 The Stdlib::Port::Privileged data type.
7026 Alias of `Integer[1, 1023]`
7028 ### Stdlib::Port::Unprivileged
7030 The Stdlib::Port::Unprivileged data type.
7032 Alias of `Integer[1024, 65535]`
7034 ### Stdlib::Syslogfacility
7036 The Stdlib::Syslogfacility data type.
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']`
7040 ### Stdlib::Unixpath
7042 this regex rejects any path component that does not start with "/" or is NUL
7044 Alias of `Pattern[/^\/([^\/\0]+\/*)*$/]`
7046 ### Stdlib::Windowspath
7048 The Stdlib::Windowspath data type.
7050 Alias of `Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/]`
7054 The Stdlib::Yes_no data type.
7056 Alias of `Pattern[/\A(?i:(yes|no))\z/]`