From 9703782bad3ddfad90b21ca5a225d4bd2e393f0d Mon Sep 17 00:00:00 2001 From: Claire McQuin Date: Thu, 17 Sep 2015 09:47:08 -0700 Subject: Don't add win_evt logger when on nano. --- lib/chef/platform/query_helpers.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'lib/chef/platform') diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb index 2dd33ea190..9ba8d2261d 100644 --- a/lib/chef/platform/query_helpers.rb +++ b/lib/chef/platform/query_helpers.rb @@ -36,6 +36,28 @@ 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_powershell_execution_bypass?(node) node[:languages] && node[:languages][:powershell] && node[:languages][:powershell][:version].to_i >= 3 @@ -52,7 +74,7 @@ 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) -- cgit v1.2.1