Classes
We've come across the class concept a few times so far in this book, without really explaining it. Let's explore a little further now and see how to use this key Puppet language building block.
The class keyword
You may have noticed that in the code for our example NTP module in Chapter 7, Mastering modules (in the Writing the module code section), we used the class
keyword:
class pbg_ntp { ... }
If you're wondering what the class
keyword does, the surprising answer is nothing at all. Nothing, that is, except inform Puppet that the resources it contains should be grouped together and given a name (pbg_ntp
), and that these resources should not be applied yet.
You can then use this name elsewhere to tell Puppet to apply all the resources in the class together. We declared our example module by using the include
keyword:
include ntp
The following example shows a class definition, which makes the class available to Puppet, but does not (yet) apply any of its contained resources...