help-cfengine
[Top][All Lists]
Advanced

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

Re: embedded scripts [was: cfengine ideology question]


From: Brendan Strejcek
Subject: Re: embedded scripts [was: cfengine ideology question]
Date: Thu, 15 Apr 2004 12:55:29 -0500
User-agent: Mutt/1.3.28i

Billy Allan wrote:

> On another note though, I was wondering if it might be useful to be able
> to embed small scripts in an arbitory scripting language
> (shell/perl/python/whatever) in a conf file and have cfengine call the
> interpretor.
> 
> Something like :
> 
> perl = ( /apps/perl )
> sh = ( /bin/sh )
> 
> ...
> 
> scripts:
>         solaris.Hr00.Min0_5::
>               perl {
>                       for ($i = 0; $i < 10; $i++) {
>                               print "hello world\n";
>                       }
>               }
> 
>       patch_server.Hr00.Min0_5::
>               sh {
>                       cd /export/patches/
>                       /apps/wget ftp://some.site.com/8_Recommended.zip
>                       /apps/unzip -q 8_Recommended.zip
>               }

cfengine actually already has this functionality, though it is sort of
a hack. You can use multiline shellcommands. For example:

control:

    actionsequence = ( shellcommands )

    perl_bin = ( ExecResult(/usr/bin/which perl) )

shellcommands:

    "${perl_bin} -e '
        for (${dollar}i = 0; ${dollar}i < 10; ${dollar}i++) {
            print \"hello world\n\";
        }'
    "

This is not taht different that what you wrote above. The only problem
is making sure that cfagent's variable interpolation does not mess up
the final script passed to the interpreter. Hence the ${dollar}.

I actually use little bits like this frequently.




reply via email to

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