Puppet 4.10 reference manual

When values for class parameters aren’t explicitly provided, Puppet automatically looks them up in Hiera, using the fully-qualified name of the parameter (like myclass::parameter_one) as a lookup key.

How class parameters work

Most classes need some amount of configuration, and they can specify parameters to request the data they need.

There are three ways to set values for class parameters, and Puppet tries each of them in order when the class is declared or assigned by an ENC:

  1. If it was a resource-like declaration/assignment, Puppet uses any parameters that were explicitly set. These always win if they exist.
  2. Puppet automatically looks up the remaining parameters with Hiera, using <CLASS NAME>::<PARAMETER NAME> as the lookup key (for example, ntp::servers for the ntp class’s $servers parameter).
  3. For any parameters that still have no value, Puppet uses the default value from the class’s definition.
  4. If any parameters have no value AND no default, Puppet fails compilation with an error.

Thus, you can set servers for the NTP class like this:

# /etc/puppetlabs/code/production/data/nodes/web01.example.com.yaml
  - time.example.com
  - 0.pool.ntp.org

That’s automatic class parameter lookup.

Pro-tip: Use the roles and profiles method

Automatic class parameter lookup is powerful, but you probably use thousands of class parameters to describe your infrastructure, and putting them all in Hiera is an invitation to chaos. The best way to manage that is to use the roles and profiles method, which allows you to store a smaller amount of more meaningful data in Hiera. For more details, see our documentation on the roles and profiles method.

Back to top
The page rank or the 1 our of 5 rating a user has given the page.
The email address of the user submitting feedback.
The URL of the page being ranked/rated.