New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[COOK-1863] Change default service style on Windows to windows_service if Chef >= 11.6 #110
Changes from 1 commit
e288621
24f419d
179e2b2
c23fed9
5409e96
43be8c1
8880da5
8075306
83c6c21
76f93fa
9945240
7129bc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
'runit', | ||
'smf', | ||
'upstart', | ||
'windows', | ||
'winsw' | ||
] | ||
init_style = node["chef_client"]["init_style"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Cookbook Name:: chef-client | ||
# Recipe:: windows_service | ||
# | ||
# Author:: Julian Dunn (<jdunn@opscode.com>) | ||
# | ||
# Copyright 2013, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
class ::Chef::Recipe | ||
include ::Opscode::ChefClient::Helpers | ||
end | ||
|
||
# libraries/helpers.rb method to DRY directory creation resources | ||
create_directories | ||
|
||
# Will also avoid touching any winsw service if it exists | ||
execute "register-chef-service" do | ||
command "chef-service-manager -a install" | ||
only_if { WMI::Win32_Service.find(:first, :conditions => {:name => 'chef-client'}).nil? } | ||
# Previous versions of Chef (< 11.6.x) had a windows_service library but no manager. | ||
# However, they were also broken, so only try this on versions that have the manager | ||
only_if "chef-service-manager -v" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of checking the version I would execute "chef-service-manager" and assume that we're on a good version if it executes. If it's not there exception will be thrown and we can fall back to using winsw. If I was doing this based on version I would check the version as such: only_if do More logic to make the version check.end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I couldn't see the fallback logic to winsw style service installation. |
||
end | ||
|
||
service "chef-client" do | ||
action [:enable, :start] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an option where users can specify a different name for the chef-service other than chef-client ?
We should make sure this condition works for winsw + chef-service-manager style installed services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that a requirement? Given that we've assumed this naming up to now, in both the chef-client cookbook and what the MSI calls it on Windows if you install the service component, I'm a bit loath to change it, or to add that functionality. The code becomes very complicated if we have to account for this?