rgl / packer-plugin-windows-update

Packer plugin for installing Windows updates
Mozilla Public License 2.0
299 stars 71 forks source link

Windows Server 2016 never finishes updates install. #105

Open FedorRub opened 2 years ago

FedorRub commented 2 years ago

I recently encountered an issue, where updates on Windows Server 2016 never finish. Other Windows versions do not seem to be affected, so it could be related to a recent update. Windows Updates plugin is stuck after downloading updates and never proceeds to install. You can view the full log here. https://gist.github.com/FedorRub/5352c43be40a0a3c5bdbc1467a8a9221

021/10/04 02:28:30 ui: ==> vsphere-iso.windows: Running Windows update...
2021/10/04 02:28:31 packer.exe plugin: [INFO] starting remote command: PowerShell -ExecutionPolicy Bypass -OutputFormat Text -File C:/Windows/Temp/packer-windows-update-elevated.ps1
2021/10/04 02:28:44 ui:     vsphere-iso.windows: Searching for Windows updates...
2021/10/04 02:29:47 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 20 % cpu; 94 % memory)...
2021/10/04 02:30:47 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 24 % cpu; 90 % memory)...
2021/10/04 02:31:51 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 4 % cpu; 92 % memory)...
2021/10/04 02:32:55 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 5 % cpu; 96 % memory)...
2021/10/04 02:34:01 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 13 % cpu; 99 % memory)...
2021/10/04 02:35:00 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 11 % cpu; 27 % memory)...
2021/10/04 02:36:05 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 11 % cpu; 29 % memory)...
2021/10/04 02:37:09 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 21 % cpu; 42 % memory)...
2021/10/04 02:38:15 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 27 % cpu; 49 % memory)...
2021/10/04 02:39:15 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 8 % cpu; 30 % memory)...
2021/10/04 02:39:35 ui:     vsphere-iso.windows: Found Windows update (2021-01-12; 0.07 MB): Security Update for Windows Server 2016 for x64-based Systems (KB4535680)
2021/10/04 02:39:35 ui:     vsphere-iso.windows: Found Windows update (2021-03-09; 2.2 MB): 2021-01 Update for Windows Server 2016 for x64-based Systems (KB4589210)
2021/10/04 02:39:35 ui:     vsphere-iso.windows: Found Windows update (2021-09-14; 1665.89 MB): 2021-09 Cumulative Update for Windows Server 2016 for x64-based Systems (KB5005573)
2021/10/04 02:39:35 ui:     vsphere-iso.windows: Downloading Windows updates (3 updates; 1668.16 MB)...
2021/10/04 02:40:19 ui:     vsphere-iso.windows: Waiting for operation to complete (system performance: 53 % cpu; 47 % memory)...

When I login to vm console I see that updates are ready to be installed.

image

I use the following packer template for all windows builds. It has multiple calls to windows update provider for win2012-r2.

variable "vcenter_server" {
    type = string
    description = "vCenter server to build the VM on"
}
variable "vcenter_username" {
    type = string
    description = "Username to authenticate to vCenter"
    default     = ""
}
variable "vcenter_password" {
    sensitive = true
}
variable "vcenter_cluster" {
    type = string
}
variable "vcenter_datacenter" {
    type = string
}
variable "vcenter_host" {
    type = string
}
variable "vcenter_datastore" {
    type = string
}
variable "vcenter_folder" {
    type = string
    description = "The vcenter folder to store the template"
}
variable "os_username" {
    type = string
    default = "Administrator"
}
variable "os_password" {
    type = string
    sensitive = true
}
variable "vm_hardware_version" {
    type = string
    default = "15"
}
variable "iso_checksum" {}
variable "os" {
    description = "Parameter used by DeployVM to identify template"
    type = string
}
variable "vm_name" {
    type = string
}
variable "secondary_iso_path" {
}
variable "guest_os_type" {
    type = string
}
variable "root_disk_size" {
    default = 40960
}
variable "nic_type" {
    default = "vmxnet3"
}
variable "vm_network" { 
    type = string
}
variable "num_cpu" {
    default = 4
}
variable "num_cores" {
    default = 1
}
variable "vm_ram" {
    default = 4096
}
variable "os_family" {
    description = "OS Family builds the paths needed for packer"
    default = ""
}
variable "os_iso_path" {
    description = "The download url for the ISO"
    default = ""
}
variable "firmware" {
    description = "Firmware for virtual machine. Supported values: bios, efi or efi-secure"
    default = "efi-secure"
}

packer {
  required_plugins {
    windows-update = {
      version = "0.14.0"
      source = "github.com/rgl/windows-update"
    }
  }
}

source "vsphere-iso" "windows" {
  # vCenter settings
  vcenter_server      = var.vcenter_server
  username            = var.vcenter_username
  password            = var.vcenter_password
  insecure_connection = true #TODO: Add ca to docker
  cluster             = var.vcenter_cluster
  datacenter          = var.vcenter_datacenter
  host                = var.vcenter_host
  datastore           = var.vcenter_datastore
  convert_to_template = false
  folder              = var.vcenter_folder

  # VM Settings
  ip_wait_timeout       = "45m"
  communicator          = "winrm"
  winrm_username        = var.os_username
  winrm_password        = var.os_password
  winrm_timeout         = "12h"
  winrm_port            = "5985"
  shutdown_command      = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
  shutdown_timeout      = "30m"
  vm_version            = var.vm_hardware_version
  firmware              = var.firmware
  cdrom_type = "sata"
  cd_files = var.secondary_iso_path
  iso_paths              = [
      var.os_iso_path,
  ]
  iso_checksum          = var.iso_checksum
  vm_name               = var.vm_name
  guest_os_type         = var.guest_os_type
  notes = <<EOF
  os=${var.os};
  owner=ManagedWithPacker;
  updates={{isotime `2006-01-02`}};
  EOF
  disk_controller_type  = ["pvscsi"] # Windows requires vmware tools drivers for pvscsi to work
  network_adapters {
    # For windows, the vmware tools network drivers are required to be connected by floppy before tools is installed
    network = var.vm_network
    network_card = var.nic_type
  }
  storage {
    disk_size = var.root_disk_size
    disk_thin_provisioned = true
  }
  CPUs                  = var.num_cpu
  cpu_cores             = var.num_cores
  CPU_hot_plug          = true
  RAM                   = var.vm_ram
  RAM_hot_plug          = true

  boot_wait    = "3s"
  boot_command = [
    "<spacebar><spacebar>",
    "a<enter><wait>a<enter><wait>a<enter><wait>a<enter>"
  ]

}

build {
    # Windows builds
    sources = [
        "source.vsphere-iso.windows",
    ]

provisioner "powershell" {
        elevated_user = "${var.os_username}"
        elevated_password = "${var.os_password}"
        scripts = [
            "scripts/Disable-UAC.ps1"
        ]
    }
     provisioner "powershell" {
        elevated_user = "${var.os_username}"
        elevated_password = "${var.os_password}"
        scripts = [
            "scripts/Set-WSUS.ps1" 
        ]
    }
     provisioner "powershell" {
        elevated_user = "${var.os_username}"
        elevated_password = "${var.os_password}"
        scripts = [
            "scripts/Enable-RDP.ps1" 
        ]
    }

    provisioner "windows-update" { # This requires windows-update-provisioner https://github.com/rgl/packer-provisioner-windows-update
        max_retries = "5"
        pause_before = "1m"
        filters = [
            "exclude:$_.Title -like '*Preview*'",
            "include:$true"
        ]
    }
    provisioner "windows-update" { # This requires windows-update-provisioner https://github.com/rgl/packer-provisioner-windows-update
        max_retries = "5"
        pause_before = "1m"
        filters = [
            "exclude:$_.Title -like '*Preview*'",
            "include:$true"
        ]
    }
    provisioner "windows-update" { # This requires windows-update-provisioner https://github.com/rgl/packer-provisioner-windows-update
        max_retries = "5"
        pause_before = "1m"
        filters = [
            "exclude:$_.Title -like '*Preview*'",
            "include:$true"
        ]
    }
    provisioner "file" {
        source = "WinCloudInit"
        destination = "C:\\Program Files\\WindowsPowerShell\\Modules"
    }

    provisioner "powershell" {
        elevated_user = "${var.os_username}"
        elevated_password = "${var.os_password}"
        environment_vars = [
            "username=${var.os_username}",
            "password=${var.os_password}",
        ]
        scripts = [
            "scripts/Enable-WinCloudInit.ps1" 
        ]
    }
    post-processors {
        post-processor "shell-local" { # Remove Secondary CDROM
            environment_vars = [
                "vcenter_username=${var.vcenter_username}",
                "vm_name=${var.vm_name}",
                "vcenter_server=${var.vcenter_server}",
                "vcenter_password=${var.vcenter_password}",
        ]
        execute_command  = ["powershell.exe", "{{.Vars}} {{.Script}}"]
        env_var_format   = "$env:%s=\"%s\"; "
        scripts = [ 
            "scripts/ESX-Remove-Extra-CDrom.ps1" 
            ]
        }
    }
}
rgl commented 2 years ago

