help-cfengine
[Top][All Lists]
Advanced

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

Re: simply, yet elusive import: question


From: Christian Pearce
Subject: Re: simply, yet elusive import: question
Date: Thu, 28 Apr 2005 13:33:57 -0400

Kelly you are prob right, but to answer Nathan's original question, I
would do the following.

Ditch main.cf.  What is the point?  Just make main.cf your cfagent.conf.
Don't add to the confusion of imports.  Next create a second file that
actually does your service restarts.

Here is my example:

bash-2.05b$ tail *
==> cf.config <==
editfiles:

    { /var/tmp/somefile
        AppendIfNoSuchLine "line"
        DefineClasses "RestartService"
    }

==> cf.services <==
shellcommands:

    RestartService::
        '/usr/bin/echo "I am restarting the service"'

==> cfagent.conf <==
control:

    actionsequence = ( editfiles shellcommands )

import:
    cf.config
    cf.services
bash-2.05b$ touch /var/tmp/somefile
bash-2.05b$ /usr/sbin/cfagent  --inform -K   
cfengine:: Saving edit changes to file /var/tmp/somefile
cfengine:: Executing script /usr/bin/echo "I am restarting the
service"...(timeout=0,uid=-1,gid=-1)
cfengine::r/bin/echo "I a: I am restarting the service
cfengine:: Finished script /usr/bin/echo "I am restarting the service"
bash-2.05b$ /usr/sbin/cfagent  --inform -K 
bash-2.05b$

Notice the second time it doesn't output that it is doing something.
(And yes I ignore locks it make it work immediately)

Finally you can see the graph I attached.  Any files that are imported
after cf.config will have cf.config's variables and defined classes.

Oh one thing to note that editfile will not work unless the file exists.
So I touched it ahead of time.

On Thu, 2005-04-28 at 09:21 -0700, Kelly Brown wrote:
> Hi Nathan:
> 
> I'm not sure if this is it but I'll give it a stab.  I think that class 
> will only be defined if "yaddah" actually gets appended to somefile.  If 
> "yaddah" was already in the file I don't think the class will be 
> created.  Is that the problem?
> 
> -K
> 
> nathan r. hruby wrote:
> 
> > Hi,
> >
> > I have what's sure to be a simple question about the way import: works
> > with defined classes, yet, the simple answer eludes me.
> >
> > I have in cfagent.conf:
> >
> >> import:
> >>     any::
> >>         main.cf
> >
> >
> > In main.cf I have:
> >
> >> control:
> >>   actionsequence = ( resolve disks disable processes copy links tidy 
> >> files editfiles shellcommands )
> >>
> >> classes:
> >>     FirstRun        = ( FileExists(/.cfengine-needs-init) )
> >>
> >> import:
> >>         FirstRun.linux::
> >>                 linux.firstrun.cf
> >> shellcommands:
> >>     RestartSomeService::
> >>         "restart command here"
> >
> >
> > In linux.firstrun.cf I have:
> >
> >> editfiles:
> >>     { /somefile
> >>
> >>     AppendIfNoSuchLine "yaddah"
> >>     DefineClasses "RestartSomeService"
> >>     }
> >
> >
> > Now, everything in the linux.firstrun.cf file gets done happily, except,
> > the classes it defines are not seen by the shellcommands: in main.cf, 
> > thus
> > SomeService is never restarted.
> >
> > The docs state that variables and macros created in child imports are not
> > available in the parent files, does this also include Defined Classes?
> >
> > If so, would the logical solution be to move the importation of
> > linux.firstrun.cf into the cfagent.conf file before main.cf?
> >
> > This is cfengine 2.1.12 and 2.1.14.
> >
> > Thanks for any help one could give!
> >
> > -n
> 
> 
> 
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
-- 
Christian Pearce
http://www.sysnav.com
http://www.commnav.com
http://www.perfectorder.com

Attachment: cfagent-conf.png
Description: PNG image

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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