A large number of managed systems require configuration of software that is outside the scope of the built-in Windows roles and features. Chef has a very handy resource for installing arbitrary software onto a Windows host through the windows_package resource, which behaves somewhat like the Linux-based package resource only for Windows-specific installations. The windows_package resource is capable of installing software through a variety of popular installation mechanisms. Currently, that list includes the following:
- MSI packages
- Wise InstallMaster
- Inno Setup
- Nullsoft Scriptable Install System
If an installer type is not provided in the resource's attributes, then Chef will try to identify the installer by examining the package. For software that does not use one of the supported installation mechanisms, Chef provides the ability to describe a custom installer workflow by providing the custom installation type.
Note: In order for Chef to manage the installation of the software, it must support some form of unattended or quiet mode that does not rely on any user input to successfully install the software package. This applies for both installation and removal.
Installing Software Packages In Windows Using Chef - Available Action
The following table lists the available actions and parameters for the windows_ package resource:
Examples of installing Windows packages
Using a locally provided file, perform an installation of Ruby 1.9.3-p448. This package uses the Inno Setup packager and a hint is provided, but remember that even without it, the provider will try to determine the installer type:
windows_package "Ruby 1.9.3-p448" do source File.join("C:", "temp", "rubyinstaller-1.9.3-p448.exe") options '/dir="C:/Ruby193" /tasks="modpath"' installer_type :inno action :install end
You can specify arbitrary flags to pass to an installer that does not use one of the known packaging systems. One example of this is Firefox, which supports passing the -ms command-line arguments to the installer in order to run in silent mode:
ff_url = "http://archive.mozilla.org/pub/mozilla.org/mozilla.org/ firefox/releases/28.0b4/win32/en-US/Firefox%20Setup%2028.0b4.exe" windows_package 'Mozilla Firefox 28.0b4 (x86 en-US)' do source ff_url action :install installer_type :custom options '-ms' end
The options for Firefox can be found at https://wiki.mozilla.org/ Installer:Command_Line_Arguments.
In order to remove a previously installed package, such as iTunes, make use of the :remove action as follows:
windows_package "iTunes" do action :remove end