summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-07-22 15:17:58 -0400
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-07-24 15:12:08 -0400
commitca8a8bdb000c7cb82588cc56ddfb32464babf3c3 (patch)
tree4a799a0dc2bcd0285dc37c69541b0445e07a69f2
parent283301d40e6449f9d513d18afacdb6ca360898d9 (diff)
downloadchef-ca8a8bdb000c7cb82588cc56ddfb32464babf3c3.tar.gz
Add ability to specify dependencies in chef-service-manager.
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xbin/chef-service-manager4
-rw-r--r--lib/chef/application/windows_service_manager.rb16
-rw-r--r--lib/chef/platform/query_helpers.rb5
-rw-r--r--lib/chef/win32/version.rb4
5 files changed, 13 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 28886da594..a02dd81a23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
* [pr#3666](https://github.com/chef/chef/pull/3666) Support SNI in `knife ssl check`.
* [pr#3667](https://github.com/chef/chef/pull/3667) Change chef service to start as 'Automatic delayed start'.
* [pr#3683](https://github.com/chef/chef/pull/3683) Correct Windows reboot command to delay in minutes, per the property.
+* [pr#3698](https://github.com/chef/chef/pull/3698) Add ability to specify dependencies in chef-service-manager.
## 12.4.1
diff --git a/bin/chef-service-manager b/bin/chef-service-manager
index bbcab5ca92..7c031f70d4 100755
--- a/bin/chef-service-manager
+++ b/bin/chef-service-manager
@@ -29,10 +29,10 @@ if Chef::Platform.windows?
:service_display_name => "Chef Client Service",
:service_description => "Runs Chef Client on regular, configurable intervals.",
:service_file_path => File.expand_path(File.join(File.dirname(__FILE__), '../../../../bin/chef-windows-service')),
- :delayed_start => true
+ :delayed_start => true,
+ :dependencies => ['Winmgmt']
}
Chef::Application::WindowsServiceManager.new(chef_client_service).run
else
puts "chef-service-manager is only available on Windows platforms."
end
-
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index 9bd6095260..44526c1720 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -93,6 +93,7 @@ class Chef
@service_start_name = service_options[:run_as_user]
@password = service_options[:run_as_password]
@delayed_start = service_options[:delayed_start]
+ @dependencies = service_options[:dependencies]
end
def run(params = ARGV)
@@ -114,16 +115,17 @@ class Chef
cmd = "\"#{ruby}\" \"#{@service_file_path}\" #{opts}".gsub(File::SEPARATOR, File::ALT_SEPARATOR)
::Win32::Service.new(
- :service_name => @service_name,
- :display_name => @service_display_name,
- :description => @service_description,
+ :service_name => @service_name,
+ :display_name => @service_display_name,
+ :description => @service_description,
# Prior to 0.8.5, win32-service creates interactive services by default,
# and we don't want that, so we need to override the service type.
- :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
- :start_type => ::Win32::Service::SERVICE_AUTO_START,
- :binary_path_name => cmd,
+ :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
+ :start_type => ::Win32::Service::SERVICE_AUTO_START,
+ :binary_path_name => cmd,
:service_start_name => @service_start_name,
- :password => @password,
+ :password => @password,
+ :dependencies => @dependencies
)
::Win32::Service.configure(
:service_name => @service_name,
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb
index b3948eac21..e64189fbd6 100644
--- a/lib/chef/platform/query_helpers.rb
+++ b/lib/chef/platform/query_helpers.rb
@@ -25,13 +25,10 @@ class Chef
end
def windows_server_2003?
+ # WMI startup shouldn't be performed unless we're on Windows.
return false unless windows?
require 'wmi-lite/wmi'
- # CHEF-4888: Work around ruby #2618, expected to be fixed in Ruby 2.1.0
- # https://github.com/ruby/ruby/commit/588504b20f5cc880ad51827b93e571e32446e5db
- # https://github.com/ruby/ruby/commit/27ed294c7134c0de582007af3c915a635a6506cd
-
wmi = WmiLite::Wmi.new
host = wmi.first_of('Win32_OperatingSystem')
is_server_2003 = (host['version'] && host['version'].start_with?("5.2"))
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index 17c27e4780..6a7a65b01b 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -122,10 +122,6 @@ class Chef
# WMI always returns the truth. See article at
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
- # CHEF-4888: Work around ruby #2618, expected to be fixed in Ruby 2.1.0
- # https://github.com/ruby/ruby/commit/588504b20f5cc880ad51827b93e571e32446e5db
- # https://github.com/ruby/ruby/commit/27ed294c7134c0de582007af3c915a635a6506cd
-
wmi = WmiLite::Wmi.new
os_info = wmi.first_of('Win32_OperatingSystem')
os_version = os_info['version']