11
Jan

Create Puppet modules using Classes

A Puppet module is a reusable unit of manifest code, similar to functions or methods in procedural languages. A Puppet module can be defined in either of the following ways:

  1. Using classes
  2. Using defined types

In this article, I’m going to explain how to create a Puppet module using Classes. A Puppet class can be considered to be a container for resources. It is defined once and selected by all nodes that need to make use of the prepared functionality. Each class represents a well-known subset of a system’s configuration.

Here is the syntax of the class.

1
 class name { type {‘name’: attribute => value, } type {‘name’: attribute => value, } }
First thing you need to do is to create directory structure for your module. It needs to be created under “modules” directory present in your Puppet home directory (on most of the systems, Puppet home directory is /etc/puppet)

Here are step by step instructions: Continue reading

7
Jan

How to define a Puppet Resource

A Puppet resource is a fundamental unit for modelling system configurations. Each resource describes some aspect of the system, e.g. Service, Package, File, etc. The block of Puppet code that describes a resource is called resource declaration.

Every resource has a type, title and set of attributes.

Syntax:

1
 type {“title”: property => value, }


Example:
1
 package {“apache2”: ensure => installed, }
Continue reading