After you have a good profile::baseline
, focus on developing a role to model a specific host type. Minimize test time spent repeating classification and the number of hosts affected by testing by working from the top of the abstraction triangle downwards.
Select a role to develop
Select a role to develop. Focus on getting the most impact for your time. Keep the selection process simple by staying focused on the process you want to accomplish.
Here are some ideas to help you get started:
- Avoid products and service stacks that are overly complicated.
- Avoid clustered applications.
- If you want to develop a role for a service, pick a service that has a Forge module.
- Pick a product that uses the same middleware as other products you use, for example, Tomcat, Apache, Nginx, or MySQL.
When the product or service is identified:
-
Give each role a unique descriptive name so that it’s clear what type of host it models. Keep in mind other potential roles that you’re developing. It’s likely your organization has more than one type of database server, for example, so
role::database_server
is not descriptive enough. -
Put the role into a subdirectory in your
role/manifest
directory:role/manifest/<PRODUCT_NAME>/<SERVICE_TYPE>.pp
. For example:role/manifest/firestorm/web_backend.pp
androle/manifest/firestorm/database.pp
-
Add
profile::baseline
to the role:class role::firestorm::web_backend { include profile::baseline }
-
Do research to select a module to manage your middleware or service. Go to the Forge and review available modules. Check the following for each: module dependencies, supported operating systems, module quality score, number of downloads, module release data (to verify that it is being actively developed), and whether the module is supported or approved.
-
Select a module and deploy it.
Develop required profiles based on the role
As you write a profile for the role, start small. First, manage the installation of the software, and then manage the configuration of the installed software. Some services might require a firewall port or a different configuration than profile::baseline
. Make sure that you include defaults for every parameter in the profile.
The first profile for Tomcat might look something like this:
class profile::app::tomcat::webserver (
Optional[String] $download_url = 'https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz',
Stdlib::Absolutepath $tomcat_install_path = '/opt/tomcat',
String[1] $user = 'tomcat',
String[1] $group = 'tomcat',
) {
# Installs Java, required for Tomcat
require profile::app::java
# Install of Tomcat using puppetlabs-tomcat
tomcat::install { $tomcat_install_path:
source_url => $download_url,
user => $user,
group => $group,
}
}
For this profile, you’d change the role for Tomcat to:
class role::firestorm::web_backend {
include profile::baseline
include profile::app::tomcat::webserver
}
Once Tomcat is installed and appropriate, flexible parameters are in place, update the profile to configure the software and start the service.
class profile::app::tomcat::webserver (
Optional[String] $download_url = 'https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz',
Stdlib::Absolutepath $tomcat_install_path = '/opt/tomcat',
String[1] $user = 'tomcat',
String[1] $group = 'tomcat',
String[1] $service = 'tomcat',
Integer $port = 8080,
) {
# Installs Java, required for Tomcat
require profile::app::java
# Configuration of Tomcat
class { 'tomcat':
catalina_home => $tomcat_install_path,
user => $user,
group => $group,
}
# Install of Tomcat using puppetlabs-tomcat
tomcat::install { $tomcat_install_path:
source_url => $download_url,
user => $user,
group => $group,
}
tomcat::service { $service:
require => Tomcat::Install[$tomcat_install_path]
}
contain tomcat
}
Rinse and repeat
Now that we have a method and steps to extend Puppet management with roles and profiles, we need to rinse and repeat. As you develop more and more profiles, you can develop new roles more and more quickly.
Stay focused, write good code, and happy Puppeting.
Comments
0 comments
Please sign in to leave a comment.