help-cfengine
[Top][All Lists]
Advanced

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

Réf. : conditional file copy


From: paguerlais
Subject: Réf. : conditional file copy
Date: Thu, 2 Oct 2003 10:49:44 +0200





I didn't tested the following lines of cfengine code (they indeed look like
constructs I use a lot), only the ideas are meaningful. Please forgive the
syntax errors ;-)

If your file repository is local to your cfengine client, you can do
something like :
<example1>
control:
   exists_file_host        = ( FileExists(file.host))
   exists_file_host::
      file = ( file.host )
   !exists_file_host::
      file = ( file )

copy::
    ${file} dest=somewhere server=localhost ...
</example1>


But if your repository is on another system, you can't test the local
existence of the specific file. You should rather use the SingleCopy option
or play with the mtime of the local file :
<single_copy>
control:
      SingleCopy = on

copy:
      file.host dest=somewhere server=some_server ...
      file          dest=somewhere server=some_server ...
</single_copy>
The copy to 'somewhere' should occur only once. I never tried this option,
but I should ;-)

<play_with_mtime>
copy:
      file.host dest=somewhere server=some_server force=true ...
      file          dest=somewhere server=some_server type=mtime ...
</play_with_mtime>
The copy of file.host to 'somewhere' occurs only if file.host exists (you
get a warning if file.host doesn't exist). This copy is done in force mode,
and then modifies the mtime of 'somewhere'. Then it tries to get 'file',
but only if 'file' is newer than 'somewhere'. Which is false if the
preceeding line has been successful.
There are two potential weaknesses with this solution :
      - if 'file.host' if large (a huge directory for example), you
_always_ perform a large copy :-(
      - if somebody touches 'file' right during the copy of 'file.host',
the second copy will occur :-(
I use a lot this last solution (I started with cfengine 1.5.x and
SingleCopy didn't exist), and never faced such problems. But my
configuration and context are clearly defined, only a few guys modify the
files, and everybody is aware of these weaknesses.

Of course, in both <single_copy> and <play_with_mtime> you can compute the
name of the origin and destination files, and group your systems in classes
to get the right filenames.

HIH
Patrice






Jason Allen <jallen@fnal.gov>@gnu.org le 01/10/2003 20:12:10

Envoyé par :      help-cfengine-bounces+paguerlais=airfrance.fr@gnu.org


Pour : help-cfengine@gnu.org
cc :

Objet :     conditional file copy


Is there anyway to do something like the following with Cfengine?

copy:
any::

if(filexists$(linuxfiles)/passwd.$(host)){
 $(linuxfiles)/passwd.$(host)
}else{
 $(linuxfiles)/passwd
}
dest=/etc/passwd
server=$(cfserver)
mode=644
type=sum

In other words I'd like cfengine to copy passwd.$hostname if it exists
and if not copy passwd.

The problem is that want to manage the same files on large numbers of
dissimilar machine and trying to setup logical groups within cfengine is
proving to be very tedious.

Thanks,

Jason Allen
Fermilab




_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
 http://mail.gnu.org/mailman/listinfo/help-cfengine






reply via email to

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