Install a module from The Puppet Forge
# search for a module
$ /opt/puppetlabs/bin/puppet module search docker
...
garethr-docker ...
RHsyseng-docker ...
...
# install the module we've selected
$ sudo /opt/puppetlabs/bin/puppet module install garethr-docker
...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/site
garethr-docker (v5.3.0)
...
# verify the module is installed
$ sudo /opt/puppetlabs/bin/puppet module list
/etc/puppetlabs/code/environments/production/site
|-- garethr-docker (v5.3.0)
Thanks to the large and productive Puppet community there is a high chance that for any common piece of software you want to manage via puppet there is an existing module you can download for free and use in your own environment. Before embarking on a coding spree to bring another piece of infrastructure under the control of your puppet server it's worth spending a few minutes searching the modules submitted to The Puppet Forge to see if you can save yourself time and effort by using existing code.
There are two main ways to search the Forge. The easiest is to open The Puppet Forge in your browser and use the search box on the front page. This will show you a large amount of meta data about the modules that will help guide your decision as to which module to use. In addition to the quality scores and compatibility details there are two special indicators to watch out for on modules, 'Supported' and 'Approved'. From The Forge itself "Puppet approved modules pass Puppet, the companies, specific quality and usability requirements. Those modules are recommended by Puppet, but are not supported as part of a Puppet Enterprise license agreement. Puppet supported modules have been tested with Puppet Enterprise and are fully supported by Puppet."
The second approach is to query via the command line. This can be helpful when you're trying to find a module you've already investigated but it lacks a lot of the information found on a modules Forge page.
$ /opt/puppetlabs/bin/puppet module search docker
Notice: Searching https://forgeapi.puppetlabs.com ...
NAME DESCRIPTION AUTHOR KEYWORDS
garethr-docker Module for installing and managing docker @garethr ubuntu lxc redhat centos docker
puppetlabs-docker_platform Installs, configures, and manages the Docker... @puppetlabs
RHsyseng-docker set up docker on a host @RHsy
Once you've selected the module you want to use you'll need to install
it. Assuming you run puppet in the traditional way, many puppet agents
connecting to the puppet server, you'd install the module on the puppet server
itself and the agents will sync the modules files over as needed.
It's important to note that this example shows the simplest way to
install a puppet module, as a one time operation by hand. If you have a
more sophisticated deployment and use features such as multiple puppet
environments, or manage your modules using tools such as r10k
or puppet-
librarian
, then you'll want to skip this example and move on to more
advanced documentation.
If you're comfortable installing the module by hand directly on the puppet server then run the commands given here:
sudo /opt/puppetlabs/bin/puppet module install garethr-docker
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/site ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/site
garethr-docker (v5.3.0)
puppetlabs-apt (v2.3.0)
puppetlabs-stdlib (v4.12.0) [/etc/puppetlabs/code/environments/production/modules]
stahnma-epel (v1.2.2)
You can then verify the installation with
sudo /opt/puppetlabs/bin/puppet module list
/etc/puppetlabs/code/environments/production/site
|-- garethr-docker (v5.3.0)
You can now use the resources, providers and types from the module in your own puppet code.