hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

Win2022server OS corrupted/broken #13102

Open TadasNRK opened 2 months ago

TadasNRK commented 2 months ago

Community Note

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

After creating a Windows server 2022 with Packer, we noticed it is with corrupted Operating System. Some manifest files are missing. Due to this issue OS could not be patched. The only fix is to do in place upgrade for an OS from an ISO. Strange thing what we observed is windows update size about 25GB for the patch KB5039227. Based on Microsoft library, this KB size is about 340MB.

Why we see such a big size in the packer logs?

Reproduction Steps

Create template for the win2022 server from an older ISO image.

Packer version

[v1.11.1]

Operating system and Environment details

Used ISO image for Windows server 2022 template creation is : SW_DVD9_Win_Server_STD_CORE_2022_2108.19_64Bit_English_DC_STD_MLF_X23-40586.ISO

Used plugins:

Installed plugin github.com/rgl/windows-update v0.14.3 in "/root/.config/packer/plugins/github.com/rgl/windows-update/packer-plugin-windows-update_v0.14.3_x5.0_linux_amd64" Installed plugin github.com/hashicorp/vsphere v1.3.0 in "/root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.3.0_x5.0_linux_amd64"

Log Fragments and crash.log files

==> win2022.vsphere-iso.windows-template: Uploading the Windows update elevated script... ==> win2022.vsphere-iso.windows-template: Uploading the Windows update check for reboot required elevated script... ==> win2022.vsphere-iso.windows-template: Uploading the Windows update script... ==> win2022.vsphere-iso.windows-template: Running Windows update... win2022.vsphere-iso.windows-template: Searching for Windows updates... win2022.vsphere-iso.windows-template: Found Windows update (2022-08-09; 0.07 MB): 2022-08 Security Update for Microsoft server operating system version 21H2 for x64-based Systems (KB5012170) win2022.vsphere-iso.windows-template: Found Windows update (2024-05-14; 66.77 MB): 2024-05 Cumulative Update for .NET Framework 3.5, 4.8 and 4.8.1 for Microsoft server operating system version 21H2 for x64 (KB5038282) win2022.vsphere-iso.windows-template: Found Windows update (2024-06-11; 69.39 MB): Windows Malicious Software Removal Tool x64 - v5.125 (KB890830) win2022.vsphere-iso.windows-template: Found Windows update (2024-06-21; 148.33 MB): Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.413.438.0) - Current Channel (Broad) win2022.vsphere-iso.windows-template: Found Windows update (2024-06-11; 25371.39 MB): 2024-06 Cumulative Update for Microsoft server operating system version 21H2 for x64-based Systems (KB5039227) win2022.vsphere-iso.windows-template: Downloading Windows updates (5 updates; 25655.94 MB)... win2022.vsphere-iso.windows-template: Installing Windows updates...

lbajolet-hashicorp commented 1 month ago

Hi @TadasNRK,

Hard to say why the patch is this big, but at first glance this is probably unrelated to Packer. The windows-update plugin is the one performing the action here, so this would probably be where to look if this is a bug.

As for why the OS image is corrupted, it's also hard to say without more information, other users manage to build Windows images AFAICT, but that doesn't completely rule out a bug being the cause of what goes wrong in your case.

In order to determine the problem we'll need more information, namely a minimal template that exhibits the problem is possible, and the full verbose logs so we can take a look at this.

Thanks!