Vagrant Windows Update Provisioner
This is a Vagrant plugin for installing Windows updates.
NB This was only tested with Vagrant 2.0.3 and Windows Server 2016.
Installation
vagrant plugin install vagrant-windows-updateUsage
Add config.vm.provision "windows-update" to your Vagrantfile to update your
Windows VM during provisioning or manually run the provisioner with:
vagrant provision --provision-with windows-updateTo troubleshoot, set the VAGRANT_LOG environment variable to debug.
Example
In this repo there's an example Vagrantfile. Use it to launch an example.
First install the Base Windows Box.
Then install the required plugins:
vagrant plugin install vagrant-windows-update
vagrant plugin install vagrant-reloadThen launch the example:
vagrant upNB On my machine this takes about 1h to complete... but YMMV!
Filters
You can select which Windows Updates are installed by defining a set of filters, e.g.:
config.vm.provision "windows-update", filters: [
"exclude:$_.Title -like '*Preview*'",
"include:$_.Title -like '*Cumulative Update for Windows*'",
"include:$_.AutoSelectOnWebSites"]NB If the filters argument is not used, only important updates are installed (equivalent of declaring a single include:$_.AutoSelectOnWebSites filter).
The general filter syntax is:
ACTION:EXPRESSION
ACTION is a string that can have one of the following values:
| action | description |
|---|---|
include |
includes the update when the expression evaluates to $true
|
exclude |
excludes the update when the expression evaluates to $true
|
NB If no ACTION evaluates to $true the update will NOT be installed.
EXPRESSION is a PowerShell expression. When it returns $true, the
ACTION is executed and no further filters are evaluated.
Inside an expression, the Windows Update IUpdate interface can be referenced by the $_ variable.
Development
To hack on this plugin you need to install Bundler and other dependencies. On Ubuntu:
sudo apt install bundler libxml2-dev zlib1g-devThen use it to install the dependencies:
bundleBuild this plugin gem:
rakeThen install it into your local vagrant installation:
vagrant plugin install pkg/vagrant-windows-update-*.gemYou can later run everything in one go:
rake && vagrant plugin uninstall vagrant-windows-update && vagrant plugin install pkg/vagrant-windows-update-*.gem