[chef] Powershell Script Issue, Windows 2008R2 SP1 & 10.14.2 - No errors.


Chronological Thread 
  • From: Wade Peacock < >
  • To: " " < >
  • Subject: [chef] Powershell Script Issue, Windows 2008R2 SP1 & 10.14.2 - No errors.
  • Date: Fri, 28 Sep 2012 16:42:44 +0000
  • Accept-language: en-CA, en-US

Hello All,

 

In an effort to reduce Windows 2008 R2 System load during feature install evaluation during chef-client runs I modified the "installed?" process to check a installed features against a "cache" file generated at the beginning of a chef-client run.

 

Here is the recipe being run:

 

powershell "Get Installed Features" do

        code <<-EOH

$features_list_raw = dism /Online /Get-Features /Format:Table

$features_enabled = @();

foreach ($line in $features_list_raw) {

        if ($line -match "Enabled") {

                $features_enabled += @($line)

        }

}

 

$features_enabled | Out-File -encoding ascii "#{node[:chef_client][:chef_path]}/unattend_files/installed_features.txt"

        EOH

end

 

Chef Server currently 10.14.2, Cookbook Versions: Windows 1.3.4, Powershell 1.0.6, Chef_handler 1.0.8

 

This works great when the client is either 0.10.8 & 10.12.0 but does not work with 10.14.2.  Chef-client run produces no error, the file "installed_features.txt" is not produced/updated.

 

Anyone have any thoughts?

 

Also if anyone is wondering my feature_dism.rb provider for installed? Looks like:

 

 

def installed?
  @installed ||= begin
    #cmd = shell_out("#{dism} /online /Get-Features", {:returns => [0,42,127]})
    #cmd.stderr.empty? && (cmd.stdout =~  /^Feature Name : 
  : Enabled.?$/i)
    #
    # Wade's Custom Code
    #
    cmd = shell_out("cat #{node["chef_client"]["chef_path"]}/unattend_files/installed_features.txt", {:returns => [0,42,127]}) 
    cmd.stderr.empty? && (cmd.stdout =~ /#{@new_resource.feature_name} /i)
    #
    # End of Wade's Custom Code
    # 
  end
end

 

Cheers,

 

Wade Peacock
Production IT | Vision Critical
direct  604.629.9358

mobile  604.363.8137

 

www.visioncritical.com


New York  |  London  |  Vancouver |  Paris  | Sydney  |  Chicago |  San Francisco | Toronto | Montreal | Calgary

 



  • [chef] Powershell Script Issue, Windows 2008R2 SP1 & 10.14.2 - No errors., Wade Peacock, 09/28/2012

Archive powered by MHonArc 2.6.16.

§