Version information
released Aug 27th 2013
Start using this module
Add this module to your Puppetfile:
mod 'ptomulik-ptlib', '0.1.2'
Learn more about managing modules with a PuppetfileDocumentation
ptomulik/ptlib — version 0.1.2 Aug 27th 2013
ptomulik-ptlib
Utility functions for puppet modules' developers.
Functions
pt_delete_undef_values
Deletes all instances of the undef value from an array or hash.
Examples:
$hash = pt_delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
Would return: {a => 'A', b => '', d => false}
$array = pt_delete_undef_values(['A','',undef,false])
Would return: ['A','',false]
- Type: rvalue
pt_delete_values
Deletes all instances of a given value from a hash.
Examples:
pt_delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
Would return: {'a'=>'A','c'=>'C','B'=>'D'}
- Type: rvalue
pt_getparamdefault
Takes a type or resource reference and name of the parameter and returns default value of parameter for that type/resource (or empty string if default is not set).
Examples:
package { 'apache2': provider => apt }
pt_getparamdefault(Package['apache2'], provider)
Would return '' (default provider was not defined).
Package { provider => aptitude }
node example.com {
package { 'apache2': provider => apt }
pt_getparamdefault(Package['apache2'], provider)
}
Would return 'aptitude'.
Package { provider => aptitude }
node example.com {
Package { provider => apt }
package { 'apache2': }
pt_getparamdefault(Package['apache2'], provider)
}
Would return 'apt'.
Package { provider => aptitude }
node example.com {
Package { provider => apt }
pt_getparamdefault(Package, provider)
}
Would return 'apt'.
pt_getparamdefault(Foo['bar'], geez)
Would not compile (resource Foo[bar] does not exist)
pt_getparamdefault(Foo, geez)
Would not compile (type Foo does not exist)
- Type: rvalue