Forum: Cfengine Help
Subject: Re: bundlesequence and module protocol
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,21208,21212#msg-21212

elwood Wrote:
-------------------------------------------------------
> Why is commands so far down on the list?  Given the module protocol it would 
> seem that commands is one of the few types that needs to be executed as soon 
> as possible.
...
> The workaround I have to use right now is have my modules emit a special 
> "module_name_has_run" class to use as a guard for anything that uses a 
> variable that is generated by a module.  This works, but yuch.

It might be worth looking into the usemodule function.  Same module protocol, 
but applies in the classes: section.  Bonus points: sets the class specified 
when execution is finished, freeing you from having to set that class with the 
module protocol.  That way you can have commands be later on for things which 
depend on the other stuff, but have your stuff which use the module protocol 
run early.  This might be about the only "have cake and eat it too" thing in 
Cfengine, actually. :)  The only difference is that this one requires the 
modules to be located under $WORKDIR/modules, which isn't a huge deal.  At 
worst, you write a thin wrapper and put it in that directory.

classes:
  program_is_done expression => usemodule("awesomemodule", "args")



The scoping thing can also be addressed using methods if you're not excited 
about having to "and" a zillion classes in a bunch of places.  Just do 
something like

methods:
  dependencyone&dependencytwo::
    "thisstringisirrelevant" usebundle => superduperbundle("$arg", "$otherarg");

and put all the files / commands / whatever promises into superduperbundle.  I 
think I use that for scope consolidation more than any other more legitimate 
purpose.

FWIW, I'm doing roughtly what you are; integrating cfengine into a very large 
existing environment with a lot of (often ill-conceived) legacy junk, slowly 
migrating legacy processes into native Cfengine.  It works fine, but takes some 
doing to wrap your head around it enough to creatively shoehorn everything into 
what's actually a pretty well thought-out system.  And it doesn't require 
learning an otherwise worthless language like Ruby. ;)

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to