Regarding your original case, it would be more natural to use isdir()
rather than fileexists() (though both should work). I can't replicate
any problems with either isdir() or fileexists() though. I also tried
interpolating a variable into the path checked for, because that seems
like a likely place that an order bug could creep in, but that did not
give me any problems either.

$ cat .cfagent/inputs/promises.cf
body common control { bundlesequence  => { 'example' }; }
bundle agent example {
classes:
    any::
        'asdf' expression => isdir('/tmp/asdf');
commands:
    !asdf::
        '/bin/echo some command';
}
$ file /tmp/asdf
/tmp/asdf: directory
$ /usr/sbin/cf-agent -K
$ rmdir /tmp/asdf
$ /usr/sbin/cf-agent -K
Q: ".../bin/echo some ": some command
I: Last 1 QUOTEed lines were generated by promiser "/bin/echo some command"
I: Made in version 'not specified' of
'/home/brendan/.cfagent/inputs/promises.cf' near line 8
$

On Thu, Dec 17, 2009 at 6:54 AM,
<bernd.adamow...@external.icw-global.com> wrote:
>
> I guess I'm facing a typical beginners problem, however, I didn't find a
> solution.
>
> I'm checking the existence of a directory. If it's not there, I'm going to
> extract a tarball which creates it and some other files. This works very
> fine. However the extracting of the tarball is done sometimes too, even if
> the directory exists. I couldn't find a deterministic behaviour. Here's the
> code I'm using:
>
> bundle agent check_nagios_installation {
>
>     classes:
>         "nagios_installed" expression =>
> fileexists("${nagios_install_dir}/.");
>
>     commands:
>         !nagios_installed::
>             "/bin/tar xzvf /var/cfengine/artifacts/nagios/nagios.tar.gz -C
> /",
>                 comment => "Going to install Nagios now.";
> }
>
> Thanks in advance!
>
> Bernd
> InterComponentWare AG:
> Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich
> Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 /
> USt.-IdNr.: DE 198388516
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
>
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to