For each resource under management, the catalog describes its desired state and can specify ordered dependency information. Puppet automatically resolves some ordering for you, but you should enforce ordering to avoid containment issues. Containment controls the order that your Puppet code is executed in.
Version and installation information
Puppet version: 5.0, 6.0 Installation type: All
Solution
Puppet normally applies resources in the order that they are declared within a manifest.
Puppet can also establish automatic relationships between certain resources when it applies a catalog. For example, if you declare that a file is owned by a user and later in the same manifest declare that user, an automatic relationship is created, and the code is executed in the correct order.
If Puppet fails to apply the prior resource in a relationship, it skips the subsequent resource and log the following messages:
notice: <RESOURCE>: Dependency <OTHER RESOURCE> has failures: true warning: <RESOURCE>: Skipping because of failed dependencies
It then continues to apply any unrelated resources. Any resources that depend on the skipped resource are also skipped. This helps prevent an inconsistent system state, rather than attempting to apply a resource that might have broken prerequisites.
A required class is in the catalog before the class using the required function, but included and required classes don’t happen in a specific order. By using metaparameters and chaining arrows, you can ensure that your classes execute in order.
The preferred way to enforce ordering and relationships among resources in one or more manifests with the before
, require
, subscribe
, and notify
metaparameters. These metaparameters parameters are available on all resource types. You can also control resource ordering using chaining arrows.
Comments
0 comments
Please sign in to leave a comment.