help-cfengine
[Top][All Lists]
Advanced

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

cfengine3: run command only if file was changed/copied


From: Yaroslav Halchenko
Subject: cfengine3: run command only if file was changed/copied
Date: Tue, 27 Oct 2009 11:30:13 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

Hi!

Probably being silly, for a new box, instead of using good old cf2 I've
decided to go with cf3 ;-)  Few bug reports have been filed in Debian
BTS, and they might be relevant upstream
1. fixes in manpages
2. I believe that dependency on libpcre should be mandatory

But what I got really stuck with is accomplishing conditional execution
of command upon file copy/editing.  For instance, if I get a new
/etc/apt/sources.list file I want to run apt-get update command.
I don't want to just have a promise with commands including apt-get
since then it would simply run them every time.

in cf2 I had:
copy:
 $(confdir)/sources.list.$(debarch).$(distribution) dest=/etc/apt/sources.list  
mode=444 server=$(etcserver) define=aptgetupdate
shellcommands:
  aptgetupdate::
    "/usr/bin/apt-get update"

what would be logical way for cf3?

Alternative use case is for symlinks:

In cf2 I had:
links:
 /etc/alternatives/editor ->! /usr/bin/vim       define=updatealternativeseditor
shellcommands:
  updatealternativeseditor::
    "/usr/sbin/update-alternatives --set editor /usr/bin/vim"

and since it is somewhat common and per se there are only 2 parameters, it
would be great to have some 'body' or whatever which would allow me simply to
specify parameters ('editor', '/usr/bin/vim') and it would take care about
checking and conditional on necessary change -- running the corresponding
command.  Is that possible with cf3?

Thanks in advance!
-- 
Yaroslav O. Halchenko
Postdoctoral Fellow,   Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        




reply via email to

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