Actually, templates should be on topic here. However, I was not referring to the configuration files themselves. I use m4 on my cfengine scripts, because if I repeat a section with minor changes, it belongs in a macro. Reduces typing, typos, improves legibility, etc.
Now, that being said, I do take advantage of m4 to fill in some of the data going into a configuration file at the same time I'm using m4 to macro a cfengine editfiles section. m4 allows me to perform more sophisticated text substitution than just $(host). I've got some examples that use a long magic one-liner inside esyscmd() to create a chunk of text. See the EditFiles Examples on cfwiki. I've got each (block edit, full file replacement edit) setup in a macro, which I've been meaning to post to cfwiki. Russell On Tue, Oct 25, 2005 at 12:15:13PM -0700, Brian C. Hill wrote: > I tend to agree. Cannonical edit directives are concise and > clean (pretty, even?), but they will only take you so far. I mark up > all of my config files (resolv.conf, ntp.conf, automount configs, > /etc/system, syslog.conf, etc.) with m4. xml might be a better choice > in the long run, but m4 has worked well for me across a large number of > systems with different subnets, domains, roles, timezones, etc.. > > I am using cfe to replace rdist now, making heavy use of > copy:/shellcommands:. I am considering using some of the cfe mount and > resolver functionality to replace what I am doing (which will obsolete > the m4 files for those), but that's just a couple of pieces. > > Is anyone else using a markup language to 'templatize' their > config files? This is slightly off-topic - probably better to reply to > me directly. > > Brian > ====================================================================== > On Tue, Oct 25, 2005 at 11:03:59AM -0500, Adams, Russell L. wrote: > > Thats what m4 is for. > > > > Russell > > > > On Tue, Oct 25, 2005 at 10:03:32AM -0400, David Scott Coburn wrote: > > > > > > In many of my cfagent script I have constructs like this: > > > > > > editfiles: > > > > > > { /etc/postfix/main.cf > > > BeginGroupIfNoSuchLine "mydestination = $(host), $(fqhost), > > > localhost" > > > DeleteLinesMatching "^mydestination.*" > > > Append "mydestination = $(host), $(fqhost), localhost" > > > EndGroup > > > BeginGroupIfNoSuchLine "mydomain = $(domain)" > > > DeleteLinesMatching "^mydomain.*" > > > Append "mydomain = $(domain)" > > > EndGroup > > > DefineClasses "restart_postfix" > > > } > > > > > > The bit that bugs me the most about this construct is the repetition > > > of the text I am searching for and the text to replace it with. > > > > > > What would be nifty would be something like this: > > > > > > editfiles: > > > > > > { /etc/postfix/main.cf > > > UncommentAndSetValue "mydestination =" "$(host), $(fqhost), > > > localhost" > > > UncommentAndSetValue "mydomain =" "$(domain)" > > > DefineClasses "restart_postfix" > > > } > > > > > > The first argument would be the variable that get its value changed, > > > and the second argument would be what it gets set to. > > > > > > If the value was already set then nothing would happen. If a variable was > > > changed then the DefineClass would happen. If the variable was commented > > > out > > > then it would be uncommented and set to the given value. > > > > > > It seems like this kind of setting of variables in config files to some > > > value is half of what I use cfengine for and this would be a whole lot > > > easier to set up and then maintain. > > > > > > Perhaps there is already a better way to do it that I have not found in > > > the manual yet? > > > > > > Thanks, > > > > > > Scott > > > > > > -- > > > * David Scott Coburn > > > * Brookhaven National Laboratory > > > * [EMAIL PROTECTED] 631.344.7110 > > > * "Assume a spherical cow of uniform density..." > > > _______________________________________________ > > > Help-cfengine mailing list > > > Help-cfengine@gnu.org > > > http://lists.gnu.org/mailman/listinfo/help-cfengine > > > > > > _______________________________________________ > > Help-cfengine mailing list > > Help-cfengine@gnu.org > > http://lists.gnu.org/mailman/listinfo/help-cfengine > > -- > _____________________________________________________________________ > / Brian C. Hill [EMAIL PROTECTED] http://brian.bch.net \ > | UNIX Specialist BCH Technical Services http://www.bch.net | > > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@gnu.org > http://lists.gnu.org/mailman/listinfo/help-cfengine _______________________________________________ Help-cfengine mailing list Help-cfengine@gnu.org http://lists.gnu.org/mailman/listinfo/help-cfengine