Skip to main content

Using Puppet Classification

Hands-On Lab

 

Photo of Elle Krout

Elle Krout

Content Team Lead in Content

Length

00:15:00

Difficulty

Intermediate

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.

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 Puppet Classification

Introduction

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.

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS

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 hash rockets 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 hashrockets 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 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.

Conclusion

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