help-cfengine
[Top][All Lists]
Advanced

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

Re: files create and fix action question


From: Ed Brown
Subject: Re: files create and fix action question
Date: Fri, 04 Nov 2005 14:35:02 -0700

I raised this question last year, and it didn't seem there was a simple
solution, short of two files actions, and setting ifelapsed to 0, though
one person had a somewhat more complex workaround.  Here is that
conversation:
-Ed
--------------------------------------------------------------
                          Subject: 
Re: files actions
                             Date: 
Tue, 28 Sep 2004 16:04:47 -0600

Thanks Chip, 

I had tried and given up on that earlier, because the second files
action on the same file only got deferred during my test:

Checking file(s) in /var/tmp/foo
Checking file(s) in /var/tmp/foo
cfengine:: Nothing scheduled for files._var_tmp_foo_644_7133__1 (0/1
minutes elapsed)

But it finally occurred to me (after giving it some more thought on
account of your suggestion) that IfElapsed was not getting set to zero
for the test script.  It's working now - thanks!

-Ed



On Tue, 2004-09-28 at 15:46, Chip Seraphine wrote:
> On Tuesday 28 September 2004 15:51, Ed Brown wrote:
> > Hmmm, so NO easy answer I take it....
> 
> In situations like the one you describe below, I generally have two 
> near-identical files: clauses, each with a different action (one for
'fixall' 
> and one for 'create').  Obviously, put the 'create' first or you might
get an 
> extra error the first time it runs.
> 
> 
> 
> > 
> > If you care enough to create a file, with particular permissions, if
it
> > doesn't exist, why wouldn't also want to verify the permissions on
the
> > existing file, or continue to verify, as the case may be?   Seems
like
> > an odd omission, one that I was surprised to find that neither
'fixall'
> > or 'create' encompasses.   Touching a file every time cfengine runs
is
> > clearly not the right solution.
> > 
> > Any chance of addressing this in the future?
> > 
> > thanks,
> > Ed
> > 
> > 
> > On Tue, 2004-09-28 at 11:18, Ed Brown wrote:
> > > There's probably an easy answer, but at the moment it is eluding
me: how
> > > can a file be both created if missing, and have its
modes/ownership
> > > verified?  action=create does one, action=fixall does the other,
> > > action=touch gets close, but I don't want the file to be touched
> > > (timestamp updated) every time cfagent runs.
> > > 
> > > thanks,
> > > Ed
--------------------------------------------------------------
(And the other solution):
--------------------------------------------------------------
                             From: 
David E. Nelson
<david.nelson@ni.com>
                          Subject: 
Re: files actions
                             Date: 
Tue, 28 Sep 2004 19:41:31 -0500
(CDT)

Hi Ed,

You are correct!  Sorry 'bout that. ;)

         /\/elson

On Tue, 28 Sep 2004, Ed Brown wrote:

> Thanks for the suggestion, looks like it would work too (though I'm
> guessing there's a little typo in the second part ('!SystemExists'
> should be 'SystemExists::' ?))
> -Ed
>
> On Tue, 2004-09-28 at 16:12, David E. Nelson wrote:
>> Hi Ed,
>>
>> Just thought of something. How about:
>>
>> groups:
>>
>>    SystemExists = ( FileExists(/etc/system) )
>>
>> control:
>>
>>    actionsequence = ( files )
>>
>> files:
>>
>>    !SystemExists::
>>
>>      /etc/system
>>        owner=root
>>        group=other
>>        mode=0644
>>        action=touch
>>
>>    !SystemExists
>>      /etc/system
>>        owner=root
>>        group=other
>>        mode=644
>>        action=fixplain
>>
>> Regards,
>>       /\/elson
--------------------------------------------------------------



On Fri, 2005-11-04 at 13:20, Mark Burgess wrote:
> Are you sure that action=create alone doesn't do what you want?
> 
> M
> 
> On Fri, 2005-11-04 at 11:23 -0600, Frank Smith wrote:
> > I'm trying to make a files action that will create a file if it
> > doesn't exist or will fix ownership if it does exist but is wrong.
> > 
> > action=create can do the first
> > action=fixplain can do the second
> > 
> > However, if I use both a create and fixplain action, only the first
> > one in the config actually does anything, cfengine's file locking
> > prevents the second one from running.  So if the create action is
> > first, it will create it if not there but will not fix it if it is.
> > Conversely, if the fixplain is first it will fix ownerships if it is
> > wrong, but it will never create the file if it isn't there (the fix
> > action sets a lock even if the file to fix doesn't exist, so a create
> > won't happen because the non-existant file is locked).
> > 
> > action=touch will do what I want, except that it changes the timestamp
> > of the file on every run whether it changes anything or not (which is
> > what I would expect a touch to do, but not what I want)
> > 
> > Is there some option I've missed that could achieve both a create and
> > a fix and do whichever one is needed?
> > 
> > Thanks,
> > Frank






reply via email to

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