help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: edit and copy


From: Kai Grossjohann
Subject: Re: edit and copy
Date: Fri, 28 May 2004 16:17:53 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Steve Wray <stevew@catalyst.net.nz> writes:

> Ideally, the repository would contain such files (eg /etc/hosts) and 
> these would go into the working copy on the workstation and cfengine 
> would copy these into the live /etc directory (or wherever) modifying 
> them on the way; I don't want the files in the local svn working copy 
> to be modified and I don't want the unaltered files going into the 
> live /etc and then being modified, rather the files should be modified 
> in transit.

There is no cfengine functionality I know of to modify files in
transit.  AFAIK, there is only copying without modification, and then
there is editing without copying.

One possibility would be to introduce another layer of files: First
you update the svn working copy.  Then you copy the file from there to
/etc/hosts.in (say).  Then you edit that file.  Then you copy
/etc/hosts.in to /etc/hosts.

But this means that cfengine does all the work every time.  So you
would have to skip the later steps unless the svn working copy has
changed.

Hm.  Hmmm....  Ah!  Here is another idea: use templates together with
the editfiles directive.  Let's say the svn working copy of the file
is /etc/cfengine/svn/hosts.  Now you create an editfiles directive
which edits the file /etc/hosts.  The edit commands are as follows:

  - Empty the entire file.
  - Insert the contents of /etc/cfengine/svn/hosts.
  - Replace the placeholders with the real values.

If cfengine can detect that the above steps left the file unchanged,
then it won't save the file.  But if it has changed, it will save the
new file.  And you never have the placeholders on disk.

Kai





reply via email to

[Prev in Thread] Current Thread [Next in Thread]