Winrm_host setting ignored?

Hello everyone, first time posting here,

so I’ve been working with packer and ansible for quite some time now and would consider myself somewhat experienced.

In my latest project, I am setting up a Windows10 VM in VirtualBox with ansible and packer. Unfortunately, now I am having some problems with the WinRM communicator.

In the past, I used a NAT adapter such that WinRM could connect via IP 127.0.0.1 - and everything worked just fine.
Now I tried to switch to a Host-only adapter, which of course results in the necessity to change the IP address to connect to with WinRM (no more NAT interface - use Host-only interface). After adding the winrm_host option to the packer script with the new correct IP (“192.168.X.X”) the packer script no longer builds successfully, but gets stuck in the “Waiting for WinRM to become available”-step resulting in a timeout.
The output of the script also says “Using winrm communicator to connect: 127.0.0.1” - so it does not use the IP address I specified in the packer script.
“Manually” connecting via a small python-script using pywinrm works like a charm.

I am using packer version v1.6.6.

Has anyone else experienced this problem and found a solution? I found some older issues in the github-repository stating that the winrm_host option seems to be completely ignored.

Thanks for any input and suggestions!

EDIT: Here are the links to the above-mentioned issues:

Hi, just to clarify – sounds like you are not at a point where you’re even able to launch the ansible provisioner; this is a failure of the packer winrm communicator to connect, not a failure of the ansible provisioner to connect?

Hi. Yes, this is a failure of the packer WinRM communicator - not ansible. The failure occurs after the “basic” setup of the VM, where for other OSs the SSH connection is established next (WinRM in this case).

I am just asking in case anyone else had the same problem or maybe managed to get this to work? Basically, I just want to connect to a VM using the WinRM communicator of packer. I will try to add some basic examples to reproduce the problem. Thanks!

No need; I can reproduce. I think this is a bug in the virtualbox builder. I’ll add “virtualbox” to the issue in WinRm Communicator times out without winrm_host setting · Issue #6140 · hashicorp/packer · GitHub

What happens if you set skip_nat_mapping to true?

Turns out that’s not enough. Can you share the config you’re trying to get working on that linked issue? I’ll try to schedule some time to fix this.

1 Like