Require vs. Before

When writing a manifest, either Require or Before can be used to set up dependency chains.

Why should you use one vs. the other?

Require is more visually obvious if you can keep all of the related resources near each other in the manifest.

However, Require will set up a hard dependency with what is explicitly defined as the requirement.

If you want your manifest to be portable across multiple OS flavors, it might be better to use an if or case statement to define the OS specific details, and then mention afterwards (in the same stanza) that this value is to be defined before the OS neutral resource.

i.e.  If you specify that a particular configuration file is Required before the service can be started, then that will only work as long as the configuration file name & location are independent of the OS.  (Otherwise, it can never be fulfilled because the file specified won’t exist in the non-planned OS’s package for the service that is being managed.)  On the other hand if you have a series of if statements or a case statement, that specifies (based on the OS) which configuration file needs to be present, then you can easily roll with the file differences as new OS varieties are added to your environment.  Then you just specify at the end of it all that this needs to be defined Before the service (which is universal in name) is started.


Leave a Reply

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