[chef] Re: detect if a service is running?


Chronological Thread 
  • From: Kenneth Barry < >
  • To: " " < >
  • Subject: [chef] Re: detect if a service is running?
  • Date: Fri, 9 Jan 2015 17:08:50 -0800

You might so something like

Use the 'package' resource, (you can even tell it that the installer is someplace remote), if it isn't jnatalled, it installs the program.

To handle scenario 2, there might be an action for package to always install, even of it's there, else, you might try a package block to remove, followed by one to install, assuming uninstall stops the service for you.

Question, if it's installed and running, why is the reinstall necessary?

Sent from my iPhone

On Jan 9, 2015, at 3:31 PM, James Harrison < "> > wrote:

Hi chefs,

 

I’m pretty new to chef, and feel like I’m missing something obvious. Any advice would be appreciated. I’m trying to cover two scenarios with one recipe, in a Windows environment. What I’m trying to do is:

 

-          Scenario 1: install a package

-          Scenario 2: if the package is already installed, stop a service and then reinstall the package.

 

The recipe, as currently written, goes through a series of steps involving downloading the installer, always attempting to stop the service, then running the installer if the package is not already installed, then starting the service.

 

The problem I’m facing is in scenario 1. If I attempt to stop the service, but the service is not installed, then I receive an exception and execution of the recipe halts.

 

Am I trying to do something that is better covered by two recipes? Or is there some easy way to check if a service is installed?

 

Thanks

 

James




Archive powered by MHonArc 2.6.16.

§