A suite of Packer plugins for provisioning Windows machines using Windows Remote Management.
The plugins are generally available and actively maintained.
We have created the following Windows-specific plugins:
- VirtualBox ISO and OVF (
virtualbox-windows-iso
,virtualbox-windows-ovf
) - VMWare ISO and VMX (
vmware-windows-iso
,vmware-windows-vmx
) - Parallels ISO and PVM (
parallels-windows-iso
,parallels-windows-pvm
) - Amazon EBS (
amazon-windows-ebs
)
- Powershell (
powershell
) - Windows Shell (
windows-shell
) - Restart Windows (
restart-windows
)
The plugins can be used by downloading pre-built binaries, or by building the project locally and ensuring the binaries are in the correct location.
If you are using Homebrew you can follow these steps to install the plugins:
brew install https://raw.githubusercontent.com/packer-community/packer-windows-plugins-brew/master/packer-windows-plugins.rb
choco install packer-windows-plugins
- Install Packer
- Download the latest release for your host environment: packer-windows-plugins/releases
- Unzip the plugin binaries to a location where Packer will detect them at run-time, such as any of the following:
- The directory where the packer binary is.
~/.packer.d/plugins
on Unix systems or%APPDATA%/packer.d/plugins
on Windows.- The current working directory.
- Change to a directory where you have packer templates, and run as usual.
With Go 1.2+ installed, follow these steps to use these community plugins for Windows:
- Install packer
- Clone this repo
- Run
make dev
- Copy the plugin binaries located in
./bin
to a location where Packer will detect them at run-time, such as any of the following:
- The directory where the packer binary is. If you've built Packer locally, then Packer and the new plugins are already in
$GOPATH/bin
together. ~/.packer.d/plugins
on Unix systems or%APPDATA%/packer.d
on Windows.- The current working directory.
- Change to a directory where you have packer templates, and run as usual.
A simple Packer template for Windows, which utilizes the virtualbox-windows-iso
builder and winrm
communicator plugins, will look something like
{
"builders": [{
"type": "virtualbox-windows-iso",
"vm_name": "windows_2012_r2",
"iso_url": "iso/en_windows_server_2012_r2_with_update_x64_dvd_4065220.iso",
"iso_checksum_type": "md5",
"iso_checksum": "af6a7f966b4c4e31da5bc3cdc3afcbec",
"guest_os_type": "Windows2012_64",
"boot_wait": "2m",
"winrm_username": "packer",
"winrm_password": "packer",
"winrm_wait_timeout": "10m",
"shutdown_timeout": "1h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"disk_size": 61440,
"format": "ova",
"floppy_files": [
"./Autounattend.xml",
"./enable-winrm.bat",
]
}],
"provisioners": [{
"type": "powershell",
"scripts": [
"scripts/chocolatey.ps1"
]
},{
"type": "powershell",
"inline": [
"choco install 7zip",
"choco install dotnet4.5.2"
]
},{
"type": "windows-shell",
"scripts": [
"scripts/netsh.bat"
]
}],
"post-processors": [{
"type": "vagrant",
"output": "windows_2012_r2_virtualbox.box",
"vagrantfile_template": "Vagrantfile.template"
}]
}
Check out these projects for more detailed examples of Windows-centric Packer templates:
In certain situations, you may need to run commands with elevated privileges even if your winrm_username
user is an Administrator, for example upgrading system packages like the .NET Framework.
In these cases there are 2 additional keys provided on the powershell
provisioner that you can supply that will enable this mode: elevated_user
and elevated_password
:
{
"type": "powershell",
"elevated_user":"vagrant",
"elevated_password":"vagrant",
"inline": [
"choco install netfx-4.5.2-devpack"
]
}
- IRC:
#packer-community
on Freenode. - Slack: packer.slack.com