Chapter 13. Designing a Custom Module
In this chapter, we will review the process of creating a custom module. We will cover each step from the beginning, including:
- Naming a module properly
- Generating an empty module skeleton
- Writing the base manifest
- Identifying files to be copied to the node
- Creating templates to customize files on the node
- Testing that the module works as expected
Let’s get started.
Choosing a Module Name
A module can have any name that begins with a letter and contains only lowercase letters, numbers, underscores. A hyphen is not allowed within a module name. Here are some valid and invalid module names:
mymodule |
Valid |
3files |
Invalid |
busy_people |
Valid |
busy-people |
Invalid |
It is important to choose your module name carefully to avoid conflicts with other modules. As each module creates its own namespace, only one module may exist within a Puppet catalog with a given name at the same time. For most intents and purposes, this means that you can never use two modules with the same name.
When naming modules, I try to avoid naming the module anything that conflicts with a module name available in the Puppet Forge. I never know when another team might utilize that module for its project, or when a module I download might use the Puppet Forge module as a dependency.
Note
It’s possible to manage conflicting module names by utilizing them within separate environments. We’ll cover how to do this in Chapter 29.Avoiding Reserved Names
Some namespaces are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access