summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2020-03-02 10:16:16 -0800
committerGitHub <noreply@github.com>2020-03-02 10:16:16 -0800
commitcb6d978d1a9ace1cb648822f943596dc2cea38aa (patch)
tree1190d65eb68c1baebf834583a1202f596525da2c
parentd2c0e23b12a93c0f4fe6aee89a0130c4e2c61c40 (diff)
parentd55f440dbe58426d21c574ba46fd54bf2d099a4d (diff)
downloadchef-cb6d978d1a9ace1cb648822f943596dc2cea38aa.tar.gz
Merge pull request #9426 from chef/more_windows_feature_cleanup
More removal of Windows 2008 R2 support from windows_feature_powershell
-rw-r--r--lib/chef/resource/windows_feature_powershell.rb18
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/chef/resource/windows_feature_powershell.rb b/lib/chef/resource/windows_feature_powershell.rb
index e848df0ec1..8e35e9ddcc 100644
--- a/lib/chef/resource/windows_feature_powershell.rb
+++ b/lib/chef/resource/windows_feature_powershell.rb
@@ -115,18 +115,6 @@ class Chef
end
action_class do
- # shellout to determine the actively installed version of powershell
- # we have this same data in ohai, but it doesn't get updated if powershell is installed mid run
- # @return [Integer] the powershell version or 0 for nothing
- def powershell_version
- cmd = powershell_out("$PSVersionTable.psversion.major")
- return 1 if cmd.stdout.empty? # PowerShell 1.0 doesn't have a $PSVersionTable
-
- Regexp.last_match(1).to_i if cmd.stdout =~ /^(\d+)/
- rescue Errno::ENOENT
- 0 # zero as in nothing is installed
- end
-
# @return [Array] features the user has requested to install which need installation
def features_to_install
# the intersection of the features to install & disabled features are what needs installing
@@ -199,7 +187,7 @@ class Chef
# add the features values to the appropriate array
# @return [void]
def add_to_feature_mash(feature_type, feature_details)
- # add the lowercase feature name to the mash unless we're on < 2012 where they're case sensitive
+ # add the lowercase feature name to the mash so we can compare it lowercase later
node.override["powershell_features_cache"][feature_type] << feature_details.downcase
end
@@ -207,10 +195,8 @@ class Chef
# @return [void]
def fail_if_removed
return if new_resource.source # if someone provides a source then all is well
+ return if registry_key_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing') && registry_value_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing', name: "LocalSourcePath") # if source is defined in the registry, still fine
- if node["platform_version"].to_f > 6.2 # 2012R2 or later
- return if registry_key_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing') && registry_value_exists?('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Servicing', name: "LocalSourcePath") # if source is defined in the registry, still fine
- end
removed = new_resource.feature_name & node["powershell_features_cache"]["removed"]
raise "The Windows feature#{"s" if removed.count > 1} #{removed.join(",")} #{removed.count > 1 ? "are" : "is"} removed from the host and cannot be installed." unless removed.empty?
end