On Thu, Jun 23, 2011 at 5:41 PM, Daniel V. Klein <d...@lonewolf.com> wrote: > > ifvarclass() says "if the named class exists, do something" > > fileexists() says "if the named file exists, make the class expression > 'true'" and that is used to create a named class. > > The two are incompatible (because the latter is only used in class promises). > Your example isn't clear, as it appears to use the target as both a > directory and a file. What you probably want to do is use a transformer > attribute. But maybe not :-) > > -Dan
Dear Dan, Thank you for your reply. My case is (I hope this is a clear example): I want my system to have a certain PHP package (let's say "Fileinfo"). I want Cfengine to install this package for me only if it does not already exist. (I can tell if it is installed by checking for /usr/lib64/php/modules/fileinfo.so or by checking the exit status of "pear list fileinfo".) I already check if /usr/lib64/php/modules/fileinfo.so exists, and if it does, I add "extension=fileinfo.so" to /etc/php.ini and reload the httpd. I just don't like not being able to use the result of that check directly to control installation of the package. (I have to set an inverse class.) I tried using the transformer attribute as you kindly suggested, but it runs the command whether the file exists or not: {{{ bundle agent example { files: "/usr/lib64/php/modules/fileinfo.so" create => "true", transformer => "/usr/bin/pecl install fileinfo"; } }}} Mark describes Cfengine 3 as a low-level, flexible and powerful language. Adding an "ifnotvarclass" promise attribute (adding the ability to AND NOT dynamically interpolated variable classes with static classes) would increase the flexibility and power of the Cfengine language. Just thinking out loud, if we had an "iffunc" attribute, we could use that to AND it with the statically set classes; and ifnotfunc, would AND NOT it with the static classes, for example: commands: "/usr/bin/pecl install fileinfo" ifnotfunc => fileexists("/usr/lib64/php/modules/fileinfo.so"); That would only run the command if the fileexists function returns false. Very concise and powerful expression of the sysadmin's intention, all in a single promise. Sincerely, Aleksey _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine