Module cheat sheet

A quick reference to Puppet module terms and concepts. For detailed explanations of Puppet module structure, terms, and concepts, see the related topics about modules.


The manifests/ directory holds the module's Puppet code.

Each .pp file contains one and only one class or defined type. The filename, without the extension, is part of the full class or defined type name.

The init.pp manifest is unique: it contains a class or defined type that is called by the module name. For example:

class apache {

Other classes and defined types are named with a modulename::filename convention. If a manifest is in a subdirectory of manifests/ , the subdirectory is included as a segment of the name.

For example:

define apache::vhost 
($port, $docroot) 
class apache::config::ssl {


You can download files in a module's files/ directory to any node. Files in this directory are served at puppet:///modules/modulename/filename.

Use the source attribute to download file contents from the server, specifying the file with a puppet:/// URL.

For example, to fetch apache/files/httpd.conf :
file {'/etc/apache2/httpd.conf':
  ensure => file,
  source => 'puppet:///modules/apache/httpd.conf',
You can also fetch files from subdirectories of files/. For example, to fetch apache/files/extra/ssl.
file {'/etc/apache2/httpd-ssl.conf':
  ensure => file,
  source => 'puppet:///modules/apache/extra/ssl',


The lib/ directory contains different types of Puppet plug-ins, which add features to Puppet and Facter. Each type of plug-in has its own subdirectory. For example:

The lib/types directory contains custom resource types:
The lib/puppet/functions directory contains custom functions:
The lib/facter directory contains custom facts:


The templates/ directory holds ERB and EPP templates.

Templates output strings that can be used in files. To use template output for a file, set the content attribute to the template function, specifying the template in a <modulename>/<filename>.<extension> format.

For example, to use the apache/templates/vhost.erb template output as file contents:

file     {'/etc/apache2/sites-enabled/wordpress.conf':
  ensure => file,
  content => template('apache/vhost.erb'),