Forum: CFEngine Help
Subject: Re: [ANNOUNCE] CFEngine Community 3.4.0beta2 is released
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,27604,27613#msg-27613
Neil, Marco,
The active depends_on is essentially a shortcut for doing things with classes -
internally that's how it is implemented. The reasoning for this change was that
most policies (and this is even more in the Design Center) have instances of
these "flag classes" that are used to indicate whether something has already
been done, so that other promises can depend on it. Making depends_on active
gives us a way to more succinctly express the intention of the policy, i.e.
instead of something like this:
packages::
"apache"
package_policy => "addupdate",
handle => "install_apache",
classes => if_ok("apache_installed");
...
files:
"/etc/apache2.conf"
handle => "configure_apache",
edit_line => configure_apacheconf,
classes => if_ok("apache_configured"),
ifvarclass => "install_apache";
...
commands:
"/etc/init.d/apache2 reload"
handle => "restart_apache",
classes => if_ok("apache_reloaded"),
ifvarclass => "apache_configured";
We can now say:
packages::
"apache"
package_policy => "addupdate",
handle => "install_apache";
...
files:
"/etc/apache2.conf"
handle => "configure_apache",
edit_line => configure_apacheconf,
depends_on => "install_apache";
...
commands:
"/etc/init.d/apache2 reload"
handle => "restart_apache",
depends_on => "configure_apache";
The code is shorter, its intention is clearer, and we don't have to invent so
many unnecessary class names. Of course, you can still explicitly use classes
as a signaling mechanism, this is just a shortcut.
With the growth of the Design Center, having better ways to express intention
and relationships will help us in the long run as the number of components in
use grows.
I don't want to discourage discussion - on the contrary, I'm exposing the
reasons why this change was made in the hopes that we can continue having a
dialog. This change, in fact, came from feedback we received and our own
observations (a lot of people's first impression from "depends_on" is that it
must be active somehow, and were surprised when they learned it wasn't).
Best regards,
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine