Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinRM connection err: http response error: 401 - invalid content type #10088

Closed
sferguson524 opened this issue Oct 12, 2020 · 3 comments
Closed

Comments

@sferguson524
Copy link

sferguson524 commented Oct 12, 2020

Doing an automated template build for windows 2019 on VMware, and getting the above referenced error. Below is the output from my packer log.

2020/10/12 14:55:11 [INFO] Packer version: 1.6.4 [go1.15.2 windows amd64]
2020/10/12 14:55:11 Checking 'PACKER_CONFIG' for a config file path
2020/10/12 14:55:11 'PACKER_CONFIG' not set; checking the default config file path
2020/10/12 14:55:11 Attempting to open config file: C:\Users\sa-steve.ferguson\AppData\Roaming\packer.config
2020/10/12 14:55:11 [WARN] Config file doesn't exist: C:\Users\sa-steve.ferguson\AppData\Roaming\packer.config
2020/10/12 14:55:11 Setting cache directory: C:\packer\packer_cache
cannot determine if process is in background: Process background check error: not implemented yet
2020/10/12 14:55:11 Creating plugin client for path: C:\packer\packer.exe
2020/10/12 14:55:11 Starting plugin: C:\packer\packer.exe []string{"C:\\packer\\packer.exe", "plugin", "packer-builder-vsphere-iso"}
2020/10/12 14:55:11 Waiting for RPC address for: C:\packer\packer.exe
2020/10/12 14:55:11 packer.exe plugin: [INFO] Packer version: 1.6.4 [go1.15.2 windows amd64]
2020/10/12 14:55:11 packer.exe plugin: Checking 'PACKER_CONFIG' for a config file path
2020/10/12 14:55:11 packer.exe plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/10/12 14:55:11 packer.exe plugin: Attempting to open config file: C:\Users\sa-steve.ferguson\AppData\Roaming\packer.config
2020/10/12 14:55:11 packer.exe plugin: [WARN] Config file doesn't exist: C:\Users\sa-steve.ferguson\AppData\Roaming\packer.config
2020/10/12 14:55:11 packer.exe plugin: Setting cache directory: C:\packer\packer_cache
2020/10/12 14:55:11 packer.exe plugin: args: []string{"packer-builder-vsphere-iso"}
2020/10/12 14:55:11 packer.exe plugin: Plugin port range: [10000,25000]
2020/10/12 14:55:11 packer.exe plugin: Plugin address: tcp 127.0.0.1:10000
2020/10/12 14:55:11 Received tcp RPC address for C:\packer\packer.exe: addr is 127.0.0.1:10000
2020/10/12 14:55:11 packer.exe plugin: Waiting for connection...
2020/10/12 14:55:11 packer.exe plugin: Serving a plugin connection...
2020/10/12 14:55:11 Preparing build: vsphere-iso
2020/10/12 14:55:11 ui: vsphere-iso: output will be in this color.
2020/10/12 14:55:11 ui: 
2020/10/12 14:55:11 Build debug mode: false
2020/10/12 14:55:11 Force build: false
2020/10/12 14:55:11 On error: 
2020/10/12 14:55:11 Waiting on builds to complete...
2020/10/12 14:55:11 Starting build run: vsphere-iso
2020/10/12 14:55:11 Running builder: vsphere-iso
2020/10/12 14:55:11 [INFO] (telemetry) Starting builder vsphere-iso
2020/10/12 14:55:12 packer.exe plugin: No URLs were provided to Step Download. Continuing...
2020/10/12 14:55:12 packer.exe plugin: No CD files specified. CD disk will not be made.
2020/10/12 14:55:12 ui: ==> vsphere-iso: Creating VM...
2020/10/12 14:55:15 ui: ==> vsphere-iso: Customizing hardware...
2020/10/12 14:55:16 ui: ==> vsphere-iso: Mounting ISO images...
2020/10/12 14:55:16 packer.exe plugin: Check if ISO path is a Content Library path
2020/10/12 14:55:16 packer.exe plugin: ISO path not identified as a Content Library path
2020/10/12 14:55:16 packer.exe plugin: Using [ams-global-templates] _ISO/Server2019.ISO as the datastore path
2020/10/12 14:55:16 packer.exe plugin: Creating CD-ROM on controller '&{{{} 200 0xc001266180 <nil> <nil> <nil> 0 <nil>} 0 []}' with iso '[ams-global-templates] _ISO/Server2019.ISO'
2020/10/12 14:55:17 packer.exe plugin: Check if ISO path is a Content Library path
2020/10/12 14:55:18 packer.exe plugin: ISO path not identified as a Content Library path
2020/10/12 14:55:18 packer.exe plugin: Using [] /vmimages/tools-isoimages/windows.iso as the datastore path
2020/10/12 14:55:18 packer.exe plugin: Creating CD-ROM on controller '&{{{} 200 0xc0012c2440 <nil> <nil> <nil> 0 <nil>} 0 [3000]}' with iso '[] /vmimages/tools-isoimages/windows.iso'
2020/10/12 14:55:19 ui: ==> vsphere-iso: Adding configuration parameters...
2020/10/12 14:55:19 ui: ==> vsphere-iso: Creating floppy disk...
2020/10/12 14:55:19 packer.exe plugin: Floppy path: C:\Users\SA-STE~1.FER\AppData\Local\Temp\2\packer978627023
2020/10/12 14:55:19 packer.exe plugin: Initializing block device backed by temporary file
2020/10/12 14:55:19 packer.exe plugin: Formatting the block device with a FAT filesystem...
2020/10/12 14:55:19 packer.exe plugin: Initializing FAT filesystem on block device
2020/10/12 14:55:19 packer.exe plugin: Reading the root directory from the filesystem
2020/10/12 14:55:19 ui:     vsphere-iso: Copying files flatly from floppy_files
2020/10/12 14:55:19 ui:     vsphere-iso: Copying file: ./windows/autounattend.xml
2020/10/12 14:55:19 ui:     vsphere-iso: Copying file: ./scripts/install-vm-tools.cmd
2020/10/12 14:55:19 ui:     vsphere-iso: Copying file: ./scripts/setup.ps1
2020/10/12 14:55:19 ui:     vsphere-iso: Done copying files from floppy_files
2020/10/12 14:55:19 ui:     vsphere-iso: Collecting paths from floppy_dirs
2020/10/12 14:55:19 ui:     vsphere-iso: Resulting paths from floppy_dirs : []
2020/10/12 14:55:19 ui:     vsphere-iso: Done copying paths from floppy_dirs
2020/10/12 14:55:19 ui: ==> vsphere-iso: Uploading created floppy image
2020/10/12 14:55:20 ui: ==> vsphere-iso: Adding generated Floppy...
2020/10/12 14:55:21 ui: ==> vsphere-iso: Adding Floppy image...
2020/10/12 14:55:22 ui: ==> vsphere-iso: Set boot order temporary...
2020/10/12 14:55:22 ui: ==> vsphere-iso: Power on VM...
2020/10/12 14:55:23 packer.exe plugin: [INFO] Waiting for IP, up to total timeout: 30m0s, settle timeout: 5s
2020/10/12 14:55:23 ui: ==> vsphere-iso: Waiting for IP...
2020/10/12 15:07:30 packer.exe plugin: VM IP aquired: Our IP Address
2020/10/12 15:07:31 packer.exe plugin: VM IP is still the same: Our IP Address
2020/10/12 15:07:33 packer.exe plugin: VM IP is still the same: Our IP Address
2020/10/12 15:07:35 packer.exe plugin: VM IP is still the same: Our IP Address
2020/10/12 15:07:36 packer.exe plugin: VM IP is still the same: Our IP Address
2020/10/12 15:07:36 packer.exe plugin: VM IP seems stable enough: Our IP Address
2020/10/12 15:07:36 ui: ==> vsphere-iso: IP address: Our IP Address
2020/10/12 15:07:36 ui: ==> vsphere-iso: Using winrm communicator to connect: Our IP Address
2020/10/12 15:07:36 packer.exe plugin: Waiting for WinRM, up to timeout: 30m0s
2020/10/12 15:07:36 ui: ==> vsphere-iso: Waiting for WinRM to become available...
2020/10/12 15:07:36 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:07:36 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:07:37 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:07:37 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:07:42 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:07:42 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:07:42 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:07:42 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:07:47 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:07:47 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:07:47 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:07:47 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:07:52 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:07:52 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:07:52 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:07:52 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:07:57 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:07:57 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:07:57 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:07:57 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:03 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:03 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:03 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:03 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:08 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:08 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:08 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:08 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:13 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:13 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:13 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:13 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:18 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:18 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:18 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:18 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:23 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:23 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:24 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:24 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:29 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:29 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:29 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:29 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:34 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:34 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:34 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:34 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type
2020/10/12 15:08:39 packer.exe plugin: [INFO] Attempting WinRM connection...
2020/10/12 15:08:39 packer.exe plugin: [DEBUG] connecting to remote shell using WinRM
2020/10/12 15:08:39 packer.exe plugin: [ERROR] connection error: http response error: 401 - invalid content type
2020/10/12 15:08:39 packer.exe plugin: [ERROR] WinRM connection err: http response error: 401 - invalid content type

