- Lab
- A Cloud Guru
Using Puppet Classification
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.
Path Info
Table of Contents
-
Challenge
Prepare Test Nodes
-
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
-
Access the Puppet Enterprise console at
https://PUBLIC_IP
and log in asadmin
with the passwordpinehead
. -
Click Unsigned certs on the left-hand side menu.
-
Click the Accept All button to accept our nodes.
-
-
Challenge
Create the Groups
- Click Classification on the left-hand side menu.
- 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
- Click Add.
- Repeat the above process to create the Website group, except the following value will differ:
- Group name: Website
- Click Add.
- For the final Webapp group, set the following values:
- Parent name: Web
- Group name: Webapp
- Environment: production
- Click Add.
-
Challenge
Configure the Web Group
-
On the Classification page, click on the Web group, and then the Configuration tab.
-
Set Add new class to the
apache
class via a search. -
Click Add class.
Note: We may need to click Refresh for all classes to be visible.
-
Click the Commit 1 change button to save the changes.
-
-
Challenge
Configure the Website Group
- Click Classification on the left-hand side menu.
- Expand the Web group, and click Website.
- 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.-
Click Add rule.
-
Click the Configuration tab.
-
Add the
apache::vhosts
class via a search in the Add new class section. -
Click Add class.
-
Under the
apache::vhosts
class, select thevhosts
parameter name. -
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"}}
-
Click Add parameter.
-
Scroll down to the Data section, and set the following values:
- Class: apache
- Parameter: default_vhost
- Value: false
- Click Add data.
- Click Commit 3 changes.
-
Challenge
Configure the Webapp Group
-
Click Classification on the left-hand side menu.
-
Expand the Web group, then click Webapp.
-
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. -
Click Add rule.
-
Click the Configuration tab.
-
Add the
apache::vhosts
class. -
Under the
apache::vhosts
class, select thevhosts
parameter name. -
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"}}
-
Click Add parameter.
-
Add the
java
class. -
Select the distribution parameter, and then set the value to jre.
-
Click Add parameter.
-
Click Commit 3 changes.
-
-
Challenge
Test the Group Settings
For each node, perform the following:
- In the Puppet Enterprise console, click Nodes on the left-hand side menu.
- Select the desired node.
- Click Run Puppet, and then select Run.
- We can also click View report to see a detailed breakdown of the changes that were applied.
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.