hashicorp / packer-plugin-azure

Packer plugin for Azure Virtual Machine Image Builders
https://www.packer.io/docs/builders/azure
Mozilla Public License 2.0
51 stars 80 forks source link

Packer encounters "Error uploading ps script containing env vars" during the powershell provisioner step #61

Open ghost opened 3 years ago

ghost commented 3 years ago

This issue was originally opened by @sagilson as hashicorp/packer#10357. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

An azure customer is attempting to use the Azure Image Builder service to create a Windows 2004 19h2-evd image that includes only windows update and windows restart. Azure Image Builder uses packer and the azure-arm builder to create images. During the powershell provisioning step, packer is unable to upload a powershell script that contains environment variables, causing packer to fail the image build.

Reproduction Steps

Attempt to create a Windows 2004 19h2-evd image with windows update and restart using either the Azure Image Builder service or packer version with commit hash 5ddd02d1c0e5d8b1b0e2171d2d40c7d7b5641e68 (packer_1.6.1_linux_amd64).

Packer version

From packer version packer_1.6.1_linux_amd64

Also using v0.9.0 packer-provisioner-windows-update-linux.tgz

Simplified Packer Buildfile

Cannot post for security reasons as I do not own the template in question, but the customer has told me the template only contains base image Windows 2004 w/ sku 19h2-evd and the only customizers are windows update and restart.

Operating system and Environment details

Debian-like linux distro with more security patches and azure specific changes.

Log Fragments and crash.log files

[ec332261-ebd9-43ae-80d4-11cd378aad0b] PACKER ERR 2020/12/04 08:17:16 packer-provisioner-powershell plugin: Uploading env vars to c:/Windows/Temp/packer-ps-env-vars-5fc9e087-7e72-f676-6b03-871326abc66c.ps1 [ec332261-ebd9-43ae-80d4-11cd378aad0b] PACKER ERR 2020/12/04 08:17:16 packer-provisioner-powershell plugin: [INFO] 74 bytes written for 'uploadData' [ec332261-ebd9-43ae-80d4-11cd378aad0b] PACKER ERR 2020/12/04 08:17:16 [INFO] 74 bytes written for 'uploadData' [ec332261-ebd9-43ae-80d4-11cd378aad0b] PACKER ERR 2020/12/04 08:17:16 packer-builder-azure-arm plugin: Uploading file to 'c:/Windows/Temp/packer-ps-env-vars-5fc9e087-7e72-f676-6b03-871326abc66c.ps1' [ec332261-ebd9-43ae-80d4-11cd378aad0b] PACKER ERR 2020/12/04 08:28:49 packer-provisioner-powershell plugin: Retryable error: Error uploading ps script containing env vars: Error uploading file to $env:TEMP\winrmcp-2735b5fd-6a49-4753-71d9-0be9e8c8d7fd.tmp: Couldn't create shell: unknown error Post https:///wsman: EOF

jasmisbvb commented 2 years ago

I'm also facing the same issue have you got any clue on this issue

sagilson commented 2 years ago

I'm also facing the same issue have you got any clue on this issue

Unfortunately I am still hitting this issue and have not found any solutions. I'm fairly certain it is because WinRM is returning an error that the packer-plugin-azure cannot parse, thus the EOF.

lakshmigk01 commented 1 year ago

+1

koaminakligo-eaton commented 1 year ago

I am facing the same issue right now. I am trying to generate windows2019 image, but the build is failing with this error: Build 'azure-arm' errored after 2 hours 10 minutes: Error processing command: Error uploading ps script containing env vars: Error uploading file to $env:TEMP\winrmcp-5563337a-e32e-4ba4-50f7-986f0a0de02b.tmp: Couldn't create shell: http response error: 401 - invalid content type Has anyone found a solution to share with me? Thank you

ghost commented 2 months ago

I am facing the same issue right now. I am trying to generate windows2019 image, but the build is failing with this error: azure-arm.autogenerated_1: Error processing command: Error uploading ps script containing env vars: Error uploading file to $env:TEMP\winrmcp-1a677969-5c9c-4822-5551-5abc6a191d66.tmp: Couldn't create shell: http response error: 401 - invalid content type Has anyone found a solution to this case and can share it?