I do this by creating a directory for each host, and putting a file in each directory named "classes." The classes file - one class per line - is updated using a trigger on a database which identifies all known hosts which match the pattern where the class is to be applied, and regenerating the files for each modified host. While I'm still hoping to replace the physical files with a FUSE implementation which dynamically queries the DB and generates the files on-demand (there are a few other files, including passwd/group/shadow), the current approach has scaled acceptably to tens of thousands of hosts. It feels kind of brute-force, but is also simple to integrate with our external config system.
Anyway, each host pulls down "/config/$(sys.uqhost)" into "$(sys.workdir)/hostcfg". So, the CFEngine policy in
promises.cf simply reads the "/var/cfengine/hostcfg/classes" file into an slist and then defines a class for each element in the list. Some of those classes (those which begin with "servertype_") are then used to define elements in arrays named b[] and i[]. The b and i arrays get passed into getindices() at the end fo
promises.cf, which populates "bundle" and "include" slists, which are themselves then the only value within the bundlesequence and the include parameters in the common control body.
This worked really well up through 3.5.x, so long as everything in
promises.cf was in the right execution order from the top down. However, with 3.6.x, the behavior of
promises.cf has seemingly changed a little. I just noticed today, but it seems that one part of the "read a file, build an slist, define the classes" sequence isn't done until the second pass through
promises.cf, which allows the bundle sequence to be modified later but does not seemingly alter the include list, The end result is that I'm seeing "bundle not defined" issues for bundles defined in included files which are controlled by those file-based classes. I have a couple of ideas on how to work around the new behavior, but haven't actually implemented them yet. Surely something will work. :) Until then, if you were to include "everything" (perhaps with output from lsdir) and only make the bundle sequence dynamic, that'd work fine with the above mechanism.
--Danny