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.03k stars 3.32k forks source link

Error uploading script: Error uploading file to $env:TEMP\winrmcp-4688e2bf-c603-4d8a-6b02-15439b814a2b.tmp: Couldn't create shell: http response error: 401 - invalid content type #12115

Open krishnaps7 opened 1 year ago

krishnaps7 commented 1 year ago

Using below provisioner:

provisioner "windows-shell" {
    inline = [
    "reg add HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\ /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f", 
    "reg add HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\ /v lmcompatibilitylevel /t REG_DWORD /d 0 /f"]
  }

This provisioner was working before, last used on Sep 1st 2022. But this time it ended up in error as below

06:19   2022/11/11 06:06:19 [INFO] (telemetry) Starting provisioner windows-shell
build   11-Nov-2022 06:06:19    1668146779,,ui,say,==> googlecompute: Provisioning with windows-shell...
build   11-Nov-2022 06:06:19    1668146779,,ui,say,==> googlecompute: Provisioning with shell script: /tmp/windows-shell-provisioner824394215
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 1668146779,,ui,say,==> googlecompute: Provisioning with windows-shell...
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 packer-provisioner-windows-shell plugin: Found command: reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 packer-provisioner-windows-shell plugin: Found command: reg add HKLM\SYSTEM\CurrentControlSet\Control\Lsa\ /v lmcompatibilitylevel /t REG_DWORD /d 0 /f
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 1668146779,,ui,say,==> googlecompute: Provisioning with shell script: /tmp/windows-shell-provisioner824394215
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 packer-provisioner-windows-shell plugin: Opening /tmp/windows-shell-provisioner824394215 for reading
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 packer-provisioner-windows-shell plugin: [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:19    2022/11/11 06:06:19 packer-builder-googlecompute plugin: Uploading file to 'c:/Windows/Temp/script.bat'
error   11-Nov-2022 06:06:20    2022/11/11 06:06:20 packer-provisioner-windows-shell plugin: Retryable error: Error uploading script: Error uploading file to $env:TEMP\winrmcp-2c94e073-0167-4cc0-5493-b16e8a3eb607.tmp: Couldn't create shell: http response error: 401 - invalid content type
error   11-Nov-2022 06:06:22    2022/11/11 06:06:22 packer-provisioner-windows-shell plugin: [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:22    2022/11/11 06:06:22 [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:22    2022/11/11 06:06:22 packer-builder-googlecompute plugin: Uploading file to 'c:/Windows/Temp/script.bat'
error   11-Nov-2022 06:06:22    2022/11/11 06:06:22 packer-provisioner-windows-shell plugin: Retryable error: Error uploading script: Error uploading file to $env:TEMP\winrmcp-366550f4-484e-4e16-404b-c9307a8218f3.tmp: Couldn't create shell: http response error: 401 - invalid content type
error   11-Nov-2022 06:06:24    2022/11/11 06:06:24 packer-provisioner-windows-shell plugin: [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:24    2022/11/11 06:06:24 [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:24    2022/11/11 06:06:24 packer-builder-googlecompute plugin: Uploading file to 'c:/Windows/Temp/script.bat'
error   11-Nov-2022 06:06:25    2022/11/11 06:06:25 packer-provisioner-windows-shell plugin: Retryable error: Error uploading script: Error uploading file to $env:TEMP\winrmcp-21902a91-b048-48d0-6b09-6edfa9a150c7.tmp: Couldn't create shell: http response error: 401 - invalid content type
error   11-Nov-2022 06:06:27    2022/11/11 06:06:27 packer-provisioner-windows-shell plugin: [INFO] 222 bytes written for 'uploadData'
error   11-Nov-2022 06:06:27    2022/11/11 06:06:27 [INFO] 222 bytes written for 'uploadData'

Packer version used: Packer v1.8.4

arizvisa commented 1 year ago

If it's not related to winrmcp (which is dying for a maintainer as per packer-community/winrmcp#38), it might be related to masterzen/winrm#75 which describes an issue with auth that might be worth trying.

krishnaps7 commented 1 year ago

@arizvisa thanks for response. Any alternative provisioner we can use for this reg commands executions on windows?