Learning Puppet Manifests Files with Examples for Beginners

This post will help you in Learning Puppet Manifests Files with Examples for Beginners.

We will describe you how to use and write Puppet Manifest files and manifest Syntax to understand how to manage your complete Infrastructure servers.

Also refer other puppet related articles which are very essential to understand the puppet from the beginning.,

What is puppet, how puppet works?
How to install puppet master and puppet agents?
Understand the basics of puppet manifests files with examples
Understand the basics of puppet Modules
Install Puppet Modules Online and Offline

Learning Puppet Manifests Files with Examples for Beginners

Learning Puppet Manifests Files with Examples for Beginners

What is Puppet Manifests?

Manifests are files with extension “.pp” will be created at the puppet master end, where we declare all the resource types to be managed.

Resources might be files, packages, services and so on. To know more, refer this puppet fundamentals about manifests.

Syntax of Manifests
Sample syntax:

resourcetype { ‘title’:
argument or attribute1  => value,
argument or attribute2 => value,
}

Lets take an example scenario that, we have 1000+ servers which are connected with our puppet master server. We have requirement to do some operation changes to manage your all 1000+ servers.

Scenario Requirements:
1. Modifying the file /etc/motd in all infrastructure servers to add a content using puppet automation.
2. Stopping Postfix service in all servers.

In all servers, we have already installed puppet agents and connected with puppet master. Refer this to link to install puppet master and puppet agents. Now what are actions we perform in order to do these requirements in a single server if we dont have any automation softwares not implemented like puppet.

Mainly we do these below actions for these resources file /etc/hosts and service postfix.

ALSO WATCH THIS LEARNING PUPPET MANIFESTS TUTORIAL VIDEO FREE ON OUR YOUTUBE CHANNEL

For file /etc/motd :
1. We will ensure whether the file present or not
2. If present, then we will do the required changes.
3. If need, We will change file permissions.

For service postfix.
1. We will ensure whether the service exists or not.
2. If exist, ensure its running or not
3. If running, stop it.

This is what our requirement.

Lets do these actions by writing in the puppet manifest files.

[root @puppetmaster ~] vi /etc/puppet/manifests/site.pp
node default {

file {‘/etc/motd’:
content => ‘This is my testing content’,
}
service {‘postfix’:
ensure => ‘stopped’,
enable => ‘false’,
}
}

This is how we can write the manifest files to manage our complete infrastructure servers.

Note : In the first line, we have defined to apply the changes for all default nodes which are connected to puppet master server. If you want to do these changes for one server, change as “node linuxdb1.learnitguide.net“. So changes will apply only to the particular puppet agent node.

Testing the changes at the Puppet agent client nodes:
By default, Puppet agents will give request to puppet master to check any changes for every 30mins interval or manually run the below command on one server to test.

[root @puppetagent ~] puppet agent -t

Thats all about use and write puppet manifests files to manage our infrastructure servers.

Also refer other puppet related articles which are very essential to understand the puppet from the beginning.,

What is puppet, how puppet works?
How to install puppet master and puppet agents?
Understand the basics of puppet manifests files with examples
Understand the basics of puppet Modules
Install Puppet Modules Online and Offline

Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.