Using Modules from the Puppet Forge

Hands-On Lab

 

Photo of Elle Krout

Elle Krout

Content Team Lead in Content

Length

00:30:00

Difficulty

Beginner

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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Using Modules from the Puppet Forge

Introduction

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.

Solution

Prepare the Environment

  1. Log in to the Additional Node:

    ssh cloud_user@PUBLIC_IP_ADDRESS
  2. Install the Puppet agent:

    $ curl -k https://puppet.ec2.internal:8140/packages/current/install.bash | sudo bash
  3. It may not be obvious, but this command will require our password (the same one used to log in to the server)

  4. Log in to the Puppet master server:

    ssh cloud_user@PUBLIC_IP_ADDRESS
  5. Sign the CA:

    $ sudo puppetserver ca sign --all

Install a PostgreSQL Module

  1. In your web browser, go to forge.puppet.com.

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

  3. Install the module to the Puppet master:

    $ sudo 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 { 'purchases': user => 'dev', password => postgresql_password('dev', 'devpass'), } }

  5. Save and exit the file.

Force a Puppet Run against node1

  1. 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

Conclusion

Congratulations — you've completed this hands-on lab!