Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

Getting Started with Puppet Code: Manifests, Classes and Modules

A practical guide to Puppet manifests and modules: write your first .pp file, understand class declaration, build the standard module layout, use init.pp correctly, and manage Forge dependencies.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Puppet code describes the state your infrastructure should have. You write that description in UTF-8 .pp manifests, organize reusable code in modules, and let Puppet compile a node-specific catalog of resources and dependencies. A small deployment can begin with one site.pp; a maintainable team codebase usually moves logical components into modules.

What Puppet code does

Puppet is a declarative domain-specific language for configuration management. Instead of scripting every shell command in sequence, you declare facts such as “this package must be installed,” “this service must be running,” or “this file must contain this content.” Puppet evaluates the declarations, resolves relationships between resources, and compiles a catalog for one node. The catalog is the concrete plan Puppet applies to that node, even when the manifest contains conditionals for many different nodes.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This distinction matters when you design code. A manifest is source code that can describe several possible node states; a compiled catalog is the node-specific result. It is why the same main manifest can classify different machines while each machine receives only the resources that match its facts and parameters.

“Puppet is a tool that helps you manage and automate the configuration of servers.” — Puppet, Introduction to Puppet documentation

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The compile-and-apply flow

  1. Puppet reads the main manifest and any classes or modules it references.
  2. It evaluates expressions, conditionals, variables and resource relationships for the target node.
  3. It resolves the resulting resources into a catalog for that node.
  4. The agent applies the catalog, changing only resources that do not already match the declared state.

Keeping source manifests separate from compiled catalogs helps you reason about reuse, testing and failures: a syntax problem is found while parsing or compiling, while a package, file or service problem appears when the catalog is applied.

What is a Puppet manifest?

A manifest is a UTF-8 text file whose name ends in .pp. It contains Puppet code such as resource declarations, class definitions, class declarations, variables and conditional logic. Puppet evaluates the main manifest first. In the simplest layout, that file is site.pp; as the codebase grows, it becomes the place where you classify nodes and compose modules rather than a long list of every operating-system detail.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A minimal manifest

The following file declares a directory and a service. Resource titles and attributes describe the desired result; Puppet determines the provider-specific operations needed to reach it.

file { '/srv/example':
  ensure => directory,
  mode   => '0755',
}

service { 'example-service':
  ensure => running,
  enable => true,
}

Save it as site.pp in a controlled development environment and apply it with puppet apply site.pp. The command is useful for learning and local testing; production teams commonly compile catalogs through their normal server-management workflow. Run the same manifest again and Puppet evaluates the current state against the declarations instead of blindly repeating an imperative script.

Resources, attributes and relationships

A resource has a type, a title and attributes. Common types include package, file and service. Attributes such as ensure, content, source, enable and require express state and ordering. Relationships are part of the model: a service can require a package, or refresh when a managed configuration file changes. Put those relationships in the manifest or module so the catalog records the dependency explicitly rather than relying on command order.

Classes: define code once, declare it to use it

A class is a named block of Puppet code, normally stored in a module. Defining a class makes the block available; declaring the class adds its resources to the catalog. Confusing those two operations is one of the most common beginner mistakes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
class motd {
  file { '/etc/motd':
    ensure  => file,
    content => "Managed by Puppetn",
  }
}

include motd

The class motd block alone does not manage /etc/motd. The include motd declaration is what makes the class part of the node’s catalog. You can also declare a parameterized class with an explicit resource-like syntax when you need to pass values; use one declaration style consistently so the class is not accidentally declared twice.

Classes versus defined types

Classes represent a logical component that is usually included once per node, such as a web server or a monitoring agent. A defined type is a reusable resource-like template that can be instantiated multiple times with different titles, such as several similar virtual hosts. Both belong in module code, but they solve different reuse problems: class inclusion composes a component, while a defined type creates multiple instances of a pattern.

What is a Puppet module?

