Watch all our Tutorials and Training Videos for Free on our Youtube Channel, Get Online Web Tools for Free on swebtools.com

Search Suggest

Learning Puppet Manifests Files with Examples for Beginners

puppet basics, puppet manifests basics, puppet manifests tutorial, puppet manifests files, puppet manifests examples, puppet manifests explained
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.


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.
Support Us: Share with your friends and groups.

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