[chef] How to check whether a package is installed ?


Chronological Thread 
  • From: Hui Hu < >
  • To:
  • Subject: [chef] How to check whether a package is installed ?
  • Date: Thu, 10 Oct 2013 15:17:30 +0800

Hi Chef,

Is there a simple chef way to check whether a package is installed or a service is running ?

For example, I want to write some code like this :

do-work if package('mypkg').installed?
do-work if service('mysvr').running?

I know we can do it by the code below, but it's bind to the specific platform. What I need is a platform independent way.

execute "..." do
  only_if "rpm -q mypkg"
  only_if "service mysvr status"
end

Thanks
Jesse Hu,  Project Serengeti



Archive powered by MHonArc 2.6.16.

§