July 19, 2021

How to Use Chocolatey Windows Package Management with Puppet

Infrastructure Automation
Configuration Management

Chocolatey lets you manage all aspects of Windows software: installation, configuration, upgrading, and uninstalling. It works with runtime binaries, zips and existing installer technologies like MSI, NSIS and InnoSetup. Chocolatey takes advantage of PowerShell automation 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 the Chocolatey package manager.

Table of Contents

How to Install Chocolatey Windows Package Manager

Before you can configure Chocolatey with Puppet, you've got to install Chocolatey on Windows.

How to Install Chocolatey Windows Package Manager Manually

  • Step 1: Download Chocolatey from the Chocolatey website.
  • Step 2: Copy the Chocolatey installation script you need.
  • Step 3: Open Command Prompt or PowerShell.
    • Right-click on the Start button and select "Command Prompt (Admin)" or "Windows PowerShell (Admin)" to open the appropriate tool.
  • Step 4: Install Chocolatey on Windows using the Chocolatey installation script.
    • Paste the script into your Command Prompt or PowerShell window and press Enter.
  • Step 5: Accept User Account Control (UAC) if prompted.
  • Step 6: Verify the Chocolatey installation.
    • To verify your installation, type 𝚌𝚑𝚘𝚌𝚘 in the Command Prompt or PowerShell window and press Enter. Confirm that the Chocolatey logo and version information appear.

How to Install Chocolatey Windows with the Puppet Module

There is a Puppet-supported module for Chocolatey for Windows for use as a package provider within Puppet. It allows Open Source Puppet and Puppet Enterprise users to quickly and easily install, configure, and start delivering packages with Chocolatey.

To use it, simply download the Chocolatey module for Puppet on the Puppet Forge.

How to Configure the Chocolatey Windows Package Manager with Puppet

Now, let’s look at the Puppet Chocolatey module in action. Make sure Chocolatey is installed using one of the following commands:

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 Chocolatey.org to pull down the latest version of the package. Alternatively, you can have a local URL (a file sitting on an HTTP server).

Try Puppet for Package Management

Automate 10 nodes for free, forever. No strings attached.


A laptop running Puppet with the Puppet Enterprise logo next to it.

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

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’, ‘“‘],

We can specify default sources in Chocolatey itself, or you can define them 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 the Chocolatey package manager is as simple as dropping some packages into a folder or a server somewhere that can serve packages. You have plenty of install and uninstall options as well.

Creating Packages in the Chocolatey Windows Package Manager

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.

Related ▶️: How Puppet Supports DevOps Workflows in the Windows Ecosystem

Why Chocolatey?

The Chocolatey Windows package manager allows you to use non-centralized and private repositories and create your own packages.

Using Chocolatey means you don’t need a GUID – Chocolatey itself handles all the downloading and installing. If you’re hosting internal packages, you can even embed the install file into the Chocolatey package itself to further streamline the process.

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 Chocolatey.org. That way you’ll have complete control over your software.

Chocolatey and Puppet are Better Together

But hey, don't take our word for it. Get a free, guided demo of Puppet today and see for yourself.


Chocolatey is a unified interface for 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 achieved 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.

How Puppet Makes Using the Chocolatey Package Manager on Windows Even Better

Puppet can install Chocolatey and packages, and all the configuration that goes along with Chocolatey as well — including custom sources and other features.

Because Chocolatey is a command line tool, using Puppet to configure and control Chocolatey is straightforward and sensible. Puppet allows you to automate many important parts of the package creation process in Chocolatey, which is a great way to streamline package creation and software management on Windows.

Automating repetitive tasks also makes it easier to learn and use the Chocolatey package manager on Windows, which reduces the learning curve for new IT staff to get up to speed.

Because automation is also an essential element of continuous delivery, using Puppet to manage Chocolatey gets you one step closer to fully automated infrastructure management at scale.


This blog was originally published on September 18, 2016 and has since been updated for accuracy and relevance.

Learn More