help-cfengine
[Top][All Lists]
Advanced

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

Re: Confusion with Variables and Groups


From: Brendan Strejcek
Subject: Re: Confusion with Variables and Groups
Date: Fri, 9 Jul 2004 13:07:14 -0500
User-agent: Mutt/1.3.28i

This works fine for me:

    $ cat test.cf 
    #!/usr/sbin/cfagent -qKf
    
    classes:
        testClass = ( linux )
    control:
        actionsequence = ( shellcommands )
        testClass:: testVar = ( junk )
    shellcommands:
        "/bin/echo testVar is ${testVar}"
    $ ./test.cf 
    cfengine::/bin/echo testV: testVar is junk
    $ 

I think that's a simple case of what you want.

Erik Williamson wrote:

> Hi All,
> 
> I've got two classes defined: Com1ConsoleServers & Com2ConsoleServers, 
> with ConsoleServers being an amalgamation of the two.
> 
> In my editfiles section, I currently have a section for each, even 
> though there's very few differences between the two.  I'd like to tidy 
> this up;  Is there a way to define variables based on which of the above 
> classes a machine is in?  This way, instead of this:
> 
> editfiles:
>   Com1ConsoleServers::
>     <do stuff>
> 
>   Com2ConsoleServers::
>     <do remarkably similar stuff>
> 
> I could do this:
> 
> editfiles:
>   Com1ConsoleServers::
>     <do stuff with $(ComPort) >
>     <do more stuff with $(ComPort) >
> 
> So, as a test case, I tried this (only the important stuff shown):
> control:
>   TestClassTest::
>     BigTestVariable = ( "Wooooo" )
> 
> groups:
>    TestClassTest = ( testhost )
> 
> shellcommands:
>   TestClassTest::
>     "/bin/echo $(BigTestVariable)"
> 
> I didn't expect this to work, and it didn't (got a ) - alas, is there a 
> way to accomplish this?
> 
> Thanks!
> Erik.
> 
> -- 
> e r i k   w i l l i a m s o n                     erik@cpsc.ucalgary.ca
>  system admin . department of computer science . university of calgary
> 
> 
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-cfengine
> 




reply via email to

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