Automatic lookup of class parameters
Puppet looks up the values
for class parameters in Hiera, using the fully qualified name of
the parameter (myclass::parameter_one
) as a
lookup key.
Most classes need configuration, and you can specify them as parameters to a class as this looks up the needed data if not directly given when the class is included in a catalog. Puppet sets values for class parameters in this order:
-
If you're doing a resource-like declaration, Puppet uses parameters that are explicitly set (if explicitly setting undef, a looked up value or default is used).
-
Puppet uses Hiera, using
<CLASS NAME>::<PARAMETER NAME>
as the lookup key. For example, it looks upntp::servers
for thentp
class's$servers parameter
. -
If a parameter still has no value, Puppet uses the default value from the parameter's default value expression in the class's definition.
-
If any parameters have no value and no default, Puppet fails compilation with an error.
For example, you can set servers for the NTP
class like this:
# /etc/puppetlabs/code/production/data/nodes/web01.example.com.yaml --- ntp::servers: - time.example.com - 0.pool.ntp.orgThe best way to manage this is to use the roles and profiles method, which allows you to store a smaller amount of more meaningful data in Hiera.
lookup_options
feature.This feature is often referred to as Automatic Parameter Lookup (APL).