Every module contains one or more classes. Classes are named chunks of Puppet code and are the primary means by which Puppet Enterprise configures nodes.
The puppetlabs-apache module you installed in the Module installation quick start guide contains a class called
apache. In this quick start guide, you’ll apply the
apache class to your agent node, which will allow you to launch the default Apache virtual host on your agent node.
In the PE console, click Nodes > Classification, and click Add group.
To add nodes to a node group, create rules that define which nodes should be included in the group.
apacheclass to the node group
Now that you’ve created a node group, add classes to give the matching nodes purpose.
Unless you have navigated elsewhere in the console, the apache_example node group should still be displayed in the Classification page. On the Classes tab, in the Class name field, begin typing
apache, and select it from the autocomplete list.
Click Add class, and commit changes.
apache class now appears in the list of classes for your agent. You can see this list by clicking Nodes > Inventory and then clicking your node in the Inventory list. When the page opens with your node’s details, click the Classes tab.
From the command line on your agent, run
puppet agent -t. Next, navigate to
/var/www/html/, and create a file named
index.html with the text editor of your choice and add some content (for example, “Hello, World!”).
From the command line of your agent node, run
puppet agent -t. This configures the node using the newly assigned class.
Wait one or two minutes.
Open a browser and enter the IP address for the agent node, adding port 80 on the end, as in
http://myagentnodeIP:80/. The contents of
/var/www/html/index.html are displayed.
You can use the console to modify the values of a class’s parameters without editing the module code directly.
apachein the list of classes.
From the Parameter Name drop-down list, choose the parameter you want to edit. For this example, select
Note: The grey text that appears as values for some parameters is the default value, which can be either a literal value or a Puppet variable. You can restore this value by selecting Discard changes after you have added the parameter.
From the command line of your PE-managed node, run
puppet agent -t.
This triggers a Puppet run, and Puppet Enterprise creates the new configuration.
You have set the Apache web server’s root directory to
/var/www instead of its default
/var/www/html. If you refresh
http://myagentnodeIP:80/in your web browser, it shows the list of files in
/var/www. If you click
html, the browser again shows the contents of
Puppet Enterprise is now managing the default Apache vhost on your agent node. Next, you’ll learn how to manage users with PE, and how to set permissions for each user or group of users. Click here when you’re ready to move forward.