help-cfengine
[Top][All Lists]
Advanced

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

Re: Imports act weird...any good workarounds?


From: Chris Edillon
Subject: Re: Imports act weird...any good workarounds?
Date: Thu, 29 Apr 2004 15:58:16 -0400 (GMT+4)

On Thu, 29 Apr 2004, Paul Krizak wrote:

> I'm working on deploying cfengine for our cluster of around 2800 hosts.  
> One of the problems I've run in to is that the "import:" directive 
> doesn't function as expected.  According to the documentation, imports 
> are processed *after* the main script runs (as oppsed to before, like 
> pretty much all other languages).  I've got a file, cf.classes, that 
> contains information about the global classes (and some global 
> variables) that I'd like to be able to use in other cf.* files.  When I 
> use the import: directive in one of these files, for example:
> 
> import:
>   any::
>     cf.classes
> 
> editfiles:
>   tx::
>      do some TX stuff
> 
>   ca::
>      do some CA stuff
> 
> the "tx" and "ca" classes are defined in the cf.classes file, but have 
> no effect in this file.  Is there any way to force cfagent to apply the 
> settings in import: directives *before* it runs the rest of the script?
> 
> The only workaround I can think of is "running" cf.classes, and defining 
> some environment variable so that cf.classes sets up the global stuff, 
> then *it* imports the cf.* file that I want to run.  This solution is 
> kludgy, though; I'd rather have the cf.* files be more script-ish and 
> use the import: directive as expected.
> 
  i posted something quite a while ago regarding a similar topic.
basically, when you define a class it can be seen by all of the
actions defined in other imported cf.* files of the same "tier",
but not in a parent (like environment variables defined in a
subshell aren't seen by the parent shell process).  so, if you
have a cfagent.conf which does this:

import:
  any::
    cf.classes
    cf.do_cool_stuff

  linux::
    cf.do_linux_things

any classes defined in cf.classes will be valid for any actions
defined in cf.do_cool_stuff and cf.do_linux_things, but not for
any actions defined in your cfagent.conf file itself.  given
that, instead of trying to import your cf.classes file within
each of your other cf.* files, you could import all of your
cf.* files (including cf.classes) in cfagent.conf.  that is,
your cfagent.conf file would simply be a place for your
command: section and an import: secion, and all of the real
work would get done in your cf.* files.  maybe that would be
helpful for your situation.

chris






reply via email to

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