mitchellh/packer — pull request #1175 by sneal (2014-05-14 23:25:06+00:00)
Title: WinRM communicator

First attempt at adding WinRM comm support to Packer as an optional channel for Windows guests, Packer issue https://github.com/mitchellh/packer/issues/451. This builds off some of the work by @joefitzgerald, @masterzen, and @dylanmei

I can currently standup a Windows guest and successfully connect via WinRM through Packer.

```
vmware-iso: Download progress: 100%
==> vmware-iso: Creating floppy disk...
vmware-iso: Copying: ./Autounattend.xml
vmware-iso: Copying: ./unattend.xml
vmware-iso: Copying: ../../scripts/install-winupdates.ps1
vmware-iso: Copying: ../../scripts/configure-winrm.ps1
==> vmware-iso: Creating virtual machine disk
==> vmware-iso: Building and writing VMX file
==> vmware-iso: Starting virtual machine...
==> vmware-iso: Waiting 5m0s for boot...
==> vmware-iso: Connecting to VM via VNC
==> vmware-iso: Typing the boot command over VNC...
==> vmware-iso: Waiting for WinRM to become available...
==> vmware-iso: Connected to WinRM!
==> vmware-iso: Gracefully halting virtual machine...
vmware-iso: Waiting for VMware to clean up after itself...
==> vmware-iso: Deleting unnecessary VMware files...
vmware-iso: Deleting: output-vmware-iso/packer-vmware-iso.plist
vmware-iso: Deleting: output-vmware-iso/packer-vmware-iso.vmx.lck/M37050.lck
vmware-iso: Deleting: output-vmware-iso/startMenu.plist
vmware-iso: Deleting: output-vmware-iso/vmware.log
==> vmware-iso: Cleaning VMX prior to finishing up...
vmware-iso: Unmounting floppy from VMX...
vmware-iso: Detaching ISO from CD-ROM device...
Build 'vmware-iso' finished.
```

Obvious limitations apply:
- Only VMWare ISO builder is currently working with WinRM
- Far too few tests
- Provisioners almost certainly don't work because of Unix-isms
- WinRM library is a bit rough

A base Packer configuration file for use with WinRM:
```json
{
"builders": [{
"type": "vmware-iso",
"communicator_type": "winrm",
"iso_url": "http://download.microsoft.com/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso",
"iso_checksum_type": "md5",
"iso_checksum": "4263be2cf3c59177c45085c0a7bc6ca5",
"headless": false,
"skip_compaction": true,
"boot_wait": "5m",
"winrm_username": "Administrator",
"winrm_password": "password",
"winrm_wait_timeout": "10m",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "windows7srv-64",
"disk_size": 61440,
"floppy_files": [
"./Autounattend.xml",
"../../scripts/configure-winrm.ps1"
],
"vmx_data": {
"memsize": "2048",
"numvcpus": "2"
}
}],
"provisioners": [],
"post-processors": []
}
```

Where [configure-winrm.ps1](https://gist.github.com/sneal/a0b0f51d37fca36d1918) configures WinRM for connection.