Managing Windows Server with Puppet Part 6: Installing, Updating, and Removing Software

Posted on by Russell Smith in Windows Server

USB Type-C connector (Image Credit: thunderbolttechnology.net)

In today’s Ask the Admin, I’ll show you how to manage Puppet, Windows Installer, and Chocolatey.

 

 

So far in this series, I’ve looked at installing Puppet Master Enterprise in Azure and automatically bootstrapping the Puppet agent in a Windows Server VM. In parts four and five I showed you how to manage files and permissions and manage local users and groups. If you missed any of the previous articles, here’s a complete list of them so far:

Managing Windows Server with Puppet Part 1: Configure Puppet Master and Bootstrap the Puppet Agent in Windows Server

Managing Windows Server with Puppet Part 2: Log Into Puppet Master, Accept Node Certificate, and Test Connectivity

Managing Windows Server with Puppet Part 3: Install the Modules and Edit the Site Manifest

Managing Windows Server with Puppet Part 4: Working with Files and ACLs

Managing Windows Server with Puppet Part 5: Managing Local Users and Groups

Puppet Package Providers

There are two ways you can manage software using Puppet. The built-in package provider allows you to install software using executables (.exe files) and Windows Installer (.msi) packages. It’s possible to change the default provider and use Chocolatey, which is an open source package manager for Windows. The open source version of Chocolatey is free. Chocolatey for Business (C4B) must be licensed and it adds features for organizations that want a centralized software management solution, such as Package Builder. For more information on Chocolatey, see Package Management in Windows Using Chocolatey and Managing Windows Software Using Chocolatey on Petri.

Built-in Package Provider

Let’s look at how to install software using Puppet’s built-in package provider. To complete the instructions below, you’ll need an .exe or .msi file of the software you want to install. Here I’m using Git as an example. In the code below, I’m installing Git from a local file location on the node but you can also specify a network file share. Note that any install options you specify must be supported by the .exe or .msi installer package. They are not specific to Puppet.


If you want to install a specific version of a package, or the latest version, you must give the exact version number in the ensure parameter. The built-in package provider doesn’t support using latest as a value for the ensure parameter with .exe or .msi files on Windows.

Installing Software Using Chocolatey

The Chocolatey provider is installed as part of the Puppet on Windows module pack. Chocolatey can be used to install packages from Chocolatey’s own Internet repository or you can install software from your own local repository.

Installing software using Chocolatey and Puppet (Image Credit: Russell Smith)
Installing Software Using Chocolatey and Puppet (Image Credit: Russell Smith)

The code below uses ‘include chocolatey’ to install chocolatey on the node. And then it installs Git from Chocolatey’s Internet repository. When using the Chocolatey provider for Puppet, the value of the ensure parameter can be set to latest.


Installing software using Chocolatey and Puppet (Image Credit: Russell Smith)
Installing Software Using Chocolatey and Puppet (Image Credit: Russell Smith)

If you want to install a package from something other than Chocolatey’s own Internet repository, you need to specify the repo using the source parameter. In the example below, I’m using a local file share as my repository. Note that there are three backslashes at the start of the file path to represent two literal backslashes in Windows.


When installing software from a local repository, make sure that any dependent packages are also present in the repository. Google Chrome doesn’t have any dependencies. Other packages, like Git, have one or more dependencies. There are a couple of ways to determine a package’s dependencies. The easiest is to go to the package in Chocolatey’s Internet repository, scroll down, and see the list of dependencies. Alternatively, you can open a package using NuGet Package Explorer to view dependencies.

Removing Software

Uninstalling software is very easy. Whether you are using Chocolatey or Puppet’s built-in provider, you just set the value of ensure to absent.


In this article, I showed you how to install software using Puppet’s built-in package provider and using Chocolatey.

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register