- [Instructor] You might be familiar with the term class as it's used in programming. In Puppet, a class is a much simpler concept. It's really just a way of including a set of resources by name. Take a look at this example class. Maybe there's a developer named Grace who wants to make sure that she always has root access, and that her favorite editor is installed along with its config file. There's some new syntax here for the resources, but don't worry about that at the moment. This is what we call a class definition, and it's just a wrapper of some resource declarations.
Declaring a specific class on a node or a set of models is called classification. In this example, by adding the dev_environment class to the default node group, we could say that all nodes that don't fit into another group are classified with dev_environment. When Puppet runs on any of those nodes, the resources defined in this class will be managed. Another way of declaring classes is with the include keyword. Include lets you declare the same class more than once.
In this case, the machine grace.puppet.vm would get the classification from the node definition specific to that node and not from the default. A node only matches a single node definition. Classes can also be declared within other classes alongside resources. This is a very common pattern, and it's where a lot of the power of Puppet is. Puppet lets you define logical units of configuration and then compose them as higher-level abstractions.
- What is Puppet?
- Setting up a Puppet master and control repo
- Using the built-in resource types
- Organizing code with roles and profiles
- Managing more nodes
- Triggering actions (orchestration)
- Gathering system info with facter
- Writing modules
- Using templates