Forum: CFEngine Help Subject: Re: About "new" templates correct usage or limitations Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,26723,26843#msg-26843
> > If you want to have non-CFEngine-managed edits > > (why would you want that?) > > For instance we've got the following problem : Fully agreed, there are cases where you can't have everything under CFEngine control. > - expand_template : > > . why doesn't it empty the file first ? (as > edit_template does). The cost here is a longer run > time starting from the second run. Because expand_template (and expand_scalars) is meant to be a generic file-editing mechanism, not a complete templating solution. > . it misses the [% CFEngine class:: %] tags, the > consequence being you've got to define all the > to-be-expanded variables in all the classes in > your .cf file, even in the classes where you don't > want some of these variables defined Mike Svoboda posted an example of how they do fairly complex whole-file templating (for sysctl.conf, in his example): https://cfengine.com/forum/read.php?3,24105,24120, including parameters that may or may not be defined on some systems. Maybe something like this would also work (maybe not in the /etc/passwd example, but in others). > . with insert_lines, non-existing inserted lines > are append at the end You can control this with location: https://cfengine.com/manuals/cf3-Reference#location-in-insert_005flines or select_region, although it depends a lot on the file. > . indentation not controlled by you Yes, but indentation should not matter too much for functionality, except for human-readability, but if the file is being maintained by CFEngine, that might not be much of a concern. > . harder to code than a template, especially if > you insert lines into a section (think Host > section in ssh config file) Which reminds me - I've been meaning to add Host/User section support to that bundle for some time... :) Best regards, _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine