Hi Nicolas,

I tried your example and this is what happened:

- the nagios directory is created (which should lead to creating the class 
'not_nagios_installed')
- the extraction of the tarball does not happen at all

Having a look at the output of the agent there's no evidence that anything 
is happening concerning Nagios installation at all. Having a look at the 
output of cf-execd this is what happens:

  10349 * Begin new promise type category files in function
  10350
  10351 Subtype files syntax ok for agent
  10352 Promising object name '/usr/local/nagios/.'
  10353 Recorded LVAL create
  10354 Recorded scalarRVAL true
  10355 Recorded LVAL comment
  10356 Recorded scalarRVAL Creating nagios directory
  10357 Recorded LVAL classes
  10358 Found function identifier if_repaired
  10359 Start FnCall if_repaired args level 1
  10360 Appending scalar to rval-list [not_nagios_installed]
  10361 CopyRvalItem(s)
  10362 End args level 1
  10363 Installing Function Call if_repaired
  10364 Installed if_repaired(not_nagios_installed,)
  10365
  10366 Finished with function call, now at level 0
  10367
  10368 End full promise with promisee /usr/local/nagios/.
  10369
  10370
  10371 * Begin new promise type category commands in function
  10372
  10373 Subtype commands syntax ok for agent
  10374   New class context 'not_nagios_installed' ::
  10375
  10376 Promising object name '/bin/tar xzvf 
/var/cfengine/artifacts/nagios/nagios.tar.gz -C /'
  10377 Recorded LVAL comment
  10378 Recorded scalarRVAL Going to install Nagios now.
  10379 End full promise with promisee /bin/tar xzvf 
/var/cfengine/artifacts/nagios/nagios.tar.gz -C /
  10380
  10381 End promise bundle

I'm not quiet sure how to interpret this. Obviously the promise for 'tar' 
is made, but it's not executed.

Bernd







From:
Nicolas Charles <charl...@gmail.com>
To:
bernd.adamow...@external.icw-global.com
Cc:
help-cfengine@cfengine.org
Date:
17.12.2009 13:02
Subject:
Re: Problem recognizing existence of directory



Hi,

Maybe you could use something like this :

bundle agent check_nagios_installation {
    files:
        "${nagios_install_dir}/"
        create => "true",
        comment => "Creating nagios directory",
        classes => if_repaired("not_nagios_installed");
   commands:
      not_nagios_installed::
            "/bin/tar xzvf /var/cfengine/artifacts/nagios/nagios.tar.gz 
-C /",
                comment => "Going to install Nagios now.";
}
body classes if_repaired(class)
{
promise_repaired => { "$(class)" };
}




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
> 






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

Reply via email to