-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[COOK-3714] Powershell features provider and delete support.
Signed-off-by: Sean OMeara <[email protected]>
- Loading branch information
Showing
4 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# Author:: Greg Zapp (<[email protected]>) | ||
# Cookbook Name:: windows | ||
# Provider:: feature_powershell | ||
# | ||
|
||
include Chef::Provider::WindowsFeature::Base | ||
include Chef::Mixin::PowershellOut | ||
This comment has been minimized.
Sorry, something went wrong. |
||
include Windows::Helper | ||
|
||
def install_feature(name) | ||
cmd = powershell_out("Install-WindowsFeature #{@new_resource.feature_name}") | ||
Chef::Log.info(cmd.stdout) | ||
end | ||
|
||
def remove_feature(name) | ||
cmd = powershell_out("Uninstall-WindowsFeature #{@new_resource.feature_name}") | ||
Chef::Log.info(cmd.stdout) | ||
end | ||
|
||
def delete_feature(name) | ||
cmd = powershell_out("Uninstall-WindowsFeature #{@new_resource.feature_name} -Remove") | ||
Chef::Log.info(cmd.stdout) | ||
end | ||
|
||
def installed? | ||
@installed ||= begin | ||
cmd = powershell_out("Get-WindowsFeature #{@new_resource.feature_name} | Select Installed | % { Write-Host $_.Installed }") | ||
cmd.stderr.empty? && cmd.stdout =~ /True/i | ||
end | ||
end | ||
|
||
def available? | ||
@available ||= begin | ||
cmd = powershell_out("Get-WindowsFeature #{@new_resource.feature_name}") | ||
cmd.stderr.empty? && cmd.stdout !~ /Removed/i | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As of Chef 11.8.2, Chef::Mixin::PowershellOut is only available as a library from opscode-cookbook/powershell. The powershell cookbook is not listed as a dependency in the metadata.rb