I’ve spent a lot of time at work tinkering around with the BCFG2 configuration management system. Here’s a neat stunt you can pull off in your bcfg2 repo to achieve great flexibility when it comes to templating.
First off, all my bundles are defined in SGenshi. Now you can obviously use <ConfigFile> and point to a TGenshi template. But you might run into a problem here: A TGenshi template always has a static owner/group/perms tuple set in the info.xml file (which is bad if you need multiple instances of the template that belong to different users). I tried working around this via an extra <Permissions>, but the default info from <ConfigFile> seems to have a higher priority (see BCFG2 bug #627).
My next shot was to use <BoundConfigFile>, which lets you inline the template in the bundle file. However, this method has a number of problems as it tends to clutter your bundle files and forces you to use XML templating for text files.
So here’s my ingenious solution: Genshi allows the use of XInclude in XML templates, but with a special twist: You can tell Genshi to parse the referenced file as a text template! So here we go:
<BoundConfigFile name="/foo/bar" owner="${owner}" group="${group}" perms="0644"> <xi:include parse="text" href="templates/foo/bar.newtxt" /> </BoundConfigFile>Remember to include the xi namespace reference in your <Bundle>.


