This Vagrant plugin allows you to standup Windows guests using WinRM instead of SSH on older versions of Vagrant.
Vagrant 1.6 will natively support Windows guests, this plugin should not be used with Vagrant 1.6 or later.
vagrant plugin install vagrant-windows
.vagrant plugin install vagrant-windows --plugin-version 0.1.2
.Supported Guest Operating Systems:
Windows Server 2003 and Windows XP are not supported by the maintainers of this project. Any issues regarding any unsupported guest OS will be closed. If you still insist on using XP or Server 2003, this may help.
You'll need to create a new Vagrant base box. Create a new Windows VM in VirtualBox, configure some Windows settings (see below) then follow the Vagrant packaging instructions.
These commands assume you're running from a regular command window and not PowerShell.
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
NOTE: For the WinRM service to work in Windows 7, the network profile has to be changed from Public to Work. To ensure that networks added later (i.e. through the Vagrantfile) also are made non-public, add the following to your Vagrantfile:
# Ensure that all networks are set to private
config.windows.set_work_network = true
These additional configuration steps are specific to Windows Server 2008 (WinRM 1.1). For Windows Server 2008 R2, Windows 7 and later versions of Windows you can ignore this section.
netsh firewall add portopening TCP 5985 "Port 5985"
winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
If you like to turn off optional Windows services you'll need to ensure you leave these services enabled for vagrant-windows to continue to work:
Add the following to your Vagrantfile
config.vm.guest = :windows
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
Example:
Vagrant.configure("2") do |config|
# Configure base box parameters
config.vm.box = "vagrant-windows2008r2"
config.vm.box_url = "./vagrant-windows2008r2.box"
config.vm.guest = :windows
# Port forward WinRM and RDP
config.vm.network :forwarded_port, guest: 3389, host: 3389
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
end
Available Config Parameters:
config.windows.halt_timeout
- How long Vagrant should wait for the guest to shutdown before forcing exit, defaults to 30 secondsconfig.windows.halt_check_interval
- How often Vagrant should check if the system has shutdown, defaults to 1 secondconfig.windows.set_work_network
- Force network adapters to "Work Network". Useful for Win7 guests using private networking.config.winrm.username
- The Windows guest admin user name, defaults to vagrant.config.winrm.password
- The above's password, defaults to vagrant.config.winrm.host
- The IP of the guest, but because we use NAT with port forwarding this defaults to localhost.config.winrm.guest_port
- The guest's WinRM port, defaults to 5985.config.winrm.port
- The WinRM port on the host, defaults to 5985. You might need to change this if your hosts is also Windows.config.winrm.max_tries
- The number of retries to connect to WinRM, defaults to 20.config.winrm.timeout
- The max number of seconds to wait for a WinRM response, defaults to 1800 seconds.Note - You need to ensure you specify a config.windows and a config.winrm in your Vagrantfile. Currently there's a problem where Vagrant will not load the plugin config even with defaults if at least one of its values doesn't exist in the Vagrantfile.
@{MaxMemoryPerShellMB="512"}
etc in single quotes:
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="512"}'
If all else fails try running vagrant with debug logging, perhaps that will give you enough insight to fix the problem or file an issue.
Clone this repository and use Bundler to get the dependencies:
$ bundle install
Once you have the dependencies, you can run the tests with rake
:
$ bundle exec rake spec
If those pass, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant environment by just creating a Vagrantfile in the top level of this directory (it is gitignored) that uses it, and use bundler to execute Vagrant:
$ bundle exec vagrant up
If you want to globally install your locally built plugin from source, use the following method (this would be for 1.2.0):
bundle install
bundle exec rake build
vagrant plugin install pkg/vagrant-windows-1.2.0.gem
Keep in mind you should have Ruby 1.9.3 and Ruby DevKit installed. Check out the following gist that can get you what you need (from blank system to fully ready): Install Vagrant Windows Plugin From Source Gist.