Installing package using choco in puppet

Chocolatey is an apt-like package manager for Windows (https://chocolatey.org) that greatly simplifies the installation of software on windows.

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.

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.

include chocolatey
 package { 'git':
  ensure   => installed,
  provider => chocolatey,
}

If we 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.

package {'GoogleChrome':
  ensure => installed, 
  source => '\\\zippyopsfilesrv1\soft'
}

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.

Uninstalling software is simple. Whether we are using Chocolatey or Puppet’s built-in provider, we just set the value of ensure to absent.
package {'GoogleChrome':
  ensure => absent, 
}


Recent Comments

No comments

Leave a Comment