0% found this document useful (0 votes)
41 views

Puppet Module Sheet

Modules provide a standard directory structure for organizing Puppet code. They can contain manifests, files, templates, and plugins that Puppet will automatically load. The modulepath setting specifies where Puppet looks for modules. Files within a module can be retrieved from Puppet's file server using puppet:/// URIs. Templates render ERB templates to generate file contents.

Uploaded by

mludas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Puppet Module Sheet

Modules provide a standard directory structure for organizing Puppet code. They can contain manifests, files, templates, and plugins that Puppet will automatically load. The modulepath setting specifies where Puppet looks for modules. Files within a module can be retrieved from Puppet's file server using puppet:/// URIs. Templates render ERB templates to generate file contents.

Uploaded by

mludas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Modules are directories with a predictable structure.

Puppet can automatically load manifests, files, and plugins from modules in its modulepath. Use puppet master --configprint modulepath to see where Puppet expects to find modules on your system.

This directory holds the module's Puppet code. Each .pp file should contain one and only one class or defined type. Filenames and class/defined type names are related; see the examples below. Within a module, the special $module_name variable always contains the module's name.

Nodes can download any files in this directory from Puppet's built-in file server. Use the source attribute to download file contents from the server. Use puppet:/// URIs to specify which file to fetch. Files in this directory are served at puppet:///modules/modulename/filename.

class apache { ... }

To fetch this file:


file {'/etc/apache2/httpd.conf': ensure => file, source => 'puppet:///modules/apache/httpd.conf', }

Init.pp is special; it should contain a class (or define) with the same name as the module.

define apache::vhost ($port, $docroot) { ... }

Puppet's file server can navigate any subdirectories:


file {'/etc/apache2/httpd-ssl.conf': ensure => file, source => 'puppet:///modules/apache/extra/ssl', }

Other classes (and defines) should be named modulename::filename (without the .pp extension).

class apache::config::ssl { ... }

Subdirectories add intermediate namespaces.

This directory holds Ruby plugins, which can add features to Puppet and Facter.

This directory holds ERB templates. Use the template function to create a string by rendering a template. Use the content attribute to fill file contents with a string. Template files are referenced as modulename/filename.erb.

To use this template: A custom type.


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

A custom function.

A custom fact.

You might also like