Puppet Modules and How to Use them

What are Puppet Modules and How to Use them?

How to do automation tasks using Puppet modules and how they differ to manifests. In previous articles I discussed What is Puppet, How to install it and Puppet Manifests Basics.

Puppet Module

Puppet Module

What are Puppet Modules ?

Puppet modules are mainly for organizing and breaking your code into simpler and smaller files. For modules you can write your own or even download pre-made ones.

Does Puppet Modules Require Programming Skills ?

Short answer is yes. But even if you don't have these skills still you can learn how to use a lot of pre-made modules which will make your life much easier.


How to Download Puppet Modules ?

There are two ways to download and install Puppet Modules, either by downloading it manually and installing it or by using the Puppet Module Installer.


Find Modules and Install Them

  1. Go to forge.puppet.com which is the official Puppet site for modules.
  2. Search for any keyword. Ex.: I searched for HTTPD and i found a lot of modules like one will install the Apache and make me manage all the configuration.
  3. Select the desired module. "In this example I selected this Apache Module"
  4. In that page you will find several info like what Puppet versions are supported, which Linux flavors and version along with how to install and examples.
  5. Now you can either download manually or install from command line, below is the manual install :
    1. To download click on "download latest tar.gz" link. Download it to your Puppet Master server.
    2. Now run below command against the downloaded file.

      puppet module install blah-blah-blah.tar.gz

      Tips: If you get errors you can use --ignore-dependency and also if the module is there and you want to overwrite it use --force.

  6. Or install directly using similar to below commandpuppet module install apache_httpd --version 1.4.1
  7. To add the Module you need simply to add something similar to below example, below showing httpd as this is the module i downloaded.

Without parameters:

class { 'apache_httpd': }

With parameters:

class { 'apache_httpd':
  mpm       => 'worker',
  modules   => [ 'mime', 'setenvif', 'alias', 'proxy', 'cgi' ],
  keepalive => 'On',
  user      => 'git',
  group     => 'git',



Additional Puppet Modules Tips:

Search for specific module from command line:

puppet module search httpd

List all modules by using:

Puppet module list

Run Puppet in agent without waiting

puppet agent -t

Define module path

puppet apply --modulepath /etc/koko/module/

Subscribe to
for video tutorials updates