Open source Puppet documentation

Resource default statements enable you to set default attribute values for a given resource type. Resource declarations within the area of effect that omits those attributes will inherit the default values.

Syntax

Exec {
  path        => '/usr/bin:/bin:/usr/sbin:/sbin',
  environment => 'RUBYLIB=/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0/',
  logoutput   => true,
  timeout     => 180,
}
The general form of resource defaults is:
  • The capitalized resource type name. If the resource type name has a namespace separator (::), every segment must be capitalized, for example Concat::Fragment.

  • An opening curly brace.

  • Any number of attribute and value pairs.

  • A closing curly brace.

You can specify defaults for any resource type in Puppet, including defined types.

Behavior

Within the area of effect, each resource type that omits a given attribute uses that attribute’s default value.

Important: Attributes set explicitly in a resource declaration override any default value.

Resource defaults are evaluation-order independent — that is, a default affects resource declarations written both above and below it.

Puppet uses dynamic scoping for resource defaults, even though it no longer uses dynamic variable lookup. This means that when you use a resource default statement in a class, it could affect any classes or defined types that class declares. Therefore, they should not be set outside of site.pp. You should use per-resource default attributes when possible.

Resource defaults declared in the local scope override any defaults received from parent scopes. Overriding of resource defaults is per attribute, not per block of attributes. This means local and parent resource defaults that don’t conflict with each other are merged together.

Back to top