@SwampDragons
Copy link
Contributor

Thanks for opening an issue -- to help you, we really do need the things requested in the issue template, including:

The simplest complete example template and scripts needed to reproduce the bug. Include these in your gist https://gist.github.com

In your case that means we need to know what your autounattend looks like or how you're setting up WinRM.

Often this error crops up when WinRM is not properly configured, or your packer template isn't setting the correct WinRM settings. Check your password, whether WinRM on your guest is configured to use http or https, make sure the ports are right, check whether WinRM on your guest expects ntlm, etc. For some working Packer+ WinRM examples, check out https://github.com/StefanScherer/packer-windows/tree/main/answer_files.

If you're struggling to get Packer working for the first time, I'd recommend reaching out to the community forum for help, since more people read that forum than read the issue tracker on GitHub. this issue tracker is generally reserved for bugs, not configuration questions.

Thanks!

@nywilken
Copy link
Contributor

Closing since there have been no updates to the issue. If you believe this is still an issue please open a new bug issue with the information requested in the template.

@valipop1
Copy link

valipop1 commented Jan 6, 2025

I was struggling with this few days...
I want to update an existing image in azure image gallery, just install lates windows updates.
While packer was stuck on "Waiting for WinRM to become available", I RDP to the temporary VM, it created, and run the following:
winrm quickconfig
Enable-PSRemoting -Force
winrm set winrm/config/service '@{AllowUnencrypted = "true"}'
winrm set winrm/config/service/auth '@{Basic = "true"}'
Then, Packer connected to the VM and continued the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants