Ever wanted to make sure a promise only runs if some other promise has succeeded?
Consider this contrived example with two reports
type promises, It's Friday!
and I love CFEngine Feature Friday.
Per normal ordering1, these two promises will be emitted in the written order.
bundle agent feature_friday
{
reports:
"It's Friday, Friday";
"Gotta get down on Friday";
}
cf-agent --no-lock --bundlesequence feature_friday --file /tmp/feature-friday-7.cf
R: It's Friday!
R: I love CFEngine Feature Friday.
If we want them in the opposite order, we could either change the order or define classes based on the results of the promises. But today’s feature, depends_on
, lets us influence the ordering using a more lightweight method via handle.
bundle agent feature_friday
{
reports:
"It's Friday!"
depends_on => { "first" };
"I love CFEngine Feature Friday."
handle => "first";
}
cf-agent --no-lock --bundlesequence feature_friday --file /tmp/feature-friday-7-1.cf
R: I love CFEngine Feature Friday.
R: It's Friday!
As you can see from the output above, we effectively switched the order of the promises.
The depends_on
attribute requires that the promises with the named handles have been resolved as KEPT or REPAIRED before it’s allowed to actuate.
Happy Friday! 🎉
-
Documentation on CFEngine Normal ordering https://docs.cfengine.com/latest/reference-language-concepts-normal-ordering.html ↩︎