While I disagree with Mark about usefulness of exit status (at least of exit status 0 in this case), in case of packages, it's pretty easy to check some vital file for existence as I stated already. I use such a method to detect availability of a package, and it never harmed me. Moreover, I use it like follows:
classes: "ntpd_installed" expression => fileexists("/usr/sbin/ntpd"); packages !ntpd_installed:: "ntpd" package_method => yum, package_policy => "add"; This approach saves me from wasting CPU and time for unnecessary package manager invocation when a package is already installed. 2010/9/17 Mark Burgess <mark.burg...@iu.hio.no>: > > > On 09/17/2010 11:09 AM, Davide Brini wrote: >> On Friday 17 Sep 2010 09:59:10 Seva Gluschenko wrote: >> >>> Davide, >>> >>> as far as I'm known, Cfengine does not analyze package manager exit >>> status. You might check certain file from a package for existence or >>> ask Mark to add exit status recognition :) >> >> Well that makes it pretty useless doesn't it? How can one detect if the >> installation failed (or succeeded, for that matter)? Even the documentation >> itself uses that same exact code (classes => if_ok ...) to make an example of >> setting a class upon success. >> >> The documentation says "Package promises are like commands promises in the >> sense that cfengine promises nothing about the outcome of executing a >> command. >> All it can promise is to interface with it, starting it and using the results >> in good faith. Packages are basically `outsourced', to invoke IT parlance." >> >> As I read it, "using the result in good faith" should mean "trust the >> command", including its exit status, which is also (imho) the only possible >> sensible policy, short of building package management into cfengine. >> > > David, the problem is one of semantics. In bulk operations, some things > succeed and some > fail. You are entirely slave to the behaviour of the package manager, making > it difficult > to have a consistent behaviour that everyone can agree on. Installing one by > one is > inefficient, but possible. > > Try to think more about the final (desired) state rather than the outcome of > the shell > command. > > M > -- SY, Seva Gluschenko. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine