packer-plugin-windows-update
packer-plugin-windows-update copied to clipboard
W2019 Provisioner won't wait for update to complete, goes immediately to the next provisioner
Hello, some time ago new problem appeared. Previously, updates were working fine with update status displayed and waiting till the process end. Since some time (within period May to July), without modifying the JSON file nor plugin version, the plugin stopped to show the progress and immediately goes to the next provisioner. The problem did not appeared on W2016 server, so my assumption was, it was due to some specific update for W2019.
JSON file:
{
"variables": {
"boot_wait": "2s",
"disk_size": "61440",
"iso_checksum_type": "sha1",
"iso_checksum": "f60e87bc8a413d00d46e59281a1c14f3ffda8570",
"iso_url": "https://nexus.domain.com/repository/binary/iso/Windows_Server_2019_MLF_X22-18452.iso",
"memsize": "8192",
"numvcpus": "2",
"winrm_password" : "{{env `WINRM_PASSWD`}}",
"winrm_username" : "{{env `WINRM_USR`}}",
"remote_vm_host": "esx026.domain.com",
"remote_vm_datastore": "Datastore001",
"remote_usr": "{{env `REMOTE_USR`}}",
"remote_passwd": "{{env `REMOTE_PASSWD`}}"
},
"builders": [
{
"type": "vmware-iso",
"name":"Standard",
"vm_name":"W2K19STD",
"output_directory": "W2K19STD",
"keep_registered":true,
"guest_os_type": "windows9srv-64",
"version": "13",
"memory": "{{user `memsize`}}",
"cpus": "{{user `numvcpus`}}",
"boot_command": ["<enter><wait2s><spacebar>"],
"boot_wait": "{{user `boot_wait`}}",
"disk_size": "{{user `disk_size`}}",
"headless": false,
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_url": "{{user `iso_url`}}",
"communicator":"winrm",
"winrm_username": "{{user `winrm_username`}}",
"winrm_password": "{{user `winrm_password`}}",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_timeout": "1h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"shutdown_timeout": "30m",
"floppy_files": [
"answer_files/W2K19/Standard/autounattend.xml",
"files/MicrosoftRootCertificateAuthority2011.cer",
"files/makecert"
],
"vmdk_name":"{{user `vm_name`}}",
"skip_compaction": false,
"remote_type": "esx5",
"remote_host": "{{user `remote_vm_host`}}",
"remote_datastore": "{{user `remote_vm_datastore`}}",
"remote_username": "{{user `remote_usr`}}",
"remote_password": "{{user `remote_passwd`}}",
"tools_upload_flavor": "windows",
"vnc_port_min": 5900,
"vnc_port_max": 5990,
"vnc_disable_password": true,
"vmx_data": {
"firmware": "efi",
"scsi0.virtualDev": "lsisas1068",
"RemoteDisplay.vnc.enabled": "true",
"RemoteDisplay.vnc.port": "5900",
"ethernet0.networkName": "VM Network 401",
"ethernet0.addressType": "static",
"ethernet0.address": "00:50:56:13:3F:39",
"ethernet0.present": "true"
}
}
],
"provisioners": [
{
"type": "powershell",
"pause_before": "60s",
"elevated_user": "{{user `winrm_usr`}}",
"elevated_password": "{{user `winrm_passwd`}}",
"scripts": [
"scripts/LX_Install_VMTools_x64.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout":"10m"
},
{
"type": "powershell",
"pause_before": "60s",
"elevated_user": "{{user `winrm_usr`}}",
"elevated_password": "{{user `winrm_passwd`}}",
"scripts": [
"scripts/LX_Install_dotNET462.ps1",
"scripts/LX_Configure_WSUS.ps1",
"scripts/LX_Install_Chef.ps1",
"scripts/LX_Disable_Old_TLS.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout":"60m"
},
{
"type": "file",
"pause_before": "60s",
"source": "./scripts/LX_Post_Config_2019.ps1",
"destination":"C:/Windows/Temp/LX_Post_Config_2019.ps1"
},
{
"type": "file",
"source": "./files/LX_InputLocale.xml",
"destination":"C:/Windows/Temp/LX_InputLocale.xml"
},
{
"type": "file",
"source": "./files/gemrc",
"destination":"C:/ProgramData/gemrc"
},
{
"type": "windows-restart",
"restart_timeout":"60m"
},
{
"type": "windows-update",
"search_criteria": "IsInstalled=0",
"filters": [
"exclude:$_.Title -like '*Preview*'",
"include:$true"
],
"update_limit": 60
},
{
"type": "windows-restart",
"pause_before": "10m",
"restart_timeout":"30m"
},
{
"type": "powershell",
"pause_before": "180s",
"scripts": [
"scripts/LX_Final_Config.ps1"
]
}
]
}
Correct run (only the windows-update part):
14:40:07 ==> Standard: Machine successfully restarted, moving on
14:40:07 ==> Standard: Uploading the Windows update elevated script...
14:40:08 ==> Standard: Uploading the Windows update check for reboot required elevated script...
14:40:15 ==> Standard: Uploading the Windows update script...
14:40:20 ==> Standard: Running Windows update...
14:40:35 Standard: Searching for Windows updates...
14:41:43 Standard: Waiting for operation to complete (system performance: 29% cpu; 18% memory)...
14:42:50 Standard: Waiting for operation to complete (system performance: 53% cpu; 19% memory)...
14:43:05 Standard: Found Windows update (2019-05-15; 12.54 MB): Microsoft Silverlight (KB4481252)
14:43:05 Standard: Found Windows update (2020-05-15; 29.96 MB): Windows Malicious Software Removal Tool x64 - v5.82 (KB890830)
14:43:05 Standard: Found Windows update (2020-05-15; 71.56 MB): 2020-05 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB4556441)
14:43:05 Standard: Found Windows update (2020-05-15; 329.74 MB): 2020-05 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4551853)
14:43:05 Standard: Found Windows update (2020-04-27; 2.34 MB): 2020-01 Update for Windows Server 2019 for x64-based Systems (KB4494174)
14:43:05 Standard: Downloading Windows updates (5 updates; 446.15 MB)...
14:43:52 Standard: Waiting for operation to complete (system performance: 0% cpu; 16% memory)...
14:44:18 Standard: Installing Windows updates...
14:44:57 Standard: Waiting for operation to complete (system performance: 51% cpu; 18% memory)...
14:46:04 Standard: Waiting for operation to complete (system performance: 21% cpu; 20% memory)...
14:47:01 Standard: Waiting for operation to complete (system performance: 23% cpu; 20% memory)...
14:48:08 Standard: Waiting for operation to complete (system performance: 22% cpu; 27% memory)...
14:49:04 Standard: Waiting for operation to complete (system performance: 43% cpu; 30% memory)...
14:50:12 Standard: Waiting for operation to complete (system performance: 57% cpu; 31% memory)...
14:51:08 Standard: Waiting for operation to complete (system performance: 34% cpu; 32% memory)...
14:52:16 Standard: Waiting for operation to complete (system performance: 28% cpu; 33% memory)...
14:53:12 Standard: Waiting for operation to complete (system performance: 33% cpu; 35% memory)...
14:54:20 Standard: Waiting for operation to complete (system performance: 85% cpu; 36% memory)...
14:55:27 Standard: Waiting for operation to complete (system performance: 74% cpu; 38% memory)...
14:56:23 Standard: Waiting for operation to complete (system performance: 68% cpu; 39% memory)...
14:57:31 Standard: Waiting for operation to complete (system performance: 81% cpu; 39% memory)...
14:58:27 Standard: Waiting for operation to complete (system performance: 35% cpu; 37% memory)...
14:59:35 Standard: Waiting for operation to complete (system performance: 68% cpu; 34% memory)...
15:00:13 Standard: Waiting for the Windows Modules Installer to exit...
15:00:28 Standard: Waiting for operation to complete (system performance: 1% cpu; 30% memory)...
15:01:36 Standard: Waiting for operation to complete (system performance: 0% cpu; 30% memory)...
15:02:32 Standard: Waiting for operation to complete (system performance: 1% cpu; 27% memory)...
15:02:32 ==> Standard: Restarting the machine...
Wrong (current) run:
10:54:17 ==> Standard: Machine successfully restarted, moving on
10:54:17 ==> Standard: Uploading the Windows update elevated script...
10:54:24 ==> Standard: Uploading the Windows update check for reboot required elevated script...
10:54:30 ==> Standard: Uploading the Windows update script...
10:54:35 ==> Standard: Running Windows update...
10:54:50 Standard: Searching for Windows updates...
10:55:46 Standard: Waiting for operation to complete (system performance: 25% cpu; 20% memory)...
10:55:54 ==> Standard: Pausing 3m0s before the next provisioner...
10:59:01 ==> Standard: Provisioning with Powershell...
10:59:01 ==> Standard: Provisioning with powershell script: scripts/LX_Final_Config.ps1
As You can see, within the previous run, the status was correctly display by the plugin, the update process took about 42 minutes. Recently the provisioner won't display what's going on behind the scenes, simply after half an minute, goes to the next provisioner.
Thanks a lot for help me troubleshoot the problem. Mariusz
Its a known bug that sometimes manifests itself. Essentially, something seems to be disconnecting the WinRM connection (or restarting it), and this provider is not detecting that, so it just continues. Feel free to submit a PR :-)