I'm also clueless about the problem.

I've noticed the memory usage might be too high. Maybe try to give it 8GB RAM to see if it helps.

FedorRub commented 2 years ago

I tried increasing the memory to 8GB to no avail. I forgot to mention that this also happens with Windows Server 2016 with hyperv-iso builder. So I suspect something broke after latest rounds of WU. Is there any debug info I can get from the running vm that could help you identify the problem?

rgl commented 2 years ago

Maybe there are logs somewhere, but I never needed to look at them, so I do not known where to look exactly.

There's one thing that you might need: install Servicing Stack Update for Windows before anything else, like in:

https://github.com/rgl/windows-vagrant/blob/master/windows-2016.pkr.hcl#L201-L208

FedorRub commented 2 years ago

That sounds promising! Let me try that!

FedorRub commented 2 years ago

So far, I am not having a lot of luck with Windows Server 2016 Standard template. I tried installing Servicing Stack Update for Windows, uninstalling Windows Defender (In case defender updates were causing the issue), and running Disable-windows-updates.ps1 script. Unfortunately, the build is stuck on applying windows updates forever. The only difference I see between our templates is that you are using Datacenter edition ISO while I am using Windows Server Standard ISO. Out of curiosity if you run your build of Windows 2016 server does it complete successfully?

rgl commented 2 years ago

Even though its using the datacenter ISO (has multiple windows editions), its actually installing the standard edition.

The last time I've tried (couple of months ago), all of the images in the windows-vagrant repo worked. I'll try windows-2016 today, and will let you known.

FedorRub commented 2 years ago

Hi @rgl. I was wondering if you had a chance to run Win2016 build?

rgl commented 2 years ago

Sorry, forgot about this. Just tried it, and it worked:

==> qemu.windows-2016-amd64: Uploading the Windows update elevated script...
==> qemu.windows-2016-amd64: Uploading the Windows update check for reboot required elevated script...
==> qemu.windows-2016-amd64: Uploading the Windows update script...
==> qemu.windows-2016-amd64: Running Windows update...
    qemu.windows-2016-amd64: Searching for Windows updates...
    qemu.windows-2016-amd64: Skipped (filter) Windows update (2018-05-17; 1273.25 MB): 2018-05 Cumulative Update for Windows Server 2016 for x64-based Systems (KB4103720)
    qemu.windows-2016-amd64: Skipped (filter) Windows update (2021-09-14; 35.28 MB): Windows Malicious Software Removal Tool x64 - v5.93 (KB890830)
    qemu.windows-2016-amd64: Found Windows update (2021-09-14; 11.42 MB): 2021-09 Servicing Stack Update for Windows Server 2016 for x64-based Systems (KB5005698)
    qemu.windows-2016-amd64: Downloading Windows updates (1 updates; 11.42 MB)...
    qemu.windows-2016-amd64: Installing Windows updates...
