What is the Order of Execution of a Puppet Manifest?

Problem scenario:  When someone uses a .pp file (either through a puppet agent call from a Puppet Agent node or via a puppet apply on a Puppet Master server), what order can a human DevOps Engineer expect the order to be?

Answer:  The execution order of a given manifest is the top of the manifest is executed and Puppet works its way down from there.  ContinualIntegration.com tested and verified this, and Puppet Labs purports this is correct.  However, PuppetLabs does recommend using metaparameters (reserved words that ensure the order of resource declaration fulfillment).  The word "before" and "require" can ensure that a given resource declaration will not happen outside of a desired sequence (before and after another operation respectively).  The syntax for these words is like this:

before => Exec["nameOfExecResourceDeclaration"]  # An operation with this specifier will always happen before nameOfExecResourceDeclaration happens.

require => Exec["nameOfExecResourceDeclaration"]  # This ensures an operation will not happen until nameOfExecResourceDeclaration happens.

Violating the syntax above will cause an error when the Puppet Agent runs such as "could not retrieve catalog from remote server...invalid relationship ... use correct format."

Leave a comment

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