extended_stdlib
Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x
- Puppet >= 5.5.0 < 9.0.0
- , , , ,
Tasks:
- csr_attributes
Plans:
- csr_regenerate
Start using this module
Add this module to your Puppetfile:
mod 'mschuchard-extended_stdlib', '1.2.1'
Learn more about managing modules with a PuppetfileDocumentation
Extended Stdlib
Overview
This module provides an extra set of extensions and expanded functionality for Puppet modules beyond that which is covered by stdlib
.
Module Description
This Puppet module adds extra facts, functions, types and providers, defined resource types, tasks, and plans to Puppet. These should not overlap with the functionality provided by the stdlib
module or core Puppet. These are also likely to be overall at least slightly less useful than those provided in stdlib
.
Setup
Install the extended_stdlib
module to add the functionality to Puppet. Pluginsync will automatically ensure the functionality prior to the next catalog application.
If you are authoring a module that depends on extended_stdlib
, then be sure to specify dependencies in your metadata.json
.
Usage
These are all automatically loaded by Puppet via pluginsync.
Reference
Please see the Reference for generated documentation.
Facts
powershell_version
Returns the semantic Powershell version on a Windows system.
subnet
Returns the ipv4-based subnet for the system.
Limitations
The Ruby code is tested primarily with versions synced with Puppet 7 and 8. Compatibility with Ruby versions synced with 5 and 6 is desired, but not guaranteed. Please open an issue if an incompatibility is encountered.
Contributing
Code should pass all current tests. New features should include new tests. Adherence to Ruby and Puppet style standards is expected where not overly onerous or where the check is of dubious cost/benefit.
Please consult the GitHub Project for the current development roadmap.
Reference
Table of Contents
Defined types
extended_stdlib::script
: Manages a script's existence in the directory of a system, and then executes the script if the script's attributes changed.
Functions
extended_stdlib::ascii_only
: Returns true for a string which has only ASCII characters, and false otherwise.extended_stdlib::center
: Centers a string in width. If the width is greater than the length of the string, then the string is centered by padding and padded with padsextended_stdlib::compact
: Returns a hash or array with all of the undef value entries removedextended_stdlib::decrypt_string
: Returns a decrypted String using the AES-256-CBC OpenSSL cipher algorithm.extended_stdlib::drop
: Returns an Array containing all but the first num element of the array, where num is a non-negative Integerextended_stdlib::end_with
: Returns true if the string ends with one of the suffixes given.extended_stdlib::exp
: Returns e**x.extended_stdlib::imperative
: THIS FUNCTION IS CURRENTLY IN BETA. Puppet function to simulate imperative execution for a subset of resources by constructing iterative dependencies of each resource upon the previous resource. This thusly ensures consecutive resource application vis a vis imperative application instead of declarative.extended_stdlib::intersect
: Returns true if the array and other_array have at least one element in common, otherwise returns false. Requires Ruby >= 3.1.extended_stdlib::log
: Returns the logarithm of x. If an additional second argument is given, then it will be the logarithm base. Otherwise it is e (for the naturalextended_stdlib::minmax
: Returns a new two element Array containing the minimum and maximum values from an array of integersextended_stdlib::next
: Returns the successor to the string. The successor is calculated by incrementing characters.extended_stdlib::none
: Returns a boolean of whether no elements of an array, or array or hash with a lambda block meet a given criterion. Note that the combined bloextended_stdlib::product
: Computes and returns all combinations of elements from all of the Arraysextended_stdlib::sample
: Returns random elements from an Array. Note that the return is non-deterministic.extended_stdlib::sqrt
: Returns the non-negative square root of x.extended_stdlib::start_with
: Returns true if the string starts with one of the prefixes given. Each prefix should be a String or (Ruby >= 2.5) Regexp.extended_stdlib::subset
: Returns a boolean of whether the first hash is a subset of the second hashextended_stdlib::sum
: Returns the sum of an optional summand with all elements of an Array.extended_stdlib::translate
: Replaces the characters in from_str with the characters in to_str. If to_str is shorter than from_str, then it is padded with its last characextended_stdlib::transpose
: Transposes the rows and columns in an Array of Arrays; the nested Arrays must all be the same size.extended_stdlib::truncate
: Returns integer truncated (toward zero) to a precision of num_digits decimal digits. When num_digits is negative, the returned value has at l
Tasks
csr_attributes
: Modifies CSR attributes on a client server.
Plans
extended_stdlib::csr_regenerate
: This plan modifies the CSR attributes on servers, and then regenerates the client certificate on the servers to enable PuppetDB to update the
Defined types
extended_stdlib::script
Manages a script's existence in the directory of a system, and then executes the script if the script's attributes changed.
Examples
Manages a script named 'myscript.sh' on the target system and sourced from the containing module, and then executes the script with the default shell interpreter.
extended_stdlib::script { 'myscript.sh': }
Parameters
The following parameters are available in the extended_stdlib::script
defined type:
script
Data type: String
The filename of the script to be managed and executed. Defaults to the title of the resource.
Default value: $title
module
Data type: String
The module containing the script. Defaults to the module where this resource is declared.
Default value: $caller_module_name
shell_path
Data type: String
The path to the shell interpreter executable used for executing the managed script file.
Default value: '/bin/sh'
stage_dir
Data type: String
The path to the staging directory for managing the script file on the target system prior to execution.
Default value: '/tmp'
source_file
Data type: String
The filename of the source script file. Templates are handled automatically. Defaults to the script param.
Default value: $script
epp_vars
Data type: Hash
A hash of variable names and values to be passed as an argument to the epp function (if applicable).
Default value: {}
file_attr
Data type: Hash
A hash of additional attribute => value pairs to append to the file resource that manages the script.
Default value: {}
exec_attr
Data type: Hash
A hash of additional attribute => value pairs to append to the exec resource that execures the script.
Default value: {}
Functions
extended_stdlib::ascii_only
Type: Ruby 4.x API
Returns true for a string which has only ASCII characters, and false otherwise.
Examples
Returns that a string is ASCII only.
ascii_only('abc') => true
Returns that a string is not ASCII only.
ascii_only('abc\u{6666}') => false
extended_stdlib::ascii_only(String $a_string, Optional[String] $encoding)
Returns true for a string which has only ASCII characters, and false otherwise.
Returns: Boolean
Boolean Whether the string is ASCII only.
Examples
Returns that a string is ASCII only.
ascii_only('abc') => true
Returns that a string is not ASCII only.
ascii_only('abc\u{6666}') => false
a_string
Data type: String
The string to determine whether it is ASCII only.
encoding
Data type: Optional[String]
The text encoding for the string (default: UTF-8).
extended_stdlib::center
Type: Ruby 4.x API
Centers a string in width. If the width is greater than the length of the string, then the string is centered by padding and padded with padstring; otherwise the string is returnd.
Examples
Returns the string since width is smaller than the string.
center('hello', 4) => 'hello'
Returns the centered string padded with empty string.
center('hello', 20) => ' hello '
Returns the centered string padded with '#-'.
center('hello', 20, '#-') => '#-#-#-#hello#-#-#-#'
extended_stdlib::center(String $a_string, Integer $width, Optional[String] $pad_string)
Centers a string in width. If the width is greater than the length of the string, then the string is centered by padding and padded with padstring; otherwise the string is returnd.
Returns: String
String The resultant apdded string.
Examples
Returns the string since width is smaller than the string.
center('hello', 4) => 'hello'
Returns the centered string padded with empty string.
center('hello', 20) => ' hello '
Returns the centered string padded with '#-'.
center('hello', 20, '#-') => '#-#-#-#hello#-#-#-#'
a_string
Data type: String
The string to center in width with the pad_string.
width
Data type: Integer
The width of the resultant padded string.
pad_string
Data type: Optional[String]
The optional string to use for the surrounding padding.
extended_stdlib::compact
Type: Ruby 4.x API
Returns a hash or array with all of the undef value entries removed
Examples
Input a hash and return it compacted.
compact({'foo' => 0, 'bar' => undef, 'baz' => 2, 'bat' => undef}) => {'foo' => 0, 'baz' => 2}
Input an array and return it compacted.
compact([undef, 0, undef, 1, undef, 2, undef]) => [0, 1, 2]
extended_stdlib::compact(Variant[Hash, Array] $hash_or_array)
Returns a hash or array with all of the undef value entries removed
Returns: Variant[Hash, Array]
The hash or array with all of the undef value entries removed.
Examples
Input a hash and return it compacted.
compact({'foo' => 0, 'bar' => undef, 'baz' => 2, 'bat' => undef}) => {'foo' => 0, 'baz' => 2}
Input an array and return it compacted.
compact([undef, 0, undef, 1, undef, 2, undef]) => [0, 1, 2]
hash_or_array
Data type: Variant[Hash, Array]
The hash or array from which to remove the undef value entries.
extended_stdlib::decrypt_string
Type: Ruby 4.x API
Returns a decrypted String using the AES-256-CBC OpenSSL cipher algorithm.
Examples
Decrypt an encrypted string and return it plain text.
decrypt_string('/path/to/key.txt', '/path/to/nonce.txt', '/path/to/encrypted.txt') => foobar
extended_stdlib::decrypt_string(Pattern[/\A\/([^\n\/\0]+\/*)*\z/] $key, Pattern[/\A\/([^\n\/\0]+\/*)*\z/] $nonce, String $encrypted)
Returns a decrypted String using the AES-256-CBC OpenSSL cipher algorithm.
Returns: String
String Returns the encrypted string as decrypted in plain text.
Examples
Decrypt an encrypted string and return it plain text.
decrypt_string('/path/to/key.txt', '/path/to/nonce.txt', '/path/to/encrypted.txt') => foobar
key
Data type: Pattern[/\A\/([^\n\/\0]+\/*)*\z/]
The path to the file containing the cipher key.
nonce
Data type: Pattern[/\A\/([^\n\/\0]+\/*)*\z/]
The path to the file containing the cipher nonce.
encrypted
Data type: String
The encrypted string to decrypt.
extended_stdlib::drop
Type: Ruby 4.x API
Returns an Array containing all but the first num element of the array, where num is a non-negative Integer
Examples
Remove the first 0, 1, or 2 elements from an array, and return that array.
drop([0, 1, 2, 3, 4, 5], 0) => [0, 1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 1) => [1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 2) => [2, 3, 4, 5]
extended_stdlib::drop(Array $the_array, Integer $num)
Returns an Array containing all but the first num element of the array, where num is a non-negative Integer
Returns: Array
Returns the array with the first num elements removed.
Examples
Remove the first 0, 1, or 2 elements from an array, and return that array.
drop([0, 1, 2, 3, 4, 5], 0) => [0, 1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 1) => [1, 2, 3, 4, 5]
drop([0, 1, 2, 3, 4, 5], 2) => [2, 3, 4, 5]
the_array
Data type: Array
The array to remove the first num elements from.
num
Data type: Integer
The number of first elements to remove from the array.
extended_stdlib::end_with
Type: Ruby 4.x API
Returns true if the string ends with one of the suffixes given.
Examples
Check if the string ends with one suffix.
end_with('hello', ['ello']) => true
Check if the string ends with one of the suffixes.
end_with('hello', ['heaven', 'ello']) => true
end_with('hello', ['heaven', 'paradise']) => false
extended_stdlib::end_with(String $a_string, Array[String] *$suffixes)
Returns true if the string ends with one of the suffixes given.
Returns: Boolean
Boolean Whether or not the string ends with one of the given suffixes.
Examples
Check if the string ends with one suffix.
end_with('hello', ['ello']) => true
Check if the string ends with one of the suffixes.
end_with('hello', ['heaven', 'ello']) => true
end_with('hello', ['heaven', 'paradise']) => false
a_string
Data type: String
The string to check if it ends with one of the given suffixes.
*suffixes
Data type: Array[String]
The suffixes to check for if the string ends.
extended_stdlib::exp
Type: Ruby 4.x API
Returns e**x.
extended_stdlib::exp(Numeric $x)
Returns e**x.
Returns: Float
x
Data type: Numeric
extended_stdlib::imperative
Type: Puppet Language
THIS FUNCTION IS CURRENTLY IN BETA. Puppet function to simulate imperative execution for a subset of resources by constructing iterative dependencies of each resource upon the previous resource. This thusly ensures consecutive resource application vis a vis imperative application instead of declarative.
Examples
Consecutively apply package resources.
extended_stdlib::imperative([Package['first'], Package['second'], Package['third']])
Consecutively apply package resources at latest versions.
extended_stdlib::imperative(
{ 'first' => {}, 'second' => {}, 'third' => {} },
'package',
{ 'ensure' => 'latest' }
)
extended_stdlib::imperative(Variant[Hash, Array[Type[Resource], 2]] $resources, Optional[Pattern[/^[a-z]+$/]] $type = undef, Optional[Hash] $defaults = {})
The extended_stdlib::imperative function.
Returns: Variant[Hash, Tuple]
Examples
Consecutively apply package resources.
extended_stdlib::imperative([Package['first'], Package['second'], Package['third']])
Consecutively apply package resources at latest versions.
extended_stdlib::imperative(
{ 'first' => {}, 'second' => {}, 'third' => {} },
'package',
{ 'ensure' => 'latest' }
)
resources
Data type: Variant[Hash, Array[Type[Resource], 2]]
The hash of resource names and attributes, or array of resources, to construe dependencies for imperative application, and also to declare if input type is hash.
type
Data type: Optional[Pattern[/^[a-z]+$/]]
The resource type to use for declarations if $resources is hash type.
defaults
Data type: Optional[Hash]
The hash of default attributes to use for declaration if $resources is hash type.
extended_stdlib::intersect
Type: Ruby 4.x API
Returns true if the array and other_array have at least one element in common, otherwise returns false. Requires Ruby >= 3.1.
Examples
Determine if first array and second array intersect.
intersect([1, 2, 3], [3, 4, 5]) => true
intersect([1, 2, 3], [5, 6, 7]) => false
extended_stdlib::intersect(Array $a_array, Array $other_array)
Returns true if the array and other_array have at least one element in common, otherwise returns false. Requires Ruby >= 3.1.
Returns: Boolean
Returns whether the two arrays intersect.
Examples
Determine if first array and second array intersect.
intersect([1, 2, 3], [3, 4, 5]) => true
intersect([1, 2, 3], [5, 6, 7]) => false
a_array
Data type: Array
The first array to determine if intersects.
other_array
Data type: Array
The second array to determine if intersects.
extended_stdlib::log
Type: Ruby 4.x API
Returns the logarithm of x. If an additional second argument is given, then it will be the logarithm base. Otherwise it is e (for the natural logarithm).
extended_stdlib::log(Numeric $num, Optional[Numeric] $base)
Returns the logarithm of x. If an additional second argument is given, then it will be the logarithm base. Otherwise it is e (for the natural logarithm).
Returns: Float
num
Data type: Numeric
base
Data type: Optional[Numeric]
extended_stdlib::minmax
Type: Ruby 4.x API
Returns a new two element Array containing the minimum and maximum values from an array of integers
Examples
Return the minimum and maximum elements of an array.
minmax([0, 1, 2]) => [0, 2]
extended_stdlib::minmax(Array[Integer, 2] $the_array)
Returns a new two element Array containing the minimum and maximum values from an array of integers
Returns: Array[Integer, 2]
Returns two element array of integers with minimum and maximum values.
Examples
Return the minimum and maximum elements of an array.
minmax([0, 1, 2]) => [0, 2]
the_array
Data type: Array[Integer, 2]
The array of integers from which to return the minimum and maximum values.
extended_stdlib::next
Type: Ruby 4.x API
Returns the successor to the string. The successor is calculated by incrementing characters.
Examples
Increments the rightmost alphanumeric character, or the rightmost character.
next('THX1138') => 'THX1139'
next('<<koala>>') => '<<koalb>>'
next('***') => '**+'
Increemnts a numeric character.
next('00') => '01'
next('09') => '10'
next('99') => '100'
Increments an alphabetic character in the same case.
next('aa') => 'ab'
next('az') => 'ba'
next('zz') => 'aaa'
extended_stdlib::next(String $a_string)
Returns the successor to the string. The successor is calculated by incrementing characters.
Returns: String
String The next/successive string.
Examples
Increments the rightmost alphanumeric character, or the rightmost character.
next('THX1138') => 'THX1139'
next('<<koala>>') => '<<koalb>>'
next('***') => '**+'
Increemnts a numeric character.
next('00') => '01'
next('09') => '10'
next('99') => '100'
Increments an alphabetic character in the same case.
next('aa') => 'ab'
next('az') => 'ba'
next('zz') => 'aaa'
a_string
Data type: String
The string in which to return the successor.
extended_stdlib::none
Type: Ruby 4.x API
Returns a boolean of whether no elements of an array, or array or hash with a lambda block meet a given criterion. Note that the combined block input forms do not have code coverage at the moment.
extended_stdlib::none(Array $the_array)
The extended_stdlib::none function.
Returns: Boolean
Returns whether no elements satisfy a conditional (i.e. every element is falsey).
Examples
Return whether no element of any array is truthy.
none([undef, false]) => true
none([undef, 0, false]) => false
none([]) => true
Return whether there is an element with an even numbered index that has a String value (no element satisfies these conditions)
['key1', 1, 2, 2].none |$index, $value| { $index % 2 == 0 and $value =~ String } => false
Return whether there is an element with an even numbered index that does not have a String value (element at index 2 causes 'false' return by satisfying both conditionals)
['key1', 1, 2, 2].none |$index, $value| { $index % 2 == 0 and $value !~ String } => false
the_array
Data type: Array
The array containing the elements to test the criterion upon. the_hash The hash containing the entries to test the criterion upon. block The optional lambda block to specify the criterion (otherwise directly tests falsiness).
extended_stdlib::none(Hash[Any, Any] $the_hash, Callable[1,1] &$block)
The extended_stdlib::none function.
Returns: Boolean
the_hash
Data type: Hash[Any, Any]
&block
Data type: Callable[1,1]
extended_stdlib::none(Hash[Any, Any] $the_hash, Callable[2,2] &$block)
The extended_stdlib::none function.
Returns: Boolean
the_hash
Data type: Hash[Any, Any]
&block
Data type: Callable[2,2]
extended_stdlib::none(Iterable $enumerable, Callable[1,1] &$block)
The extended_stdlib::none function.
Returns: Boolean
enumerable
Data type: Iterable
&block
Data type: Callable[1,1]
extended_stdlib::none(Iterable $enumerable, Callable[2,2] &$block)
The extended_stdlib::none function.
Returns: Boolean
enumerable
Data type: Iterable
&block
Data type: Callable[2,2]
extended_stdlib::product
Type: Ruby 4.x API
Computes and returns all combinations of elements from all of the Arrays
Examples
Returns original Array if only one is specified.
product([[0, 1, 2]]) => [[0, 1, 2]]
Return the product of two Arrays.
product([[0, 1, 2], [3, 4]]) => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]]
Return the product of three Arrays.
product([[0, 1, 2], [3, 4], [5, 6]]) => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]
extended_stdlib::product(Array *$arrays)
Computes and returns all combinations of elements from all of the Arrays
Returns: Array[Array]
The nested Array containing the product of the Arrays' elements.
Examples
Returns original Array if only one is specified.
product([[0, 1, 2]]) => [[0, 1, 2]]
Return the product of two Arrays.
product([[0, 1, 2], [3, 4]]) => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]]
Return the product of three Arrays.
product([[0, 1, 2], [3, 4], [5, 6]]) => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]
*arrays
Data type: Array
One or more Arrays of which to compute the products. Issue with required_repeated_param in Puppet requires this to be nested Array.
extended_stdlib::sample
Type: Ruby 4.x API
Returns random elements from an Array. Note that the return is non-deterministic.
Examples
Return a random element from an Array.
sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) => 3
Return multiple random elements from an Array.
sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3) => [8, 9, 2]
sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6) => [9, 6, 10, 3, 1, 4]
extended_stdlib::sample(Array[1] $the_array, Optional[Integer] $num_elements)
Returns random elements from an Array. Note that the return is non-deterministic.
Returns: Variant[Array, Any]
The random element or Array of random elements selected from the Array.
Examples
Return a random element from an Array.
sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) => 3
Return multiple random elements from an Array.
sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3) => [8, 9, 2]
sample([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6) => [9, 6, 10, 3, 1, 4]
the_array
Data type: Array[1]
The Array from which to select random elements.
num_elements
Data type: Optional[Integer]
The number of random elements to select from the Array.
extended_stdlib::sqrt
Type: Ruby 4.x API
Returns the non-negative square root of x.
extended_stdlib::sqrt(Numeric $x)
Returns the non-negative square root of x.
Returns: Float
x
Data type: Numeric
extended_stdlib::start_with
Type: Ruby 4.x API
Returns true if the string starts with one of the prefixes given. Each prefix should be a String or (Ruby >= 2.5) Regexp.
Examples
Check if the string begins with one String prefix.
start_with('hello', ['hell']) => true
Check if the string begins with one Regexp prefix.
start_with('hello', [/h/]) => true
Check if the string begins with one of the prefixes.
start_with('hello', ['heaven', 'hell']) => true
start_with('hello', ['heaven', 'paradise']) => false
extended_stdlib::start_with(String $a_string, Array[Variant[String, Regexp]] *$prefixes)
Returns true if the string starts with one of the prefixes given. Each prefix should be a String or (Ruby >= 2.5) Regexp.
Returns: Boolean
Boolean Whether or not the string begins with one of the given prefixes.
Examples
Check if the string begins with one String prefix.
start_with('hello', ['hell']) => true
Check if the string begins with one Regexp prefix.
start_with('hello', [/h/]) => true
Check if the string begins with one of the prefixes.
start_with('hello', ['heaven', 'hell']) => true
start_with('hello', ['heaven', 'paradise']) => false
a_string
Data type: String
The string to check if it begins with one of the given prefixes.
*prefixes
Data type: Array[Variant[String, Regexp]]
The prefixes to check for if the string begins.
extended_stdlib::subset
Type: Ruby 4.x API
Returns a boolean of whether the first hash is a subset of the second hash
Examples
Determine if hash is subset of other_hash.
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1, 'baz' => 2}) => true
subset({'foo' => 0, 'bar' => 1, 'baz' => 2}, {'foo' => 0, 'bar' => 1}) => false
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}) => true
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}, true) => false
extended_stdlib::subset(Hash $a_hash, Hash $other_hash, Optional[Boolean] $proper)
Returns a boolean of whether the first hash is a subset of the second hash
Returns: Boolean
Returns whether hash is a subset of other_hash.
Examples
Determine if hash is subset of other_hash.
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1, 'baz' => 2}) => true
subset({'foo' => 0, 'bar' => 1, 'baz' => 2}, {'foo' => 0, 'bar' => 1}) => false
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}) => true
subset({'foo' => 0, 'bar' => 1}, {'foo' => 0, 'bar' => 1}, true) => false
a_hash
Data type: Hash
The hash to determine if this hash is a subset of other_hash.
other_hash
Data type: Hash
The hash to determine if hash is a subset of this hash.
proper
Data type: Optional[Boolean]
Specifies if the subset determination should be for a proper subset or regular subset.
extended_stdlib::sum
Type: Ruby 4.x API
Returns the sum of an optional summand with all elements of an Array.
Examples
Returns sum of Array of Integers.
sum([0, 1, 2, 3]) => 6
Returns sum of Integer and Array of Integers.
sum([0, 1, 2, 3], 100) => 106
Returns sum of String and Array of Strings.
sum(['abc', 'def', 'ghi'], 'jkl') => 'jklabcdefghi'
extended_stdlib::sum(Array[Variant[Numeric, String]] $the_array, Optional[Variant[Numeric, String]] $summand)
Returns the sum of an optional summand with all elements of an Array.
Returns: Variant[Numeric, String]
Examples
Returns sum of Array of Integers.
sum([0, 1, 2, 3]) => 6
Returns sum of Integer and Array of Integers.
sum([0, 1, 2, 3], 100) => 106
Returns sum of String and Array of Strings.
sum(['abc', 'def', 'ghi'], 'jkl') => 'jklabcdefghi'
the_array
Data type: Array[Variant[Numeric, String]]
The array to sum with an optional summand.
summand
Data type: Optional[Variant[Numeric, String]]
The optional summand to sum with the Array elements.
extended_stdlib::translate
Type: Ruby 4.x API
Replaces the characters in from_str with the characters in to_str. If to_str is shorter than from_str, then it is padded with its last character in order to maintain the correspondence.
Examples
Replaces characters in the string 'hello'.
translate('hello', 'el', 'ip') => 'hippo'
translate('hello', 'aeiou', '*') => 'h*ll*'
translate('hello', 'aeiou', 'AA*') => 'hAll*'
extended_stdlib::translate(String $a_string, String $from_str, String $to_str)
Replaces the characters in from_str with the characters in to_str. If to_str is shorter than from_str, then it is padded with its last character in order to maintain the correspondence.
Returns: String
String The string with the characters replaced.
Examples
Replaces characters in the string 'hello'.
translate('hello', 'el', 'ip') => 'hippo'
translate('hello', 'aeiou', '*') => 'h*ll*'
translate('hello', 'aeiou', 'AA*') => 'hAll*'
a_string
Data type: String
The string in which to replace the characters.
from_str
Data type: String
The characters in the string to replace.
to_str
Data type: String
The replacement characters for the string.
extended_stdlib::transpose
Type: Ruby 4.x API
Transposes the rows and columns in an Array of Arrays; the nested Arrays must all be the same size.
Examples
Returns 1x2 transposition of 2x1 nested Array.
transpose([['a0', 'a1']]) => [['a0'], ['a1']]
Returns 3x2 transposition of 2x3 nested Array.
transpose([['a0', 'a1'], ['b0', 'b1'], ['c0', 'c1']]) => [['a0', 'b0', 'c0'], ['a1', 'b1', 'c1']]
extended_stdlib::transpose(Array[NotUndef, 1] *$arrays)
Transposes the rows and columns in an Array of Arrays; the nested Arrays must all be the same size.
Returns: Array[Array]
The nested Array containing the transposition of the Arrays' elements.
Examples
Returns 1x2 transposition of 2x1 nested Array.
transpose([['a0', 'a1']]) => [['a0'], ['a1']]
Returns 3x2 transposition of 2x3 nested Array.
transpose([['a0', 'a1'], ['b0', 'b1'], ['c0', 'c1']]) => [['a0', 'b0', 'c0'], ['a1', 'b1', 'c1']]
*arrays
Data type: Array[NotUndef, 1]
One or more equal-size Arrays of which to transpose. Issue with required_repeated_param in Puppet requires this to be nested Array.
extended_stdlib::truncate
Type: Ruby 4.x API
Returns integer truncated (toward zero) to a precision of num_digits decimal digits. When num_digits is negative, the returned value has at least abs(num_digits) trailing zeros. Returns same integer when num_digits is zero or positive.
extended_stdlib::truncate(Integer $a_integer, Optional[Integer] $num_digits)
Returns integer truncated (toward zero) to a precision of num_digits decimal digits. When num_digits is negative, the returned value has at least abs(num_digits) trailing zeros. Returns same integer when num_digits is zero or positive.
Returns: Integer
a_integer
Data type: Integer
num_digits
Data type: Optional[Integer]
Tasks
csr_attributes
Modifies CSR attributes on a client server.
Supports noop? false
Parameters
extension_requests
Data type: Hash
The desired extension requests (permanent data to be embedded in a signed certificate). Note that input values will overwrite current values with the same paired key.
custom_attributes
Data type: Hash
The desired custom attributes (transient data used for pre-validating requests). Note that input values will overwrite current values with the same paired key.
purge_extension_requests
Data type: Boolean
Whether or not to purge the existing extension requests in the CSR attributes when updating.
purge_custom_attributes
Data type: Boolean
Whether or not to purge the existing custom attributes in the CSR attributes instead when updating.
Plans
extended_stdlib::csr_regenerate
This plan modifies the CSR attributes on servers, and then regenerates the client certificate on the servers to enable PuppetDB to update the values from the CSR attributes.
Parameters
The following parameters are available in the extended_stdlib::csr_regenerate
plan:
servers
puppet_orchestrator
extension_requests
custom_attributes
purge_extension_requests
purge_custom_attributes
servers
Data type: TargetSpec
The servers to target for CSR attribute modification.
puppet_orchestrator
Data type: TargetSpec
The server hosting the Puppet Orchestrator software for executing plans and tasks.
extension_requests
Data type: Hash
The desired extensions requests in the CSR attributes.
Default value: {}
custom_attributes
Data type: Hash
The desired custom attributes in the CSR attributes.
Default value: {}
purge_extension_requests
Data type: Boolean
Whether or not to purge the existing extension requests in the CSR attributes when updating.
Default value: false
purge_custom_attributes
Data type: Boolean
Whether or not to purge the existing custom attributes in the CSR attributes instead when updating.
Default value: false
What are tasks?
Modules can contain tasks that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
Tasks in this module release
What are plans?
Modules can contain plans that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
1.2.1
- Fixes for imperative function.
- Update intersect function for removal in Ruby 3.0.
- Officially support Puppet 8.
1.2.0
- Add functions: truncate, exp, log, next, sqrt, translate.
- Add fact: powershell_version.
1.1.1
- Expand
script
DRT functionality. - Improve and cleanup custom functions.
- Expand
imperative
function experimental functionality.
1.1.0
- Add functions: end_with, center, start_with, ascii_only.
- Add defined resource types: script.
- Add Puppet functions: imperative (beta).
1.0.0
- Full initial release.
0.9.2
- Release candidate release.
0.9.1
- Second beta release.
0.9.0
- Initial beta release.