==> qemu.windows-2016-amd64: Uploading the Windows update elevated script...
==> qemu.windows-2016-amd64: Uploading the Windows update check for reboot required elevated script...
==> qemu.windows-2016-amd64: Uploading the Windows update script...
==> qemu.windows-2016-amd64: Running Windows update...
    qemu.windows-2016-amd64: Searching for Windows updates...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 38 % cpu; 77 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 63 % cpu; 89 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 48 % cpu; 87 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 47 % cpu; 27 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 50 % cpu; 28 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 51 % cpu; 26 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 59 % cpu; 26 % memory)...
    qemu.windows-2016-amd64: Found Windows update (2021-01-12; 0.07 MB): Security Update for Windows Server 2016 for x64-based Systems (KB4535680)
    qemu.windows-2016-amd64: Found Windows update (2021-03-09; 2.2 MB): 2021-01 Update for Windows Server 2016 for x64-based Systems (KB4589210)
    qemu.windows-2016-amd64: Found Windows update (2021-09-14; 35.28 MB): Windows Malicious Software Removal Tool x64 - v5.93 (KB890830)
    qemu.windows-2016-amd64: Found Windows update (2021-09-14; 1665.89 MB): 2021-09 Cumulative Update for Windows Server 2016 for x64-based Systems (KB5005573)
    qemu.windows-2016-amd64: Downloading Windows updates (4 updates; 1703.45 MB)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 64 % cpu; 21 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 82 % cpu; 29 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 29 % cpu; 30 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 16 % cpu; 31 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 20 % cpu; 33 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 81 % cpu; 34 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 53 % cpu; 36 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 47 % cpu; 38 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 43 % cpu; 40 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 35 % cpu; 38 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 61 % cpu; 38 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 29 % cpu; 41 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 56 % cpu; 43 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 85 % cpu; 34 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 76 % cpu; 44 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 73 % cpu; 39 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 32 % cpu; 34 % memory)...
    qemu.windows-2016-amd64: Installing Windows updates...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 41 % cpu; 30 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 70 % cpu; 29 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 47 % cpu; 31 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 52 % cpu; 31 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 50 % cpu; 31 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 49 % cpu; 32 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 43 % cpu; 32 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 53 % cpu; 32 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 46 % cpu; 33 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 60 % cpu; 37 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 56 % cpu; 38 % memory)...
    qemu.windows-2016-amd64: Waiting for the Windows Modules Installer to exit...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 1 % cpu; 21 % memory)...
    qemu.windows-2016-amd64: Waiting for operation to complete (system performance: 1 % cpu; 21 % memory)...
==> qemu.windows-2016-amd64: Restarting the machine...
==> qemu.windows-2016-amd64: Waiting for machine to become available...
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: A system shutdown is in progress.(1115)
==> qemu.windows-2016-amd64: Checking for pending restart...
    qemu.windows-2016-amd64: VAGRANT-48DM8ET restarted.
==> qemu.windows-2016-amd64: Restart complete
==> qemu.windows-2016-amd64: Running Windows update...
    qemu.windows-2016-amd64: Searching for Windows updates...
    qemu.windows-2016-amd64: No Windows updates found

PS The whole Windows installation finished in about 3h.

PPS Windows 2019 (and 2022) Standard also worked.

FedorRub commented 2 years ago

Thanks for checking. It looks like something related to my environment, where updates never finish downloading from MS. I will try switching to updates from WSUS, see if that makes any difference.

Klashblack commented 2 years ago

I am having the exact same issue. I checked windows update and i too was stuck downloading and was stuck at 95%. This is also only happening for Windows Server 2016. 2012R2 and 2019 both worked for me. I actually left it running over night and it never completed even after running for 17 hours

nkretschmar commented 2 years ago

I had the same behaviour, packer-plugin-windows-update detected on top of a vanilla image of Windows Server 2016 a first ste of few updates, installed these perfectly, and after the reboot it continued to search and download a second batch. Here it stuck... As observed by other above.

Finally, I figured out, it depends on plugin version. With 0.12 it works as expected, while it doesn't do the job with 0.14. @rgl Maybe useful to know for you. As some parts are encrypted, I cannot reproduce mannally yet.

nkretschmar commented 2 years ago

I had the same behaviour, packer-plugin-windows-update detected on top of a vanilla image of Windows Server 2016 a first ste of few updates, installed these perfectly, and after the reboot it continued to search and download a second batch. Here it stuck... As observed by other above.

Finally, I figured out, it depends on plugin version. With 0.12 it works as expected, while it doesn't do the job with 0.14. @rgl Maybe useful to know for you. As some parts are encrypted, I cannot reproduce mannally yet.

Damned, now I face 16001... like described here: https://github.com/rgl/packer-plugin-windows-update/issues/65

VersusBG commented 2 years ago

"KB4589210: Intel microcode updates" should not be installed on VM

elixx commented 2 years ago

I am able to consistently reproduce that the linux version of packer-plugin-windows-update v0.14 will hang up for me every time when updating a Win2016 guest. It appears to work for the rest of Win2012-2022. If I use the same Packer template and binary version on Windows, the windows update plugin v0.14 works fine.

martijnvdp commented 2 years ago

Maybe there are logs somewhere, but I never needed to look at them, so I do not known where to look exactly.

There's one thing that you might need: install Servicing Stack Update for Windows before anything else, like in:

https://github.com/rgl/windows-vagrant/blob/master/windows-2016.pkr.hcl#L201-L208

nice find, this works for me as well