A module is a reusable directory structure that normally manages one technology or infrastructure task. Modules are Puppet’s basic building blocks. They can contain classes, defined types, tasks, plans, functions, resource types, providers, facts, data, examples and static files. Puppet searches the configured modulepath for these directories and loads their content by module name.

Typical module layout

example_module/
├── manifests/
│   ├── init.pp
│   ├── install.pp
│   └── config.pp
├── files/
├── data/
├── examples/
└── tasks/
  • manifests/: Puppet classes and defined types. Each .pp file normally contains one class or defined type.
  • init.pp: the conventional entry point for the module’s main class.
  • files/: static files a class can source.
  • data/: module data used to separate values from code where the module’s design supports it.
  • examples/: runnable or illustrative usage for users and maintainers.
  • tasks/: task content when the module provides operational actions in addition to catalog resources.

Not every module needs every directory. Start with manifests/init.pp and add directories only when the component has a clear need. A narrow module is easier to discover and test than a catch-all folder containing unrelated server concerns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where does init.pp go?

Put init.pp in the module’s manifests/ directory. It is special because the class inside it is referenced by the module name itself. If the directory is named example_module, manifests/init.pp conventionally contains class example_module { ... }, and you declare it with include example_module.

Other files map to namespaced class or defined-type names. The mapping makes a module’s API predictable:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
File Typical name How it is used
manifests/init.pp example_module Main class, usually included once
manifests/install.pp example_module::install Install-stage class
manifests/config.pp example_module::config Configuration-stage class
manifests/instance.pp example_module::instance Class or defined type, according to its declaration

Use lowercase module names and keep the directory name, class namespace and references aligned. A file named config.pp does not become active merely because it exists; the main class must declare it, or the site manifest must declare the namespaced class directly.

Build your first module

Move from a one-file manifest to a module when a group of resources represents one logical component, needs parameters, or will be reused on more than one node.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Prove the behavior in a small manifest. Declare one or two resources and apply them in a disposable or controlled development environment. Confirm the resulting file, package or service state before adding abstraction.
  2. Choose one responsibility. Name the module after the technology or infrastructure task it manages. Avoid putting unrelated operating-system policies in the same module simply because they are deployed to the same server.
  3. Create the standard directories. Start with example_module/manifests/init.pp. Add files/, data/, examples/ or other supported content only when the module needs them.
  4. Move the logical resources into a class. Put the component’s declarations in class example_module { ... }. Split installation and configuration into namespaced classes when that improves readability or lets callers compose stages.
  5. Declare the class from the main manifest. Use include example_module or an explicit parameterized declaration. Defining the class without declaring it leaves the catalog unchanged.
  6. Expose only useful parameters. A parameter should represent a value callers genuinely need to vary, such as a port, package setting or file source. Keep implementation details inside the module.
  7. Add an example and validate. Show the intended declaration in examples/, then parse and compile the code in the same environment that will consume it. Test both default values and meaningful overrides.

One manifest or a module-based design?

A single manifest is not wrong. It is often the fastest way to learn Puppet or manage a tiny, one-node experiment. Modules become valuable when the same logic must be reused, owned by several people or installed through a repeatable deployment pipeline.

Concern One-file manifest Module-based design
Reuse across nodes Copying or conditional branches can make reuse harder to track. Classes and defined types can be declared wherever the module is available.
Separation of concerns Files, packages and services often accumulate in one list. Each module can own one technology or infrastructure task.
Discoverability Behavior depends on finding the right section of a large file. Namespaced classes and standard directories reveal where code belongs.
Dependencies and data Values and ordering are commonly mixed into the main file. Module metadata, classes and data directories provide clearer boundaries.
Testing and documentation Examples and tests tend to be ad hoc. A module can ship examples and be tested as an independent unit.
Team or Code Manager workflow Changes converge on one central file. Modules fit repository, Puppetfile, Code Manager and r10k workflows.

There is no official quantitative benchmark that makes one structure universally faster. Choose the smallest structure that preserves clear ownership and reuse, then split a manifest when its conditional logic or resource list becomes difficult to review.

