Chef: How do I check to see if a service is installed?

半腔热情 提交于 2019-12-01 17:37:26

Take a look on how is service for windows is defined

https://github.com/opscode/chef/blob/master/lib/chef/provider/service/windows.rb

AFAIU its pretty straighforward add import to your recipe:

require 'win32/service'

and then you can check if service exists with

Win32::Service.exists?(@new_resource.service_name)

voila - you can put impementation to library (http://docs.opscode.com/essentials_cookbook_libraries.html) just not to pollute recipe code and have simple method service_exists?.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!