Using Puppet Classification

15 minutes
  • 6 Learning Objectives

About this Hands-on Lab

The process by which we map our classes, variables, and parameters to our nodes is known as classification. In Puppet Enterprise (PE), we have the option to assign our nodes to groups and classify our nodes by leveraging the PE Console. Additionally, groups can be associated with a parent group, and the child group will inherit all classes alongside parameters. The overall process gives us the ability to create layered groups and systems that we can assign to our nodes based upon the designated purpose it serves within our infrastructure. Moreover, we can assign groups to the component module or use them in conjunction with roles and profiles.

In this hands-on lab, we will create a parent `web` group with two children: one for our general website and one for our web app. We will include core modules in the `web` parent, override, and then expand our requirements in each of our child groups.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Prepare Test Nodes
  1. Bring both additional nodes under Puppet’s control by logging in via SSH and running:

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

  2. Access the Puppet Enterprise console at https://PUBLIC_IP and log in as admin with the password pinehead.

  3. Click Unsigned certs on the left-hand side menu.

  4. Click the Accept All button to accept our nodes.

Create the Groups
  1. Click Classification on the left-hand side menu.
  2. On the Classification page, click Add group…, and then set the following values to create the Web group:
    • Parent name: All Nodes
    • Group name: Web
    • Environment: production
  3. Click Add.
  4. Repeat the above process to create the Website group, except the following value will differ:
    • Group name: Website
  5. Click Add.
  6. For the final Webapp group, set the following values:
    • Parent name: Web
    • Group name: Webapp
    • Environment: production
  7. Click Add.
Configure the Web Group
  1. On the Classification page, click on the Web group, and then the Configuration tab.

  2. Set Add new class to the apache class via a search.

  3. Click Add class.

    Note: We may need to click Refresh for all classes to be visible.

  4. Click the Commit 1 change button to save the changes.

Configure the Website Group
  1. Click Classification on the left-hand side menu.
  2. Expand the Web group, and click Website.
  3. Under the Rules section, set the following values:

    • Fact: fqdn
    • Operator: ~
    • Value: website

    Note: Changing the operator field to ~ensures that partial matches will work.

  4. Click Add rule.
  5. Click the Configuration tab.
  6. Add the apache::vhosts class via a search in the Add new class section.
  7. Click Add class.
  8. Under the apache::vhosts class, select the vhosts parameter name.
  9. In the Value section, we need to write our virtual hosts parameters as a hash, replacing what would traditionally be hashrockets with colons:

    {"puppet-project":{"port":"80","docroot":"/var/www/puppet-proj"}}

  10. Click Add parameter.
  11. Scroll down to the Data section, and set the following values:
    • Class: apache
    • Parameter: default_vhost
    • Value: false
  12. Click Add data.
  13. Click Commit 3 changes.
Configure the Webapp Group
  1. Click Classification on the left-hand side menu.
  2. Expand the Web group, then click Webapp.
  3. Under the Rules section, set the following values:

    • Fact: fqdn
    • Operator: ~
    • Value: app

    Note: Changing the operator field to ~ ensures that partial matches will work.

  4. Click Add rule.
  5. Click the Configuration tab.
  6. Add the apache::vhosts class.
  7. Under the apache::vhosts class, select the vhosts parameter name.
  8. In the Value section, we need to write our virtual hosts parameters as a hash, replacing what would traditionally be hash rockets with colons:

    {"marionette":{"port":"8081","docroot":"/var/www/marionette"}}

  9. Click Add parameter.
  10. Add the java class.
  11. Select the distribution parameter, and then set the value to jre.
  12. Click Add parameter.
  13. Click Commit 3 changes.
Test the Group Settings

For each node, perform the following:

  1. In the Puppet Enterprise console, click Nodes on the left-hand side menu.
  2. Select the desired node.
  3. Click Run Puppet, and then select Run.
  4. We can also click View report to see a detailed breakdown of the changes that were applied.

Additional Resources

You are a DevOps Engineer for a company that recently adopted Puppet Enterprise as their configuration management platform. Your team wishes to use PE's group-based classification for the setup of your nodes. You are also tasked with performing the classification for all web-based nodes, including the static website and the product's web application.

In order to achieve this, you need to make three groups that will consist of a web parent group that adds the apache module, plus two children: website and webapp.

Here are some of the requirements to keep in mind as you create each group for this lab:

Web

  1. Include the apache module.

Website

  1. Add a virtual host with the apache::vhosts class, and then apply the following value settings:
    • Servername: puppet-project
    • Port: 80
    • Docroot: /var/www/puppet-proj
  2. Override the default_vhost value for the main Apache class, and set it to false.

Webapp

  1. Add a virtual host with the apache::vhosts class, and then apply the following value settings:
    • Servername: marionette
    • Port: 8081
    • Docroot: /var/www/marionette
  2. Add the java module.
  3. Set the distribution to jre.

Ensure that all nodes starting the website are mapped to the website class, and all nodes starting with app are mapped to the webapp class.

Access the Puppet Enterprise console by navigating to: https://PUBLIC_IP_OF_SERVER. The user is admin and the password is pinehead.

To prepare the additional nodes for the classification process, install Puppet by running:

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

Finally, accept the certs located on the PE console.

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?