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.
manifests/
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:
apache/manifests/init.pp
:
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:
apache/manifests/vhost.pp
: define apache::vhost
($port, $docroot)
{
...
}
apache/manifests/config/ssl.pp
:class apache::config::ssl {
...
}
files/
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.
apache/files/httpd.conf
:file {'/etc/apache2/httpd.conf':
ensure => file,
source => 'puppet:///modules/apache/httpd.conf',
files/
. For
example, to fetch apache/files/extra/ssl
.file {'/etc/apache2/httpd-ssl.conf':
ensure => file,
source => 'puppet:///modules/apache/extra/ssl',
}
lib/
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:
lib/types
directory contains custom resource types:
apache/lib/puppet/type/apache_setting.rb
The lib/puppet/functions
directory contains custom
functions:
apache/lib/puppet/functions/apache/bool2httpd.rb
The
lib/facter
directory contains custom facts:
apache/lib/facter/apache_confdir.rb
templates/
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'),
}