Windows Package Resource and Providers

Proposal for moving windows_package LWRP from the windows cookbook into core Chef.

Chef internal PBI: OC-5114

There are a number of package installer frameworks that are common on Windows, which can specified by the user or detected. Installing packages usually means passing a flag to the installer to indicate it is an unattended installation.

Support for roles features will be handled by a separate resource.

New Core Package Resource and Provider

Chef::Resource::WindowsPackage

Shortcut Resource Name: windows_package

This would be the default package provider on windows, so you would use the 'package' resource and wouldn't necessarily need a shortcut resource.

Attributes

Deprecated attributes:

Platform specific resources

Utilizing the platform-specific resource functionality introduced in CHEF-2698, add a new package resource with windows specific attributes

class Chef
  class Resource
    class WindowsPackage < Chef::Resource::Package

      provides :package, :on_platforms => ["windows"]

      def initialize(name, run_context=nil)
        super
        @action = :install
        @allowed_actions = [ :install, :remove ]
        @provider = Chef::Provider::Package::Windows
        @resource_name = :windows_package
        @installer_type = nil
        @checksum = nil
        @timeout = 600
        @success_codes = [0, 42, 127]

Chef::Provider::Package::Windows

Initial support for the Microsoft Installer (MSI) only, incrementally adding support for additional installers.

All installer support in core must use a unique identifier when available (e.g. Product Code, AppID) to:
* Support upgrade/removal
* Idempotently verify installation state

We must determine the installer type for the user to match the same experience of running the executable on windows itself. Some methods require reading the installer file, so we cannot make this determination in the resource and will do so in this provider, which will call another class specific to the determined installer

Example framework

Chef::Provider::Package::Windows::MSI

We will determine package installation status using MsiGetProductPropertyA and MsiGetProductInfoA using FFI. See the proof of concept code.

Actions

Example

windows_package '7-Zip 9.20 (x64 edition)' do
  source 'http://downloads.sourceforge.net/sevenzip/7z920-x64.msi'
  action :install
end

Future work

Existing Windows Cookbook

The existing windows cookbook contains a package LWRP

Resources

Providers