I have found that using the InsertFile works well for medium size files
that need a host specific section, but where the majority of the file is
the same on every host. I even have one config file which is split into
three sections. The first section is a choice of two files (server or
workstation, in this case) depending on class, the second section is
host specific, and picks up host specific variables from a config file,
and the third section is common to all hosts.
Works really well, so far anyway!
Changes to the insert file are pushed out by having a version number
appended as the first line, and used by a StartGroup loop with a
EmptyEntireFilePlease as the first line in the loop.
Regards,
Marco
Ed Brown wrote:
One more approach, that doesn't require any file copying or tempfile
storage, is to build the file entirely with cfengine, like this yum.conf
example, where 3 variables are set depending on network segment, server
class, and whether it's a 'new build' or not:
{ /etc/yum.conf
EmptyEntireFilePlease
AppendIfNoSuchLine "[main]"
AppendIfNoSuchLine "cachedir=/var/cache/yum"
AppendIfNoSuchLine "pkgpolicy=newest"
AppendIfNoSuchLine "tolerant=1"
AppendIfNoSuchLine "exactarch=1"
AppendIfNoSuchLine "retries=3"
AppendIfNoSuchLine "exclude=${YumExcludes}"
AppendIfNoSuchLine "${LogString}"
AppendIfNoSuchLine "[base]"
AppendIfNoSuchLine "name=${packageserver} common rpm
repository"
AppendIfNoSuchLine "baseurl=ftp://${packageserver}"
AutoCreate
}
As with some of the other examples, cfengine doesn't actually rewrite
the file unless it's necessary. This is well-suited for short files,
would be a little bit of a pain to generate long files this way.
-Ed
_______________________________________________
Help-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-cfengine
_______________________________________________
Help-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-cfengine