Using Modules from the Puppet Forge

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Using Puppet but don’t want to have to write your own modules? The Puppet Forge is an online repository hosted by PuppetLabs that stores public modules anyone can use in their Puppet infrastructure. These modules are labeled by quality and rated, so users are able to best gauge which module suits their needs before adding it to their Puppet setup.

In this lab, we’ll find a PostgreSQL module on the Puppet Forge, and use it — alongside our main manifest — to install PostgreSQL on our node and ensure a new database is created and ready for use.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install a PostgreSQL Module
  1. SSH into the Puppet master server.

  2. In your web browser, go to

  3. Search for a PostgreSQL module; select the one from PuppetLabs.

  4. Install the module to the Puppet master:

    $ puppet module install puppetlabs-postgresql –version 6.0.0

Create a Node Definition for the `node1.ec2.internal` Node
  1. Move to the production environment directory:

    $ cd /etc/puppetlabs/code/environments/production/

  2. Open the main manifest for the environment:

    $ sudo vim manifests/site.pp

  3. Create a node definition for the node1 node at the end of the file. Call the PostgreSQL module from the definition, ensuring that a new password is set:

    node node1.ec2.internal {
    class { ‘postgresql::server’:
    postgres_password => ‘temporarypenguin’,

  4. Next, use the provided postgresql::server::db defined type to set up a database:

    node node1.ec2.internal {
    class { ‘postgresql::server’:
    postgres_password => ‘temporarypenguin’,
    postgresql::server::db { ‘mydatabasename’:
    user => ‘dev’,
    password => postgresql_password(‘dev’, ‘devpass’),

  5. Save and exit the file.

Force a Puppet Run against node1

Log in to the node1 node and perform a Puppet run. Note that due to dependencies within the PostgreSQL module, this command may need to run twice:

$ sudo puppet agent -t
$ sudo puppet agent -t

Additional Resources

As a member of the DevOps team, you are often tasked with setting up new environments, something that Puppet often makes a lot simpler. However, a developer has requested a new host with PostgreSQL, of which you do not have an existing Puppet module for; you and your team also do not have the cycles to write one for at least another quarter. To prevent excessive waiting, you've instead decided to pull an existing PostgreSQL module from the Puppet Forge, and use that to set up the node for the developer.

Navigate to to search for existing PostgreSQL modules. Ensure you use a Supported module, and make sure to save it to the production environment. Review the README to see how to use the module, then add it to the production environment's main manifest so it's only applied to the node1 node. Within the main manifest, set the overall PostgreSQL password to temporarypenguin. Add an additional class to create a new database with the name purchases, the user dev, and the password devpass. When finished, log in to the node and force a Puppet run to test the module; you may need to run puppet agent -t twice.

Before you begin, install the Puppet agent on the additional node:

curl -k https://puppet.ec2.internal:8140/packages/current/install.bash | sudo bash

Sign the cert on the master when finished:

sudo puppetserver ca sign --all

Note that you should not need to log in to the PE console to complete this activity, but if you wish to access the Puppet Enterprise console, use the public IP of the Puppet master: https://PUBLICIP. Use the username admin and the password pinehead to log in.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?