A collection of task oriented solutions in Puppet

 

Install the Puppet stdlib module

Challenge

You want to use code from the puppet stdlib

Solution

First install stdlib from the puppet forge:

# install the stdlib module
$ sudo /opt/puppetlabs/bin/puppet module install puppetlabs-stdlib

...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/site
  puppetlabs-stdlib (v4.12.9)
...

Then use code from it in your puppet manifests:

class strace {
  notify { 'In strace': }
  ensure_packages(['strace'], { ensure => 'present' })
}

class debug_tools {
  # install lots of debug tools, and then strace
  notify { 'In debug_tools': }
  ensure_packages(['strace'], { ensure => 'present' })
}

include strace
include debug_tools

Explanation

The Puppetlabs stdlib module is a collection of puppet enhancements that provide commonly requested functionality, some basic additions missing from the core and some version compatibility shims that can make maintaining code across multiple puppet versions easier.

While it's possible to maintain a large puppet code base without using stdlib a large number of modules on the puppetforge rely on its functionality and it can often save you writing your own little utility functions while also providing some helpful examples of the what and how of extending puppet with functions.

See also