hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

Guest-specific operations were attempted on a machine that is not ready for guest communication #5352

Closed spuder closed 9 years ago

spuder commented 9 years ago

While attempting to provision a windows VM, it gave the following errors

Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.
sowens-MBP:ND-iis sowen$ vagrant provision
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'ND-Webserver2012' from source at .
==> default: Using ND-Webserver2012 (0.1.0) from source at .
==> default: Using iis (3.0.12) from https://github.com/opscode-cookbooks/iis.git (at master)
==> default: Using chef_handler (1.1.6)
==> default: Using windows (1.36.1)
==> default: Vendoring ND-Webserver2012 (0.1.0) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150213-2877-9rn1mi-default/ND-Webserver2012
==> default: Vendoring chef_handler (1.1.6) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150213-2877-9rn1mi-default/chef_handler
==> default: Vendoring iis (3.0.12) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150213-2877-9rn1mi-default/iis
==> default: Vendoring windows (1.36.1) to /Users/sowen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150213-2877-9rn1mi-default/windows
==> default: Running provisioner: shell...
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.

If I run with debugging info, this is what it shows

vagrant provision --debug
...
GuestAdditionsFacility_Seamless Mode=0,1423864457084
GuestAdditionsFacility_Graphics Mode=0,1423864457083
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
DEBUG virtualbox_4_3:   - [1, "ssh", 2222, 22]
DEBUG virtualbox_4_3:   - [1, "tcp1234", 1234, 3389]
DEBUG virtualbox_4_3:   - [1, "winrm", 55985, 5985]
DEBUG winrmshell: initializing WinRMShell
DEBUG winrmshell: powershell executing:
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
 INFO winrmshell: Attempting to connect to WinRM...
 INFO winrmshell:   - Host: 127.0.0.1
 INFO winrmshell:   - Port: 55985
 INFO winrmshell:   - Username: vagrant
 INFO retryable: Retryable exception raised: #<WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (401).>
DEBUG winrmshell: powershell executing:
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
 INFO retryable: Retryable exception raised: #<WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (401).>
DEBUG winrmshell: powershell executing:
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
 INFO retryable: Retryable exception raised: #<WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (401).>
DEBUG winrmshell: powershell executing:
hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }
 INFO retryable: Retryable exception raised: #<WinRM::WinRMHTTPTransportError: Bad HTTP response returned from server (401).>
DEBUG winrmshell: powershell executing:
hostname

Here is the full vagrant file

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(2) do |config|
  config.vm.box = "lmayorga1980/windows-2012r2"
  config.vm.communicator = "winrm"
  config.vm.guest = :windows

  # To prevent conflicts with other windows VMs, the RDP port has been changed to 1234
  # To Connect, RDP to 127.0.0.1:1234

  config.vm.network "forwarded_port", host: 1234, guest: 3389
  config.vm.provider "virtualbox" do |v|
    v.cpus = 2
    v.memory = 2048
  end

# Provisioning

  config.vm.provision 'shell', path: 'NDJoinLabDomain.ps1'
  config.vm.provision :reload
  config.vm.provision 'shell', inline: 'gpupdate.exe /force'

  config.vm.provision 'shell', path: 'InstallChocolatey.ps1'
  config.vm.provision 'shell', inline: 'choco install -y chef-client'
  config.vm.provision 'shell', inline: 'Add-WindowsFeature Web-Server'
  config.vm.provision 'shell', inline: 'Add-WindowsFeature Web-Mgmt-Console'

  config.vm.provision "chef_solo" do |chef|
    chef.add_recipe "ND-Webserver2012"
  end
end

I'm not sure how to reproduce this, but I suspect it has something to do with the following things that I did.

mitchellh commented 9 years ago

Please reproduce this without plugins, and we'll take a look! Sorry but we have to narrow the repro case down to get one.

spuder commented 9 years ago

I reproduced this again, it is caused by adding a machine to active directory. This causes the Vagrant user to loose administrative privileges. Without local administrative privileges, the vagrant user can not execute winRM.

I've sort of worked around the issue by running the following command to add vagrant back to the local administrators group.

   config.vm.provision 'shell', inline: 'net localgroup administrators vagrant /add'