A suite of Packer plugins for provisioning Windows machines using Windows Remote Management.
IMPORTANT The plugins in this project have been incorporated into Packer 8.0. The code in this repo is unbuildable. Relevant issue: #63
- We have created the following Windows-specific plugins:
virtualbox-windows-iso
, virtualbox-windows-ovf
)vmware-windows-iso
, vmware-windows-vmx
)parallels-windows-iso
, parallels-windows-pvm
)amazon-windows-ebs
)powershell
)windows-shell
)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
~/.packer.d/plugins
on Unix systems or %APPDATA%/packer.d/plugins
on Windows.With Go 1.2+ installed, follow these steps to use these community plugins for Windows:
make dev
./bin
to a location where Packer will detect them at run-time, such as any of the following:
$GOPATH/bin
together.~/.packer.d/plugins
on Unix systems or %APPDATA%/packer.d
on Windows.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"
]
}
#packer-community
on Freenode.