Booleans are one-bit values, representing true or false. The condition of an if statement expects an expression that resolves to a boolean value. All of Puppet's comparison operators resolve to boolean values, as do many functions.

The boolean data type has two possible values: true and false. Literal booleans must be one of these two bare words (that is, not in quotation marks).

Automatic conversion to boolean

If a non-boolean value is used where a boolean is required:
  • The undef value is converted to boolean false.

  • All other values are converted to boolean true.

Notably, this means the string values "" (a zero-length string) and "false" (in quotation marks) both resolve to true.

To convert values to booleans with more permissive rules (for example, 0 to false, or "false" to false), use the str2bool and num2bool functions in the puppetlabs-stdlib module.

The Boolean data type

The data type of boolean values is Boolean.

It matches only the values true or false, and accepts no parameters.

You can use abstract types to match values that might be boolean or might have some other value. For example, Optional[Boolean] matches true, false, or undef. Variant[Boolean, Enum["true", "false"]] matches stringified booleans as well as true booleans.