chef unable to install windows features on this image
Closed this issue · 1 comments
I have a slightly modified fork of this repo generating windows 2012 R2 images.
Problem
In test kitchen, the windows cookbook is unable to install any windows features. However if I RDP into the vm and manually run dism.exe the windows features install without problem.
windows_feature 'IIS-ASPNET45' do
action :install
all true
end
[2016-06-28T21:02:57+00:00] FATAL: Stacktrace dumped to C:/Users/ADMINI~1/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
[2016-06-28T21:02:57+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-06-28T21:02:57+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: windows_feature[Application-Server-WAS-Support] (nd-web::windows_feature line 33) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 42, 127, 3010], but received '-2146498298'
---- Begin output of C:\Windows\system32\dism.exe /online /enable-feature /featurename:Application-Server-WAS-Support /norestart /All ----
STDOUT: Deployment Image Servicing and Management tool
Version: 6.3.9600.17031
Image Version: 6.3.9600.17031
Enabling feature(s)
Error: 0x800f0906
The source files could not be downloaded.
Use the "source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.
The DISM log file can be found at C:\Windows\Logs\DISM\dism.log
STDERR:
---- End output of C:\Windows\system32\dism.exe /online /enable-feature /featurename:Application-Server-WAS-Support /norestart /All ----
Cause
According to smurawski's comment here dism.exe won't use windows update as a source when executed from winrm. That would explain the symptoms.
I have other golden images (not built by this packer repo) that are able to install windows_features using the same chef cookbooks.
I don't understand what is different in this image that causes dism.exe to fail over winrm/chef.
Theories
- The cleanSXS step in provision.ps1 is removing cached windows features.
I've tried running the following with no luck.
Dism.exe /online /Cleanup-Image /StartComponentCleanup
sfc /scannow
Dism /Online /Cleanup-Image /RestoreHealth
sfc /scannow
- The package.ps1 step that removes unused windows features is removing something critical that prevents dism.exe from later working from chef
I'm making some boxes to try and test these theories. Do you have any other ideas or suggestions?
Turns out the step that uninstalls the windows features was the culprit.
if (Test-Command -cmdname 'Uninstall-WindowsFeature') {
Write-BoxstarterMessage ""
Write-BoxstarterMessage "***************************"
Write-BoxstarterMessage "Removing unused features..."
Write-BoxstarterMessage "***************************"
Write-BoxstarterMessage ""
Remove-WindowsFeature -Name 'Powershell-ISE'
Get-WindowsFeature |
? { $_.InstallState -eq 'Available' } |
Uninstall-WindowsFeature -Remove
}
Removing the following lines fixed the problem.
https://github.com/mwrock/packer-templates/blob/master/scripts/package.ps1#L10-L16