Puppet’s default value acts like a keyword in a few specific usages. Less commonly, it can also be used as a value.


The only value in the default data type is the bare word default.

Usage with cases and selectors

In case statements and selector expressions, you can use default as a case. Puppet attempts to match a default case last, after it has tried to match against every other case.

Usage with per-block resource defaults

You can use default as the title in a resource declaration to invoke a particular behavior. Instead of creating a resource and adding it to the catalog, the default resource sets fallback attributes that can be used by any other resource in the same resource expression.

In the following example, all of the resources in the block inherits attributes from default unless they specifically override them:
file {
    ensure => file,
    mode   => '0600',
    owner  => 'root',
    group  => 'root',
    mode => '0644',
    mode => '0644',

Usage as parameters of data types

Several data types take parameters that have default values. In some cases, like minimum and maximum sizes, the default value can be difficult or impossible to refer to using the available literal values in the Puppet language. For example, the default value of the String type’s maximum length parameter is infinity, which can’t be represented in the Puppet language.

These parameters let you provide a value of default to indicate that you want the default value.

Other default usage

You can use the value default anywhere you aren’t prohibited from using it. In these cases, it generally won’t have any special meaning.

There are a few reasons you might want to do this. A prime example is if you are writing a class or defined resource type and want to give users the option to specifically request a parameter’s default value. Some people have used undef to do this, but that’s no good when dealing with parameters where undef would, itself, be a meaningful value. Others have used a value like the string "UNSET", but this can be messy.

Using default in this scenario lets you distinguish among:
  • A chosen “real” value.

  • A chosen value of undef .

  • Explicitly declining to choose a value, represented by default .

In other other words, default can be useful when you need a truly meaningless value.

The Default data type

The data type of default is Default. It matches only the value default, and takes no parameters.

Variant[String, Default, Undef]
Matches undef, default, or any string.