Closed
Description
Host OS | OS X, Windows 10 Enterprise |
---|---|
Guest OS | Windows 10 Enterprise |
Vagrant | 1.7.4 |
VirtualBox | 5.0.4 |
Provider | virtualbox |
Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "custom"
config.vm.guest = :windows
config.vm.communicator = "winrm"
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.winrm.max_tries = 20
config.vm.network :forwarded_port, guest: 3389, host: 3389
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
config.vm.provider "virtualbox" do |vb|
vb.name = "custom"
vb.gui = true
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--vram", "256"]
end
config.vm.provision :shell, path: "./ps/Install-Chocolatey.ps1"
config.vm.provision :shell, path: "./ps/InstallApps.ps1"
end
Preparation:
- Firewall is turned off on host and guest machines, anyway ports were opened manually:
netsh advfirewall firewall add rule name="5985" dir=in action=allow protocol=TCP localport=5985
netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=TCP localport=3389
- Enabled private networking :
Set-NetConnectionProfile -InterfaceAlias Ethernet -NetworkCategory Private
- WinRM service and client configured next way:
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
sc config "WinRM" start=auto
Export:
$path = "F:\custom"
vagrant package --base custom --output $path/custom.box --vagrantfile $path/Vagrantfile
vagrant box add custom.box --name custom
Result:
F:\custom> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'custom.box'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: custom_default_1445570609823_89912
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 3389 => 3389 (adapter 1)
default: 5985 => 5985 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: WinRM address: 127.0.0.1:5985
default: WinRM username: vagrant
default: WinRM transport: plaintext
An error occurred executing a remote WinRM command.
Shell: powershell
Command: hostname
if ($?) { exit 0 } else { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1
} }
Message: HTTPClient::KeepAliveDisconnected: An existing connection was forcibly
closed by the remote host.
vagrant up
on Windows host : https://gist.github.com/mskutin/3c57928ff608f8ad7991
vagrant up
on OS X host : https://gist.github.com/mskutin/fad15bba67032b6f7745
The VM is starting but WinRM is unable to connect due to exception above.