Learning Kit

Puppet Language Basics


Time: 5 minutes
Materials needed: none

Resources can be collected, combined, and distributed together using classes. By combining resources into a class, a class can configure large blocks of functionality, containing all of the packages, configuration files, and services needed to run an application.
A single manifest should contain only one class definition each. A single class can be used across multiple nodes, but each class name you use must be unique and, once declared, a class cannot be declared again on the same node.

Classes begin with the class keyword, followed by the name of the class. Then, you’ll write all of the classes’ resources within {} (curly braces). Each resource inside a class follows normal resource declaration syntax.

This example class definition contains package, file, and service resources. When this class is distributed to a node, the node will receive all of these configurations together at once.

Defining a class specifies the contents and behaviors of that class, but it doesn’t automatically add the class to your configuration. To do that, the class must be declared. Declaring a class adds each resource to the catalog and directs Puppet to begin managing those resources.


There are two ways to declare a class in a manifest: by using the include keyword followed by the name of the class, or by using the class keyword followed by the name of the class in '' (single quotes), followed by a : (colon), and enclosed in {} (curly braces).