Modules on Puppet Forge can be installed using Puppet's built-in module
command. The modules on the Forge have files named Modulefile
, which define their dependencies; so, if you download modules from the Forge using puppet module install
, then their dependencies will be resolved in a way similar to how yum resolves dependencies for rpm packages.
To install the puppetlabs-puppetdb
module, we will simply issue a puppet module install
command in the appropriate directory. We'll create a new directory in tmp
; for our example, this will be /tmp/public_modules
, as shown here:
[git@stand ~]$ cd /tmp [git@stand tmp]$ mkdir public_modules [git@stand tmp]$ cd public_modules/ [git@stand public_modules]$
Then, we'll inform Puppet that our modulepath
is /tmp/public_modules
and install the puppetdb
module using the following command:
[git@stand public_modules]$ puppet module install --modulepath=/tmp/public_modules puppetlabs-puppetdb Notice: Preparing to install into /tmp/public_modules ... Notice: Downloading from https://forgeapi.puppetlabs.com ... Notice: Installing -- do not interrupt ... /tmp/public_modules └─┬ puppetlabs-puppetdb (v5.0.0) ├── puppetlabs-firewall (v1.7.1) ├── puppetlabs-inifile (v1.4.2) └─┬ puppetlabs-postgresql (v4.6.0) ├── puppetlabs-apt (v2.2.0) ├── puppetlabs-concat (v1.2.4) └── puppetlabs-stdlib (v4.9.0)
Using module install
, we retrieved puppetlabs-firewall
, puppetlabs-inifile
, puppetlabs-postgresql
, puppetlabs-apt
, puppetlabs-concat
, and puppetlabs-stdlib
all at once. So, not only have we satisfied dependencies automatically, but we also have retrieved release versions of the modules as opposed to the development code. We can, at this point, add these modules to a local repository and guarantee that our fellow developers will be using the same versions that we have checked out. Otherwise, we can inform our developers about the version we are using and have them check out the modules using the same versions.
You can specify the version with puppet module install
as follows:
[git@stand public_modules]$ m -r stdlib [git@stand public_modules]$ puppet module install --modulepath=/tmp/public_modules puppetlabs-stdlib --version 4.8.0 Notice: Preparing to install into /tmp/public_modules ... Notice: Downloading from https://forgeapi.puppetlabs.com ... Notice: Installing -- do not interrupt ... /tmp/public_modules └── puppetlabs-stdlib (v4.8.0)
Keeping track of the installed versions can become troublesome; a more stable approach is to use librarian-puppet
to pull in the modules you require for your site.