Published on 19 September 2016 by

Editor’s note: This is one in a series of posts about using Puppet to automate your Windows servers. Follow us on social media or subscribe to our our RSS feed to be notified when the next post is released.

Chocolatey is a package manager for Windows, like Yum. It uses the NuGet packaging framework and PowerShell for automation scripts. With Chocolatey, you can use non-centralized and private repositories and create your own packages. Chocolatey is a Microsoft-validated tool, and any Windows installer, zip, or binary can be packaged with Chocolatey.

Chocolatey lets you manage all aspects of Windows software: installation, configuration, upgrade and uninstalling. It works with runtime binaries, zips and existing installer technologies like MSI, NSIS and InnoSetup. Chocolatey takes advantage of PowerShell to turn complex tasks into simple function calls.

In this post, we'll take a look at how you can use Puppet to configure and control Chocolatey.

The Chocolatey community repository has thousands of packages that anyone can use, but we recommend you host your own internal package repository server rather than the packages on That way you’ll have complete control over your software.

Let’s look at the Puppet Chocolatey module. It can install Chocolatey and packages, and later all the configuration that goes along with Chocolatey as well — including custom sources and other features. Here’s a couple ways of ensuring Chocolatey is installed:

include chocolatey

# OR

class {‘chocolatey’:
    chocolatey_download_url => ‘http://url/to/chocolatey.nupkg’,


We can see in this manifest that we can simply include Chocolatey, and the default reaches out to to pull down the lastest version of the package. Alternatively, you can have a local URL (a file sitting on an HTTP server).

package {‘name_of_package’:
    provider        => chocolatey,
    ensure          => absent, installed, latest, ‘1.0.0’, held,
    source          => ‘http://some_odata_feed/;c: \\local;\\some\network\share’,
    install_options     => [‘-installArgs’, ‘“‘, ‘addtl’, ‘args’, ‘“‘],
    uninstall_options   => [‘-uninstallargs’, ‘“‘, ‘addtl’, ‘args’, ‘“‘],

Above is the anatomy of a package resource. We set Chocolatey as the provider, so we can ensure software is removed, installed, stays up to date, is a particular version, or hold a package on a version.

We can specify default sources in Chocolatey itself, or you can define it here. We can pull the package from one source or more (separated by a semicolon) — either a web data feed or a local file or folder. Getting started with Chocolatey is as simple as dropping some packages into a folder a server somewhere that can serve packages. You have plenty of install and uninstall options as well.

Why Chocolatey? It’s a unified interface to all different types of installers. Here’s the difference between the built-in Windows package provider and Chocolatey:

#built-in provider
package { “Git version 2.6.1’:
    ensure      => installed,
    source      => ‘C:\temp\Git-2.6.1-32bit.exe’,
install_options => [‘/VERYSILENT’]

#Chocolatey provider
package { ‘git’:
    ensure      => latest,

Note the differences. For the built-in provider, when we need to upgrade we’ll run into maintenance issues. We’ll need to change the manifest over time. Instead, if we take a look at the Chocolatey provider, we can see it looks just like the package provider for other operating systems. We’ve achieving platform-agnostic packaging. You can use that same packaging to ensure the latest version of Git is installed across all of your platforms and operating systems.

Creating packages

There are a few files in the default Chocolatey package template, as it is meant to provide a generalist approach. You can also create your own templates. Chocolatey will by default generate a readme file, install and uninstall PowerShell scripts, and a nuspec — which is a way of describing the packaging format. It has information about the version of the software, any dependencies, etc. For example, if you have a package with Git extensions and it requires Git to be installed first, Chocolatey will be able to manage that for you.

That’s a quick overview of how Chocolatey works with Puppet. For the full demo, download the webinar here. For more information on Chocolatey, visit

Rob Reynolds is a senior software engineer at Puppet.

Learn more

Share via:
Posted in:
The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.