- From: AJ Christensen <
>
- To: chef <
>
- Subject: [chef] Re: Problem calling Win32::Service from recipe
- Date: Thu, 14 Mar 2013 09:30:07 +1300
Use ::Win32::Service to break out of the Chef namespace
Cheers,
AJ
On 14 March 2013 08:14, Peter Loron
<
>
wrote:
>
I've got a simple recipe I'm working on to set up some of our custom
>
Windows services. I'm trying to invoke the win32-service gem to check for
>
the existence of a service. I'm using Chef 11.2.0.
>
>
When I make the chef-client run, it fails with a "Recipe Compile Error",
>
"uninitialized constant Chef::Win32::Service".
>
>
The recipe code is below. I'm sure I'm just missing something basic but I'm
>
not sure what. I've found other examples of Chef code out there using this
>
syntax. I looked down in the bowels of the omnibus installed ruby and the
>
win32-service gem is there, and I don't get an error on the require. When I
>
run something like this from the command-line on the client box, it
>
succeeds. The omnibus ruby is the only one on that machine.
>
>
Any pointers? Clue stick? Thanks.
>
>
>
>
require 'win32/service'
>
>
target_service = "BogusServiceName"
>
>
if Win32::Service.exists?(target_service)
>
Chef::Log.info target_service + "Found!"
>
else
>
Chef::Log.info target_service + "NOT Found!"
>
end
Archive powered by MHonArc 2.6.16.