Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

juliandunn
Copy link
Contributor

No description provided.

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"
Copy link

Choose a reason for hiding this comment

The 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
::Chef::VERSION <= "11.6."

More logic to make the version check.

end

Copy link

Choose a reason for hiding this comment

The 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.

@sersut
Copy link

sersut commented Jul 15, 2013

Also deprecation or warning message while using winsw with chef version that supports chef-service-manager ?

# 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? }
Copy link

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.

Copy link
Contributor Author

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?

end

# Fall back to winsw on older Chef Clients without the service manager
if ::Chef::VersionConstraint.new("< 11.6").include?(::Chef::VERSION.split(/\./)[0..1].join('.'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the .split necessary here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this magic due to this only working with x.y or x.y.z versions?

Seth recommends this:

Gem::Requirement.new('< 11.6').satisfied_by?(Gem::Version.new(Chef::VERSION))

That's complicated too. What's the path forward for the best practice for comparing cookbook versions?

Julian C. Dunn added 7 commits August 31, 2013 01:23
@btmspox et. al pointed out that the latter is for cookbook version testing.

Note: The use of "11.5" is not a mistake. Using "11.6" will cause RCs to give the wrong behavior; same as hotfixes of the format "11.6.0.hotfix.1". More detail is available in the ticket.
…OK-1863

Conflicts:
	recipes/windows_service.rb
	recipes/winsw_service.rb
@sethvargo
Copy link
Contributor

Merged in 0a516b6

@sethvargo sethvargo closed this Sep 9, 2013
@juliandunn juliandunn deleted the COOK-1863 branch September 10, 2013 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants