Reserved words

 

Reserved words cannot be used as:

  • Bare word strings—to use these words as strings, you must enclose them in quotes.
  • Names for custom functions.
  • Names for classes.
  • Names for custom resource types or defined resource types.

In addition, do not:

  • Use the name of any existing resource type or function as the name of a function.
  • Use the name of any existing resource type as the name of a defined type.
  • Use the name of any existing data type (such as integer) as the name of a defined type.

 
Reserved word Description
and Expression operator
application Language keyword
attr Reserved for future use
case Language keyword
component Reserved
consumes Language keyword
default Language keyword
define Language keyword
elsif Language keyword
environment Reserved for symbolic namespace use
false Boolean value
function Language keyword
if Language keyword
import Former language keyword
in Expression operator
inherits Language keyword
node Language keyword
or Expression operator
private Reserved for future use
produces Language keyword
regexp Reserved
site Language keyword
true Boolean value
type Language keyword
undef Special value
unit Reserved
unless Language keyword

Reserved class names

Puppet automatically creates two names that must not be used as class names elsewhere:

  • main: Puppet creates a main class, which contains any resources not contained by any other class.
  • settings: Puppet creates a settings namespace, which contains variables with the settings available to the primary server.

Additionally, the names of data types can't be used as class names:

  • any, Any
  • array, Array
  • binary, Binary
  • boolean, Boolean
  • catalogentry, catalogEntry, CatalogEntry
  • class, Class
  • collection, Collection
  • callable, Callable
  • data, Data
  • default, Default
  • deferred, Deferred
  • enum, Enum
  • float, Float
  • hash, Hash
  • integer, Integer
  • notundef, NotUndef
  • numeric, Numeric
  • optional, Optional
  • pattern, Pattern
  • resource, Resource
  • regexp, Regexp
  • runtime, Runtime
  • scalar, Scalar
  • semver, SemVer
  • semVerRange, SemVerRange
  • sensitive, Sensitive
  • string, String
  • struct, Struct
  • timespan, Timespan
  • timestamp, TImestamp
  • tuple, Tuple
  • type, Type
  • undef, Undef
  • variant, Variant

Reserved variable names

The following variable names are reserved. Unless otherwise noted, you can't assign values to them or use them as parameters in classes or defined types.

 
Reserved variable nameDescription
$0, $1, and every other variable name consisting only of digitsThese are regex capture variables automatically set by regular expression used in conditional statements. Their values do not persist oustide their associated code block or selector value. Assigning these variables causes an error.
Top-scope Puppet built-in variables and facts Built-in variables and facts are reserved at top scope, but you can safely reuse them at node or local scope. See built-in variables and facts for a list of these variables and facts.
$factsReserved for facts and cannot be reassigned at local scopes.
$trustedReserved for facts and cannot be reassigned at local scopes.
$server_factsIf enabled, this variable is reserved for trusted server facts and cannot be reassigned at local scopes.
titleReserved for the title of a class or defined type.
nameReserved for the name of a class or defined type.