Commit 4635be6d authored by Ken Sykora's avatar Ken Sykora

Merge pull request #95 from joefitzgerald/develop

1.21 Release - Develop Merge into Master
parents 24866782 a61632d5
## v1.21 (Aug 6th, 2014)
* Added rsync.bat as an optional script to include rsync capabilities to the vagrant box (#88)
* RDP now enabled for use with vagrant (#75)
## v1.20 (July 21st, 2014)
* Update Chocolatey script for Chocolatey 0.9.8.27
......
# How to enable RSync for Windows Templates
## Introduction
This document explains how to install RSync into the Windows boxes to be able to use Vagrant's synced folder type `rsync`. Read the [Vagrant Docs](https://docs.vagrantup.com/v2/synced-folders/rsync.html) for more details and the additional vagrant commands.
## Prerequisites
### SSH
To use `rsync` in the Windows boxes you also will need that SSH is installed and enabled. At the time of writing OpenSSH will always be installed to make the packer build work. This is part of the `Autounattend.xml` answer files.
In the future SSH might disappear from default installation as packer will be able to communicate through WinRM with the Windows box. For rsync you then have to add the `scripts/openssh.ps1` again to have OpenSSH up and running.
## Installation
To install `rsync` in the Windows boxes you have to add the `./scripts/rsync.bat` script to the packer template's shell provisioner scripts as shown in this example:
```json
"provisioners": [
{
"type": "shell",
"remote_path": "/tmp/script.bat",
"execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
"scripts": [
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat",
"./scripts/compile-dotnet-assemblies.bat",
"./scripts/rsync.bat",
"./scripts/compact.bat"
]
},
```
The script also creates a symlink so that the folder `/vagrant` could be used in the Vagrantfile to sync files to `C:\vagrant`. So the example from the Vagrant documentation works without any changes.
## Enable RSync in a Vagrantfile
The following is an example of using RSync to sync a folder into a Windows box. Please notice that we have to forward the SSH port as it will not be forwarded automatically at the moment.
```ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "windows_2012_r2"
config.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: ".git/"
config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", auto_correct: true
config.vm.provider "virtualbox" do |vb|
vb.gui = true
end
end
```
If you want to sync into another directory of the Windows box, use the Cygwin path prefix `/cygdrive/c` as shown in this example:
```ruby
config.vm.synced_folder '.', "/cygdrive/c/vagrant-rsync",
type: "rsync",
rsync__auto: "true",
rsync__exclude: [".git/",".vagrant/"],
id: "vagrant"
```
......@@ -79,11 +79,13 @@ If you have serious objections to OpenSSH being installed, you can always add an
* Build a base box using Packer
* Create a Vagrantfile, use the base box from Packer, connect to the VM via WinRM (using the [vagrant-windows](https://github.com/WinRb/vagrant-windows) plugin) and disable the 'sshd' service or uninstall OpenSSH completely
* Perform a Vagrant run and and output a .box file
* Perform a Vagrant run and output a .box file
### Using .box Files With Vagrant
If you are going to use the .box files produced by the project with Vagrant, you should also use the [vagrant-windows](https://github.com/WinRb/vagrant-windows) plugin, which will ensure Vagrant works well with Windows. This will also allow Vagrant to use WinRM to communicate with the box.
The generated box files include a Vagrantfile template that is suitable for
use with Vagrant 1.6.2+, which includes native support for Windows and uses
WinRM to communicate with the box.
### Getting Started
......
netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
rem install rsync
if not exist "C:\Windows\Temp\7z920-x64.msi" (
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/sevenzip/7z920-x64.msi', 'C:\Windows\Temp\7z920-x64.msi')" <NUL
)
msiexec /qb /i C:\Windows\Temp\7z920-x64.msi
pushd C:\Windows\Temp
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('http://mirrors.kernel.org/sourceware/cygwin/x86_64/release/rsync/rsync-3.1.0-1.tar.xz', 'C:\Windows\Temp\rsync-3.1.0-1.tar.xz')" <NUL
cmd /c ""C:\Program Files\7-Zip\7z.exe" x rsync-3.1.0-1.tar.xz"
cmd /c ""C:\Program Files\7-Zip\7z.exe" x rsync-3.1.0-1.tar"
copy /Y usr\bin\rsync.exe "C:\Program Files\OpenSSH\bin\rsync.exe"
rmdir /s /q usr
del rsync-3.1.0-1.tar
popd
msiexec /qb /x C:\Windows\Temp\7z920-x64.msi
rem make symlink for c:/vagrant share
mklink /D "C:\Program Files\OpenSSH\vagrant" "C:\vagrant"
......@@ -75,6 +75,7 @@
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat",
"./scripts/compact.bat"
]
},
......
......@@ -75,6 +75,7 @@
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat",
"./scripts/compact.bat"
]
},
......
......@@ -74,7 +74,8 @@
"scripts": [
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat"
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat"
]
},
{
......
......@@ -75,6 +75,7 @@
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat",
"./scripts/compile-dotnet-assemblies.bat",
"./scripts/compact.bat"
]
......
......@@ -75,6 +75,7 @@
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat",
"./scripts/compile-dotnet-assemblies.bat",
"./scripts/compact.bat"
]
......
......@@ -74,7 +74,8 @@
"scripts": [
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat"
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat"
]
},
{
......
......@@ -74,7 +74,8 @@
"scripts": [
"./scripts/vm-guest-tools.bat",
"./scripts/chef.bat",
"./scripts/vagrant-ssh.bat"
"./scripts/vagrant-ssh.bat",
"./scripts/enable-rdp.bat"
]
},
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment