Forum: CFEngine Help
Subject: Re: Edit selected files
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,17747,24267#msg-24267

I also couldn't get file selection rules to work using the "/path/to/*/*.pl" 
files promises.  So what I ended up doing is writing a module using find to 
return all of the matched files I need to edit.  To get around the 4K line 
length limit (yet another arbitrary limit), my module counts the accumulated 
characters in the output, and creates a series of numbered slists (l1, l2, l3, 
etc), each within the allowable line length.  Then it also returns a meta-list 
which contains the names of all the sub-lists.  I have a parametrized bundle 
which takes the name of a sublist, and it's called by iterating over the 
metal-list.  I couldn't figure out how to access the list by name (the 
@($(var)) syntax wasn't real obvious to me at the time, and I'm still not 
positive that it'd work), so I ended up creating a new list by joining and then 
re-splitting, as in:


vars:
  "separator"       string => "<=>";
  "executable_list" slist => splitstring(
    join( "$(separator)", "$(listname)" ),
    "$(separator)",
    "inf"
  );


Which is just the cherry on top of this whole workaround for something that's 
limited because "it's too dangerous" - while recursive directory emptying is 
clearly not too dangerous at all. ;)  This part of my policy takes about 20 
minutes to evaluate over something like 32K files, for the record.  It should 
probably just all be done in a much faster external script with different 
return codes, but I've been stubborn about doing as much native to CFEngine as 
possible...

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

Reply via email to