This module follows semver.org (v1.0.0) versioning guidelines. The standard
library module is released as part of [Puppet
Enterprise](http://puppetlabs.com/puppet/puppet-enterprise/) and as a result
older versions of Puppet Enterprise that Puppet Labs still supports will have
bugfix maintenance branches periodically "merged up" into master. The current
list of integration branches are:
*v2.1.x (v2.1.1 released in PE 1)
*v2.2.x (Never released as part of PE, only to the Forge)
*v2.3.x (Released in PE 2)
*v3.0.x (Released in PE 3)
*v4.0.x (Maintains compatibility with v3.x despite the major semantic version bump. Compatible with Puppet 2.7.x)
*v5.x (To be released when stdlib can drop support for Puppet 2.7.x. Please see [this discussion](https://github.com/puppetlabs/puppetlabs-stdlib/pull/176#issuecomment-30251414))
*master (mainline development branch)
The first Puppet Enterprise version including the stdlib module is Puppet
Enterprise 1.2.
# Compatibility #
Puppet Versions | < 2.6 | 2.6 | 2.7 | 3.x |
:---------------|:-----:|:---:|:---:|:----:
**stdlib 2.x** | no | **yes** | **yes** | no
**stdlib 3.x** | no | no | **yes** | **yes**
**stdlib 4.x** | no | no | **yes** | **yes**
The stdlib module does not work with Puppet versions released prior to Puppet
2.6.0.
## stdlib 2.x ##
All stdlib releases in the 2.0 major version support Puppet 2.6 and Puppet 2.7.
## stdlib 3.x ##
The 3.0 major release of stdlib drops support for Puppet 2.6. Stdlib 3.x
supports Puppet 2 and Puppet 3.
## stdlib 4.x ##
The 4.0 major release of stdlib was intended to drop support for Puppet 2.7,
but the impact on end users was too high. The decision was made to treat
stdlib 4.x as a continuation of stdlib 3.x support. Stdlib 4.x supports Puppet
2.7 and 3. Notably, ruby 1.8.5 is no longer supported though ruby
1.8.7, 1.9.3, and 2.0.0 are fully supported.
# Functions #
abs
---
Returns the absolute value of a number, for example -34.56 becomes
34.56. Takes a single integer and float value as an argument.
-*Type*: rvalue
any2array
---------
This converts any object to an array containing that object. Empty argument
lists are converted to an empty array. Arrays are left untouched. Hashes are
converted to arrays of alternating keys and values.
-*Type*: rvalue
base64
--------
Converts a string to and from base64 encoding.
Requires an action ['encode','decode'] and either a plain or base64 encoded
string
-*Type*: rvalue
bool2num
--------
Converts a boolean to a number. Converts the values:
false, f, 0, n, and no to 0
true, t, 1, y, and yes to 1
Requires a single boolean or string as an input.
-*Type*: rvalue
capitalize
----------
Capitalizes the first letter of a string or array of strings.
Requires either a single string or an array as an input.
-*Type*: rvalue
chomp
-----
Removes the record separator from the end of a string or an array of
strings, for example `hello\n` becomes `hello`.
Requires a single string or array as an input.
-*Type*: rvalue
chop
----
Returns a new string with the last character removed. If the string ends
with `\r\n`, both characters are removed. Applying chop to an empty
string returns an empty string. If you wish to merely remove record
separators then you should use the `chomp` function.
Requires a string or array of strings as input.
-*Type*: rvalue
concat
------
Appends the contents of array 2 onto array 1.
*Example:*
concat(['1','2','3'],['4','5','6'])
Would result in:
['1','2','3','4','5','6']
concat(['1','2','3'],'4')
Would result in:
['1','2','3','4']
-*Type*: rvalue
count
-----
Takes an array as first argument and an optional second argument.
Count the number of elements in array that matches second argument.
If called with only an array it counts the number of elements that are not nil/undef.
-*Type*: rvalue
defined_with_params
-------------------
Takes a resource reference and an optional hash of attributes.
Returns true if a resource with the specified attributes has already been added
to the catalog, and false otherwise.
user { 'dan':
ensure => present,
}
if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
user { 'dan': ensure => present, }
}
-*Type*: rvalue
delete
------
Deletes all instances of a given element from an array, substring from a
string, or key from a hash.
*Examples:*
delete(['a','b','c','b'], 'b')
Would return: ['a','c']
delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
Would return: {'a'=>1,'c'=>3}
delete('abracadabra', 'bra')
Would return: 'acada'
-*Type*: rvalue
delete_at
---------
Deletes a determined indexed value from an array.
*Examples:*
delete_at(['a','b','c'], 1)
Would return: ['a','c']
-*Type*: rvalue
delete_values
-------------
Deletes all instances of a given value from a hash.
Validate that all passed values are string data structures. Abort catalog
compilation if any value fails this check.
The following values will pass:
$my_string = "one two"
validate_string($my_string, 'three')
The following values will fail, causing compilation to abort:
validate_string(true)
validate_string([ 'some', 'array' ])
$undefined = undef
validate_string($undefined)
-*Type*: statement
values
------
When given a hash this function will return the values of that hash.
*Examples:*
$hash = {
'a' => 1,
'b' => 2,
'c' => 3,
}
values($hash)
This example would return:
[1,2,3]
-*Type*: rvalue
values_at
---------
Finds value inside an array based on location.
The first argument is the array you want to analyze, and the second element can
be a combination of:
*A single numeric index
*A range in the form of 'start-stop' (eg. 4-9)
*An array combining the above
*Examples*:
values_at(['a','b','c'], 2)
Would return ['c'].
values_at(['a','b','c'], ["0-1"])
Would return ['a','b'].
values_at(['a','b','c','d','e'], [0, "2-3"])
Would return ['a','c','d'].
-*Type*: rvalue
zip
---
Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments.
*Example:*
zip(['1','2','3'],['4','5','6'])
Would result in:
["1", "4"], ["2", "5"], ["3", "6"]
-*Type*: rvalue
*This page autogenerated on 2013-04-11 13:54:25 -0700*