diff options
author | Nathan Williams <nath.e.will@gmail.com> | 2015-10-23 22:19:25 -0700 |
---|---|---|
committer | Nathan Williams <nath.e.will@gmail.com> | 2015-10-23 22:19:25 -0700 |
commit | a58c59460aa6b9cfe0824dabaf6cac0c445d0288 (patch) | |
tree | daf8cfecdc01e45dd19bd888974b6a75913401c5 /lib/chef/platform | |
parent | e6b2a07634f8eef374e1edb84387d69bca3044c1 (diff) | |
parent | 8bf1304da739d4be94edb101ad9e46c96b1d4ccd (diff) | |
download | chef-a58c59460aa6b9cfe0824dabaf6cac0c445d0288.tar.gz |
re-sync with master
Diffstat (limited to 'lib/chef/platform')
-rw-r--r-- | lib/chef/platform/query_helpers.rb | 45 | ||||
-rw-r--r-- | lib/chef/platform/service_helpers.rb | 52 |
2 files changed, 72 insertions, 25 deletions
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb index e64189fbd6..dfb99ed750 100644 --- a/lib/chef/platform/query_helpers.rb +++ b/lib/chef/platform/query_helpers.rb @@ -36,6 +36,44 @@ class Chef is_server_2003 end + def windows_nano_server? + return false unless windows? + require 'win32/registry' + + # This method may be called before ohai runs (e.g., it may be used to + # determine settings in config.rb). Chef::Win32::Registry.new uses + # node attributes to verify the machine architecture which aren't + # accessible before ohai runs. + nano = nil + key = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Server\\ServerLevels" + access = ::Win32::Registry::KEY_QUERY_VALUE | 0x0100 # nano is 64-bit only + begin + ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, access) do |reg| + nano = reg["NanoServer"] + end + rescue ::Win32::Registry::Error + # If accessing the registry key failed, then we're probably not on + # nano. Fail through. + end + return nano == 1 + end + + def supports_msi? + return false unless windows? + require 'win32/registry' + + key = "System\\CurrentControlSet\\Services\\msiserver" + access = ::Win32::Registry::KEY_QUERY_VALUE + + begin + ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, access) do |reg| + true + end + rescue ::Win32::Registry::Error + false + end + end + def supports_powershell_execution_bypass?(node) node[:languages] && node[:languages][:powershell] && node[:languages][:powershell][:version].to_i >= 3 @@ -52,6 +90,13 @@ class Chef Gem::Version.new(node[:languages][:powershell][:version]) >= Gem::Version.new("5.0.10018.0") end + + def dsc_refresh_mode_disabled?(node) + require 'chef/util/powershell/cmdlet' + cmdlet = Chef::Util::Powershell::Cmdlet.new(node, "Get-DscLocalConfigurationManager", :object) + metadata = cmdlet.run!.return_value + metadata['RefreshMode'] == 'Disabled' + end end end end diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb index 92efe24da2..f97eed2581 100644 --- a/lib/chef/platform/service_helpers.rb +++ b/lib/chef/platform/service_helpers.rb @@ -16,6 +16,8 @@ # limitations under the License. # +require 'chef/chef_class' + class Chef class Platform class ServiceHelpers @@ -34,55 +36,55 @@ class Chef # different services is NOT a design concern of this module. # def service_resource_providers - @service_resource_providers ||= [].tap do |service_resource_providers| - - if ::File.exist?("/usr/sbin/update-rc.d") - service_resource_providers << :debian - end + providers = [] - if ::File.exist?("/usr/sbin/invoke-rc.d") - service_resource_providers << :invokercd - end + if ::File.exist?(Chef.path_to("/usr/sbin/update-rc.d")) + providers << :debian + end - if ::File.exist?("/sbin/insserv") - service_resource_providers << :insserv - end + if ::File.exist?(Chef.path_to("/usr/sbin/invoke-rc.d")) + providers << :invokercd + end - if ::File.exist?("/sbin/initctl") - service_resource_providers << :upstart - end + if ::File.exist?(Chef.path_to("/sbin/initctl")) + service_resource_providers << :upstart + end - if ::File.exist?("/sbin/chkconfig") - service_resource_providers << :redhat - end + if ::File.exist?(Chef.path_to("/sbin/insserv")) + providers << :insserv + end - if systemd_is_init? - service_resource_providers << :systemd - end + if systemd_is_init? + providers << :systemd + end + if ::File.exist?(Chef.path_to("/sbin/chkconfig")) + providers << :redhat end + + providers end def config_for_service(service_name) configs = [] - if ::File.exist?("/etc/init.d/#{service_name}") + if ::File.exist?(Chef.path_to("/etc/init.d/#{service_name}")) configs << :initd end - if ::File.exist?("/etc/init/#{service_name}.conf") + if ::File.exist?(Chef.path_to("/etc/init/#{service_name}.conf")) configs << :upstart end - if ::File.exist?("/etc/xinetd.d/#{service_name}") + if ::File.exist?(Chef.path_to("/etc/xinetd.d/#{service_name}")) configs << :xinetd end - if ::File.exist?("/etc/rc.d/#{service_name}") + if ::File.exist?(Chef.path_to("/etc/rc.d/#{service_name}")) configs << :etc_rcd end - if ::File.exist?("/usr/local/etc/rc.d/#{service_name}") + if ::File.exist?(Chef.path_to("/usr/local/etc/rc.d/#{service_name}")) configs << :usr_local_etc_rcd end |