When a Puppet manifest is loaded, the resources inside the manifest are managed in the order they are declared. But when you need a group of resources to be managed in a different, specific order, you must explicitly declare the relationships. That’s where metaparameters come in.
Metaparameters are special attributes that can be used with any resource type. They specify how your system should act toward the resource, rather than mapping directly to the system state. For this course, we’re going to focus on four common metaparameters that establish relationships between resources: before, require, notify, and subscribe.
This example is a resource declaration for a package resource using the
before metaparameter. The target resource is a file. In this case, the package resource would be applied before the target resource.
This file resource accomplishes the same thing as the previous package resource, but it uses the
require metaparameter instead of before, and points to the same resource that was declared in the previous example. But in this case, the file resource will be applied after the target resource in the require attribute.
The notify metaparameter operates in the same way as the before metaparameter, causing a resource to be applied before the target resource. The target resource, however, will only refresh if the notifying resource changes.
subscribe works just like
require, causing a resource to be applied after the target resource. However, the subscribing resource will only refresh if the target resource changes.
There are many more metaparameters available to use in Puppet. They can add metadata to a resource, set limits on when a resource should be synced, prevent Puppet from making changes, and much more. Check out the Puppet documentation for a full list and details about each.