How Do You Control The Order Of When Puppet Manifests Are Applied to a Puppet Agent?

Problem scenario:  One Puppet manifest relies on another manifest to work.  Trying to apply them at the same time is not working.  The "require" and "before" keywords only seem to work for packages, exec, and file resources.  What do you do to order the manifests to satisfy dependency requirements of other manifests?

Solution:  The relationship dependency can be solved by the order in which they are applied.   The keyword "import" has been deprecated and made obsolete in many versions of Puppet.  The keyword "include" in the existing manifests (either one) will not solve the ordering problem.

The solution is to create a third module with its own manifest and call the existing manifests in the desired order from top to bottom with the "include" key word.  We'll call the module "continual" for this example.  Here is its manifest (init.pp):

continual {
   include integration
   include specialty

The above manifest for the "continual" module will apply the "integration" manifest first.  The "integration" manifest is the init.pp file in the manifests directory of the module named "integration."   In the example above "specialty" is a Puppet module that requires "integration" to have been applied.  The "specialty" module will be applied after the "integration" module.

This solution is modular in that the original respective modules can be completely separate and unmodified.  This composite manifest applies the component manifests in the order to solve the dependency problems.

Leave a comment

Your email address will not be published. Required fields are marked *