On 24/02/2012 16:35, Aleksey Tsalolikhin wrote:
> EXECUTIVE SUMMARY:  What's needed is the ability to dynamically
> construct the inputs list and the bundlesequence list.  Is this possible
> in CFEngine 3?   If so, could you please demonstrate how to do it?
> If not, could it be made possible, please?

Yes it is possible, however there are some pitfall you must avoid.
For instance, as stated by Neil, the normal ordering will play against 
you for vars are defined before classes; and you need to define all your 
variables as redefinable if you wish to use a "any" first, and there 
override

Example here :

body common control {
  bundlesequence => { "test", "@(g.bundle)"};
  inputs => { "@(inputs.list)" };
}

bundle agent test {
  reports:
    cfengine::
      "This is a test";
}

bundle common g {
   vars:
     "myvar" string => "foo";
    linux::
     "bundle" slist => {"one", "two" } ;
   classes:
     "myclass" expression => "ubuntu";
}

bundle common inputs {
  vars:
   any::
      "list" slist => { "file.cf" },
         policy => "free";
    myclass::
      "list" slist => { "custom.cf" },
         policy => "free";
}

bundle agent two {
  reports:
    cfengine::
      "This is two";
}

(I use CFEngine 3.2.3)

If I miss a policy => "free", then the list is not properly overriden.
I also defined the needed class to set the inputlist in a bundle common 
put *before* the bundle common defining the input list

> Getting this working is the last thing that stands between upgrading
> this site from CFEngine 2 to CFEngine 3 (or possibly losing them to
> Chef).
>
> DETAILED VERSION:
>
> On Thu, Feb 23, 2012 at 10:45 PM, Diego Zamboni<di...@zzamboni.org>  wrote:
>>   you could use the second method described by Neil (and which I very much
>> prefer) of having a fixed bundlesequence, and use methods: to call the 
>> different
>> bundles.
> Dear Diego,
>
> This site has been using CFEngine 2 for 5 years and they have a very
> large policy set.  We're talking thousands or more of little inputs files.
> They do EVERYTHING in CFEngine.  Their system architect teaches all
> their sysadmins, "It's not done until you do it in CFEngine."  Their total
> policy set size is measured in gigabytes.
>
> They have class expressions that are wider than a line width on a 22
> inch monitor.  Lots of soft classes.
>
> Using methods: type processes to choose from a menu of bundlesequence
> lists doesn't work for them due to the large number of combinations possible.
> Each bundle should be tested as to whether it should be run or not.
>
> Moreover, limiting inputs to just the files containing the bundles
> needed would speed up the CFEngine run.  (Loading the entire policy
> set in memory is impractical as it measures in gigabytes.)
>
> What's needed is the ability to dynamically construct the
> inputs list and the bundlesequence list.
We've been working on a CFEngine 2 -> CFEngine 3 (well Rudder actually) 
transition, and it appears that CFEngine 2 policies are much more 
verbose than in CFEngine 3
The codebase was literally divided, and most of the time spent in the 
transition was to actually figure out what was done, and how to refactor 
it to have tighter and grouped together promises (the new codebase is 
much smaller, more readable, and fells more deterministic)

And they also managed everything with CFEngine 2.
I really believe you should consider a mix of dynamic bundlesequence, 
methods, and ease the dynamic input list; maybe some site separation, or 
some higher level separation ?

>
> Here is what their systems architect wrote:
>> Here is my dilemma:
>>
>> * In promises.cf I will have classes get defined.
>> * Based on those classes I will add additional inputs.
>> * Each inputs file will have a separate bundle
>> * I need to have a dynamic bundle list that will call the main bundle in 
>> each input file.
>> * I have no way of enumerating every possible combination.
>>
>> Examples:
>>
>> 1. global ->  main ->  linux ->  debian ->  apache ->  www
>> 2. global ->  main ->  xen ->  linux ->  debian ->  dom0
>> 3. global ->  main ->  linux ->  debian ->  domU ->  apache ->  www
>>
>> My end result is that I have no way of knowing what bundlesequence I need 
>> until all of the classes and inputs have been compiled, especially since 
>> some classes will be determined by examining the system. That is, some hard 
>> classes will trigger additional inputs, regardless of whatever else is going 
>> on.
>>
>> This is close:
>> http://watson-wilson.ca/2011/09/dynamic-bundlesequence-in-cfengine.html
>>
>> But when I try to redefine @{bseq} on 3.2.1 it tells me that it's an 
>> unkeepable promise.
I tried on 3.2.3, and it works fine
Maybe an issue with the 3.2.1 ?

>> ----
>>
>> Other notes:
>>
>> Perhaps use an array? Then I can push the bundle onto the array. Right 
>> before declaring the bundlesequence push the indices into a list and 
>> bundlesequence that list.
>>
>> Use [Aleksey's practical example from 
>> http://www.verticalsysadmin.com/cfengine/practical_examples.tar] 0620 as a 
>> guide?
>

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

Reply via email to