O'Reilly logo

Puppet Essentials by Felix Frank

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A practical example

To round things off, let's build a complete example of a module that is enhanced with Hiera. Create a demo module in the environment of your choice. I will go with production:

# /etc/puppet/env/production/modules/demo/manifests/init.pp
class demo($auto = false,
           $syslog = true,
           $user = 'nobody') {
    file { '/usr/local/bin/demo': … }
    if $auto {
        cron { 'auto-demo':
            user    => $user,
            command => '/usr/local/bin/demo'
            ...
        }
        create_resources('demo::atom', hiera('demo::atoms', {})
    }
}

This class implicitly looks up three Hiera keys for its parameters:

  • demo::auto
  • demo::syslog
  • demo::user

There is also an explicit lookup of an optional demo::atoms hash that creates configuration items for the module. Each hash must fit the defined type, which is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required