Learning Kit

Puppet Language Basics


Time: 5 minutes
Materials needed: none

As you write Puppet code, you may find yourself repeating the same values again and again. To save time and minimize errors, you can assign those repeating values to variables.

Variables begin with a $ (dollar sign) and the name of the variable, followed by an = (equal sign), and finally the variable’s value. Variable names are case sensitive and must start with a lowercase letter or _ (underscore).


Note that a variable’s value is wrapped in "" (double quotes), as opposed to the '' (single quotes) you’ve seen so far in resource and class declarations.

Any code inside '' (single quotes) will be read by your system literally. Wrapping variable values in "" (double quotes) will tell your system to interpolate that code instead. Puppet agents will see the "" (double quotes) and understand that the string is a variable, and to replace that code with the variable’s value automatically.