Javatpoint Logo
Javatpoint Logo

Puppet Manifest

In puppet, all the programs are written in Ruby programming language and added with an extension of .pp is known as manifests. The full form of .pp is the puppet program.

Manifest files are puppet programs. This is used to manage the target host system. All the puppet programs follow the puppet coding style.

We can use a set of different kinds of resources in any manifest, which is grouped by definition and class.

Puppet manifest also supports the conditional statement. The default manifest file is available in the /etc/puppet/manifests/site.pp location.

Manifest Components

Puppet manifest has the following components:

  • Files: Files are the plain text files that can be directly deployed on your puppet clients. Such as yum.conf, httpd.con, etc.
  • Resources: Resources are the elements that we need to evaluate or change. Resources can be packages, files, etc.
  • Templates: This is used to create configuration files on nodes and which we can reuse later.
  • Nodes: Block of code where all the information and definition related to the client are defined here.
  • Classes: Classes are used to group different types of resources.

Writing Manifests

Working with Variables

Puppet provides many in-built variables that we can use in the manifest. As well as we can create our own variable to define in puppet manifest. Puppet provides different types of variables. Some frequently used variables are strings or an array of string.

Let's see an example for string variable:

Working with Loops

Loops are used to run the same set of code multiple times until a defined condition becomes true. To perform the loop, we can use an array. Let's see an example:

Using Conditionals

Puppet allows us to use different types of conditional statements. Such as if-else statement, case statements, etc. Let's see an example:


Writing a Manifest

As we know, we can create our resources. Let's start with common resources like notify resources.

In the above code, the notify is the resource, and the message is the attribute. The message has attributes that are separated from their values by a comma, which is a very general way of identifying key-value pairs in Ruby, PHP, Perl, and other scripting languages.

Create a manifest and write the above script in that manifest. For this first, you have to switch to the root user.

Puppet Manifest
Puppet Manifest

Here, we can see manifests are text files named with .pp extension. We can use any editor to create or modify manifest using any text editor.

Applying a Manifest

The main quality of the puppet is the ease of testing your code. In this, to work on puppet manifests, there is no need to configure complicated testing environments.

To apply the manifest, puppet uses apply command, which tells puppet to apply a single puppet manifest:

Puppet Manifest

Here, you can see, Puppet has successfully applied the manifest. This process done by many steps:

  • Compile or build the Puppet catalog from the manifest.
  • Employes dependency and ordering information to decide the evaluation order.
  • Evaluates the desired resource to decide if changes should be implemented.
  • Create, update, or remove the resource- A message will generate in the notice.
  • Gives verbose output about the catalog application.

Next TopicPuppet Modules

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA