box-cutter/windows-vm — pull request #10 by StefanScherer (2014-05-19 14:25:17+00:00)
Title: cleared some vagrant-windows keywords, add ssh port forwarding

I have removed some keywords that have been used by the vagrant-windows plugin.
The template vagrantfiles already have the `config.vm.communicator = "winrm"` to use Vagrants new winrm communicator. So it is time to cleanup such old keywords and users then don't need to install the vagrant-windows plugin.

But as the OpenSSH or Cygwin sshd are installed and keep installed after building the base box, we also should add the SSH port forwarding. Vagrant 1.6.2 with winrm communicator only auto forwards the winrm port 5985, but no longer the ssh port 22.
So it is useful to add the port forwarding in the base boxes that still have a windows SSH service running.

For future boxes without a windows SSH service, the ssh port forwarding could be removed.

A small test with a Windows 7 Enterprise works fine without the vagrant-vcloud plugin and only using Vagrant 1.6.2 with VirtualBox 4.3.10.

My sample Vagrantfile is this, I could have skipped the winrm line. The network will be set to work network with Vagrant 1.6.2. Everything looks fine.

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

VAGRANTFILE_API_VERSION = "2"

Vagrant.require_version ">= 1.6.0"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "win7x64-enterprise"
config.vm.hostname = "win7"
config.vm.communicator = "winrm"
config.vm.network :private_network, ip: "192.168.33.237"

config.vm.provider :virtualbox do |vb|
vb.gui = true
vb.customize ["modifyvm", :id, "--memory", 768]
vb.customize ["modifyvm", :id, "--cpus", 1]
vb.customize ["modifyvm", :id, "--vram", "32"]
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end

config.vm.provision "shell", path: "provision.ps1"
end
```

And the shell provision.ps1 script is this:

```ps1
Write-Host This is computer $env:COMPUTERNAME
```

```
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'win7x64-enterprise'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: tst_default_1400508530827_18902
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 3389 => 3389 (adapter 1)
default: 5985 => 5985 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => /Users/stefan/code/vpn/tst
==> default: Running provisioner: shell...
default: Running: c:\tmp\vagrant-shell.ps1
==> default: This is computer WINDOWS-AHN8UJX
```

The hostname is changed by vagrant, but the guest needs a reboot to finally have the hostname from the Vagrantfile.