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: Tim Nelson
Subject: Re: simply, yet elusive import: question
Date: Fri, 29 Apr 2005 09:57:47 +1000 (EST)

On Thu, 28 Apr 2005, 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?

I would've thought that putting the shellcommands in x.cf and then importing x.cf after linux.firstrun.cf would solve it.

        To quote the reference manual:
"Note that, if you define variables in an imported file they will not be defined for operations in their parent files. This because cfengine reads in all the import files after the main file has been parsed\u2014not at the place where you call import in your script. This means that variables or macros defined in imported files are only defined after the main program. Variables from earlier files are inherited by later includes, but not vice-versa."

        :)

--
Tim Nelson
Server Administrator
WebAlive Technologies Global
Level 1 Innovation Building, Digital Harbour
1010 LaTrobe Street
Docklands, Melbourne, Vic, 3008
Phone: +61 3 9934 0812
Fax: +61 3 9934 0899
E-mail: tim.nelson@webalive.biz
http://www.webalive.biz/

"Your Business, Your Web, Your Control"




reply via email to

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