frapposelli / vagrant-vcloud

Vagrant provider for VMware vCloud Director®
MIT License
67 stars 38 forks source link

Fix WinRM provisioning problem of issue #65 #92

Closed StefanScherer closed 10 years ago

StefanScherer commented 10 years ago

Here is my bugfix for issue #65. Adding the WaitForCommunicator in the action_boot function seems to do it for both unix guests (they still work) and Windows guests running the WinRM communicator of Vagrant 1.6.

The WaitForCommunicator exists in Vagrant 1.5.1 (haven't looked in older versions), so this should be backward compatible.

My Jenkins created five windows boxes last night, only one of them still had a problem with WinRM. Restarting the job worked fine. But there still is an issue with that situation. The WaitForCommunicator connects to WinRM before the guest customization reboot, then the ssh_info connects to port 22 and then jumps into the rsync code and then the reboot happens.

Is there a way to read the VM guest state that the guest customization hasn't finished yet?

Another idea could be to try a communicator call to read eg. the computer name of the windows guest. If this is not the one in the GuestCustomization XML tags, then we still have to wait...

I have tried to upload the console output into this Gist https://gist.github.com/StefanScherer/d7469c9a1e88e592f140#file-part1-L10076 but the intense logging is too big for gists. In line 10076 the WaitForCommunicator seems to return and the "Waiting for WinRM Access" loop of the plugin begins. So if we find any information from the responses from vCloud to recognize that this windows VM still is not ready for WinRM could help the problem better.

But still it is a better than nothing improvement.

StefanScherer commented 10 years ago

This PR still sometimes has problems connecting to the VM too early while guest customization is still in progress (short before reboot).

I managed this problem with a trick in my packer-windows boxes. I close the WinRM port (by adding a blocking port firewall rule) when packer builds the vCloud base box and I add a boot script (done with a scheduled task) that checks for the host name. If the host name differs from "vagrant-*" as used by my packer builds, then it opens the WinRM port again (removing the blocking port firewall rule again) for the Vagrant WinRM communicator.