Installing and managing Forge modules

The Puppet Forge is the official repository for reusable modules from Puppet developers and the open-source community. Puppet documentation describes thousands of available modules, but the exact count changes over time; treat that figure as a broad publisher statement rather than a fixed inventory. Forge code saves time, yet teams should still expect to write custom modules for organization-specific policies and applications.

Small installation: the puppet module command

For a small installation, install a published module into the active modulepath with the Puppet command-line workflow:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
puppet module install <author>-<module>

Use the exact module name and version shown on its Forge page. If you maintain separate development and production trees, direct the command to the intended modulepath or target directory rather than installing into an arbitrary system location. After installation, declare the module’s documented class in your manifest and compile before applying it to important nodes.

Teams using Code Manager or r10k

Code Manager and r10k users normally manage dependencies with a Puppetfile. A minimal entry identifies the module and the version your environment has approved:

mod 'author-module', '1.2.3'

Commit the Puppetfile with your control repository, deploy it through the team’s normal Code Manager or r10k process, and verify that the resulting module directory is on the environment’s modulepath. Pinning a tested version makes deployments reproducible; changing a version should be treated as a code change that is compiled and tested before rollout.

Check the modulepath when Puppet cannot find a class

A successful download does not guarantee that every environment can load the module. Puppet searches its configured modulepath, which can differ between development, test and production. When you see an error that a class or module cannot be found, check the environment’s modulepath first, then confirm that the directory name matches the module name and that the class is declared with the correct namespace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep the main manifest focused

As the module library grows, keep site.pp focused on classification and composition. It should decide which classes belong on a node and pass intentional parameters, while the module owns the package, file, service and dependency details for its component. This division makes node differences visible without forcing every administrator to understand every implementation detail.

  • Declare a module once for a node unless its interface explicitly supports multiple instances.
  • Use namespaced classes such as example_module::install when a caller genuinely needs stage-level composition.
  • Keep resource relationships explicit so a configuration file can notify or require the service it affects.
  • Document required parameters and provide a working example.
  • Review module dependencies and data as part of the same change as the class that consumes them.

Common problems and practical fixes

“I defined the class, but nothing changed.”

Look for a class definition without a declaration. Add include module_name or the appropriate parameterized declaration in the node’s composition code, then compile again.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

“Puppet says the class is already declared.”

The same class may be included through two paths, or it may be declared once with include and again with resource-like syntax. Choose one declaration path and let the module’s main class coordinate its internal classes.

“The module is installed, but Puppet cannot load it.”

Inspect the active environment’s modulepath, directory name and namespace. A module installed for one environment is not automatically available to another. Also check that the class you call actually exists in the expected manifests/ file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“The file is in the module, but the node cannot receive it.”

Static content under files/ must be referenced by a resource in a declared class. Merely placing a file in the directory does not add a file resource to the catalog.

“A change applies in one environment but not another.”

Compare the deployed module version, Puppetfile lock or deployment result, modulepath and data values. Environment drift commonly comes from different module versions or from compiling a different control-repository branch.

A practical checklist before sharing a module

  • The module has one clearly stated responsibility.
  • manifests/init.pp contains the documented main class when an entry point is appropriate.
  • Each additional manifest file contains one class or defined type with a predictable namespace.
  • The main class is declared in an example or test node; a definition alone is not presented as working usage.
  • Package, file and service relationships are explicit.
  • Static files, data and examples are stored in their conventional directories.
  • External module dependencies are recorded in the chosen workflow, whether a local puppet module installation or a team-managed Puppetfile.
  • The module compiles in every environment where it is intended to run, with the expected modulepath and data.

The useful progression is simple: start with a manifest that proves the desired state, extract a class when the component becomes logical, then package that class as a module when reuse, ownership and deployment consistency matter. Puppet’s conventions—.pp manifests, a modulepath, manifests/, namespaced classes and the init.pp entry point—turn that progression into code other people can find and safely compose.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.