On 17 Sep 2010, at 10:27 am, Seva Gluschenko wrote: > 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.
That's pretty unwieldy though, once the number of packages becomes large. Personally I avoided this problem completely by very rarely using cfengine's packages mechanism - I distribute files with cfengine containing lists of desired package states, and my own script checks that those packages are installed/removed as appropriate. It's not quite as flexible as cfengine's method -- which I do still use occasionally when I need the extra stuff -- but: a) It invokes the package manager far fewer times (only once per package list file), and then only if the package list files or defined classes have changed since the last time the script was run. b) The resulting list file is much easier for my junior admins to make changes to than editing full cfengine promise files. The downside is the script is Debian/Ubuntu specific, although it would be pretty trivial to adapt it to cope with RPM-style distros as well/instead. Regards, Tim -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine