Organize webserver configurations with roles and profiles
The roles and profiles method is a reliable way to build reusable, configurable, and refactorable system configurations.
Roles and profiles allow you to select relevant pieces of code from modules and bundle them together to create your own custom set of code for managing things. Profiles are the individual bundles of code. Roles gather profiles together so you can assign them to nodes. This allows you to efficiently organize your Puppet code.
To illustrate roles and profiles, these steps demonstrate how to:
- Define a profile that configures virtual webhost (vhost) to serve the
example.com
website with a firewall rule. - Create a role to contain the profile.
- Assign the role to the
apache
node group.
This creates a base structure where, if you had additional websites to serve, you would create additional profiles for those sites. When you have multiple profiles, you can combine profiles within roles or create unique roles for each profile.
Because this example adds a firewall rule, make sure you add the puppetlabs/firewall
module to your Puppetfile, following the same process you used to Install the apache module. Remember to add the firewall modules
dependencies (puppetlabs/stdlib
), such
as:
mod 'puppetlabs/firewall', '2.3.2' mod 'puppetlabs/stdlib' , '4.0.0'
Related information