Closed rgl closed 6 years ago
Forgot to include relevant packer log lines.
Here, while it cannot connect to WinRM it sucessfully retries and outputs these types of messages
2018/04/26 19:47:56 packer-builder-vsphere-iso.exe: 2018/04/26 19:47:56 [INFO] Attempting WinRM connection...
2018/04/26 19:47:56 packer-builder-vsphere-iso.exe: 2018/04/26 19:47:56 [DEBUG] connecting to remote shell using WinRM
2018/04/26 19:47:56 packer-builder-vsphere-iso.exe: 2018/04/26 19:47:56 [ERROR] connection error: http response error: 401 - invalid content type
2018/04/26 19:47:56 packer-builder-vsphere-iso.exe: 2018/04/26 19:47:56 [ERROR] WinRM connection err: http response error: 401 - invalid content type
And finally, when WinRM is finally configured in the VM, it starts to output these errors:
2018/04/26 19:48:01 packer-builder-vsphere-iso.exe: 2018/04/26 19:48:01 [INFO] Attempting WinRM connection...
2018/04/26 19:48:01 packer-builder-vsphere-iso.exe: 2018/04/26 19:48:01 [DEBUG] connecting to remote shell using WinRM
2018/04/26 19:48:02 packer-builder-vsphere-iso.exe: 2018/04/26 19:48:02 [ERROR] connection error: Malformed XML file
2018/04/26 19:48:02 packer-builder-vsphere-iso.exe: 2018/04/26 19:48:02 [ERROR] WinRM connection err: Malformed XML file
I'm not sure why its failing, because the XML from the packet capture seems correct.
Isn't https://github.com/jetbrains-infra/packer-builder-vsphere/blob/808a7ce57d77ecc4e988d11049e52efe17b5e4d0/iso/builder.go#L71 missing to set WinRMConfig
? Or is WinRM still not supported in the latest multistep support added to this plugin?
BTW, with packer-builder-vsphere v2.0-beta4 it works fine. This issue is just about the master version.
with packer-builder-vsphere v2.0-beta4 it works fine
That's strange because nothing has changed around 'StepConnect' except updated Packer dependency. Will investigate further.
missing to set WinRMConfig?
WinRMConfig
is optional and could be omitted. winrm_username
and winrm_password
would be used in that case.
Some search into packer issues and looking into code shows that error message is a bit incorrect, what's most probably happening is that Windows machine responds with 401 Unauthorized
and some plain text. I'll submit pull request into winrm connector library with proper error message.
Please check that there's basic authentication enabled on machine and username and password specified in packer config.
I may have the same issue. Also building Windows 2016. Winrm was working fine for me with v2.0-beta4. My winrm config: in addition to specifying the username and password, I included the "winrm_use_ntlm": "true" line and set winrm "allowunencrypted" to true (did not set auth to basic and this is what worked with the beta consistently). As soon as I switched to the master version, it stopped working.
@VladRassokhin winrm is correctly configured (supports basic authentication and non-encrypted connections) and works fine on the vm as you can see by the manual use of winrm-cli (the same winrm code that packer uses) that I've mentioned in this issue:
Note that manually using the winrm command (from https://github.com/masterzen/winrm-cli) it works fine:
winrm -username vagrant -password vagrant -hostname 10.0.0.177 -port 5985 whoami vagrant-4e4futn\vagrant
In case you need to test, my packer template and supporting scripts for creating a base Windows 2016 image are at https://github.com/rgl/windows-2016-vagrant/tree/vsphere (in the vsphere
branch).
I've confirmed the issue. ~So far it looks like a regression in Packer 1.2 we started using recently~.
I believe I've fixed that.
winrm
library has switched XML parser in https://github.com/masterzen/winrm/pull/73.
The new parser rejects XML documents without <?xml version="1.0" ?>
header.
My fork disables the validation, but we still need to open PR there.
No need for PRs. Just need to import a fresh revision of ChrisTrenkamp/goxpath
For some reason the packer build gets stuck in the
Waiting for WinRM to become available
phase:Doing a packet capture, its stuck sending these http requests:
That message is the first winrm message to start a shell, but packer never seems to send a command to that shell... any idea why?
Note that manually using the winrm command (from https://github.com/masterzen/winrm-cli) it works fine:
I'm using the latest packer-builder-vsphere-iso.exe binary from https://teamcity.jetbrains.com/viewLog.html?buildId=1404924&buildTypeId=PackerVSphere_Build&tab=artifacts (build 29 from git revision https://github.com/jetbrains-infra/packer-builder-vsphere/commit/1d61fa430b67693b97f10f25ad7edca0d57028c5)