Introduction

With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying, configuring, managing and maintaining a machine or a system.

Watch this Puppet Tutorial for Beginners video

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,


In this tutorial, you will learn all about puppet and how it works and everything else you need to know about Puppet. Following is the list of all the topics that we are going to cover in this tutorial. You can click on the topics to jump to a specific one.

What is Puppet?

what is PuppetBefore we discuss what is Puppet, the most important thing you need to know is “what is configuration management?”. So, let’s start by understanding what it is.Configuration management is set of methodologies and rules, used to keep track of the current build state and design of a system. It is used to keep record of the performances, functions, design and operational information of any system.Now, coming back to Puppet, it is a configuration management technology which is available as an open source as well as enterprise version. It is developed by Puppet labs and written in Ruby DSL(Domain specific language).Puppet runs on unix-like and windows systems and is used to manage the configuration of those systems. Puppet supports Ruby and its own Puppet declarative language.

Prepare yourself for the Top DevOps Interview Questions And Answers!

Why do we use Puppet?

Puppet is one of the most popular configuration management tools in the IT world these days. It is being extensively used in Fortune500 companies as well. Most of the businesses using DevOps methodologies are getting inclined towards using Puppet. There are multiple reasons explaining why it is coming out on top when compared with other configuration management tool such as chef:

  • Puppet provides more platform support. For example, following are the platforms you can manage using Puppet:
    •  Debian/ Ubuntu
    •  Microsoft Windows
    •  Redhat, Centos, Fedora
    •  MACOS X Server
  • Puppet has better documentation
  • Unlike other configuration management tools, Puppet, after deploying a configuration on any system keeps verifying those configurations after certain intervals. These intervals can be modified by you too.
  • Puppet is being used by some of the major organizations in the industry like Google, Red hat, etc
  • Puppet helps DevOps professionals and System administrators to work faster and smarter

Watch this interesting video on ‘Install Kubernetes?’:

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

Understanding Puppet architecture and Puppet components

Understanding Puppet architecture and Puppet components
Become Master of DevOps by going through this online DevOps training in London.
Puppet follows the client-server architecture where the client is what we call Puppet agent and the server is what we call the puppet master. Following are the components of Puppet architecture:

  • Puppet Master: Puppet master is what that handles the entire configuration related information. Puppet master runs on designated server and manages the entre deployments, configuration etc.
  • Puppet Agent: Puppet agent runs on the client. Puppet agents are the actual working machines maintained and managed by puppet master
  • Config Repository: Config Repository is where the entire server related configurations and nodes are stored. They canbe pulled anytime they are required
  • Facts: They are the global variables containing details related to the machine such as operating system and network interfaces. They are used to analyze the current status of any node.
  • Catalogue: All the configurations that are written in puppet are converted to a compiled format which is called catalogue and then those catalogs are applied in the target system.
  • Manifests: Manifests are the files where all the resources, that is, services, packages or files that need to be checked and changed are declared. Manifests have the extension “.pp”.
  • Module: A module is a collection of manifest files organized in a way that it facilitates the sharing of the files.
  • Class: Puppet like other programming languages also has classes to organize the codes better, making it easier to read and understand the code and to reuse some parts of the code.
  • Resources: In puppet codes, the coding block that is defined by declaring resources where resources may represent packages, files, users, commands.
  • Nodes: All the servers or clients that are to be managed where puppet agents installed are called the nodes.

Watch this interesting video on DevOps Training

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

How does Puppet work?

How does Puppet work
Knowing the components of Puppet architecture is all good and fine but how does it work?
Puppet has a simple yet efficient workflow. The puppet master contains all the configuration information for different nodes that the puppet master controls, using manifests.
Go through the Best DevOps Course in New York to get clear understanding of DevOps.
Let’s understand the workflow of puppet step by step:

  • The nodes that the puppet master controls have Puppet agent installed on them. The agent collects all the configuration information about their particular nodes using facts. Agents then send facts to the puppet master.
  • After gaining all the information, the puppet master compiles a catalogue based on the information on how the nodes should be configured.Puppet master then sends back the catalogue to Agents.
  • Each Agent then uses those catalogues and the information in them to make necessary configuration updates on their nodes and then reports back to Puppet master.
  • Puppet master can also share the reports with a third party tool if needed.

Connection between Puppet Master Server and Puppet Agent Nodes

As you can see that Puppet master and Puppet agent have to communicate with each other in order to let the puppet work seamlessly.  But how exactly do they communicate?
How the Puppet connections are getting established between puppet master server and Puppet agent nodes
Puppet master communicates with puppet agent via HTTPS (HyperText Transfer Protocol Secure) with client verification. Puppet master provides an HTTP interface. Whenever puppet agent has to make a request or submissions to puppet master it just makes an HTTPS request to one of the endpoints available in the HTTP interface provided by puppet master.

Puppet installation and Configuration in Linux

Pre-installation tasks

Before getting to the installation part you need to perform some pre-installation tasks as mentioned below.
1. Decide what type of Deployment you are going to use:
You can choose between the following types of deployment:

  • Master/Agent Puppet:

Master/Agent puppet is most commonly used as it is more convenient when it comes to updating the configurations.
This set up requires a central server where you run a central puppet master service. This master server is basically the host of all your configuration data. On other nodes, the puppet agent services run. Agent servers pull the configurations from master. All agents get their own configurations and they are independent of other agents, hence unable to see how the others are configured in the system. Before installing puppet, if you decide to go for master/agent deployment then you first need to decide which server will act as the puppet master. Puppet masters are not supported in windows. Only after installing puppet on your puppet master should you move to the installation on any agent nodes.
You also need to ensure that the system you are using fulfils the following requirements:

    • Fast processor
    • Lots of RAM
    • Fast disk
    • Reachable at a reliable hostname
  • Standalone:

In case of Standalone Puppet all the nodes use puppet apply command to compile the configurations and to apply them. They all use full set of Puppet modules and manifests meaning that they all need same files that are required by puppet Master in case of Master/Agent Puppet, so there is no Puppet master or Puppet slave in this type of deployment of Puppet. This helps is distributing and reducing the load of compilation unlike in Master/ Agent where all the burden of compilation is concentrated on Puppet Master. This may seem like a benefit and it is in some cases but mostly it faces issues when working with central reporting and external data sources. In case of Master/Agent, Puppet master take care of central reporting and external data sources. In Standalone Puppet every node is aware of how other nodes are configured.
2. Check your OS versions and System requirements:

  • If your system is running on OS versionwith official packages you will have an easier install path
  • If your system is running an unsupported OS, it may still run puppet, so long as the Ruby version you are using is supported. Given that you will have to follow a more complex install path.

Watch this interesting video on DevOps Project

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

3. Checking your Network Configurations:
If you are Deploying Master/Agent Puppet then this is a must step for you.

  • Firewalls: ensure that that the puppet master server allows and is able to handle incoming connections on port 8140. Also the agent nodes should be able to make the connection to the master on that same port.
  • Hostname: Every node should have a unique hostname
  • DNS configuration: Both the forward and reverse DNS should be configured properly.

Note: The default hostname of the puppet master is puppet.
4. Checking the timekeeping:
The puppet master should have itssystem time set accurately because if it isn’t then the certificate that is to be issued to the puppet master will be from past so it will be treated as expired by the other nodes.

Learn more about DevOps in this DevOps training in Sydney to get ahead in your career!

Installation

After being done with the pre-installs tasks let’s start with the installation. We will be showing the commands step by step to install puppet on RHEL
Step 1: Enabling the Puppet package Repository
Run the following command to enable the repository:

sudo rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm

Step 2: (optional) enabling the prereleases
Use the following command to enable prereleases

[puppetlabs-devel]name=Puppet Labs Devel <%= @dist.capitalize -%><%= @version -%> - $basearch

baseurl=https://yum.puppetlabs.com/<%= @dist.downcase -%>/<%= @codename -%>/devel/$basearch

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs

enabled=1

gpgcheck=1

To disable, just set the value of enabled back to 0.
Step 3: To upgrade the puppet master to latest version, run the following command

sudo puppet resource package puppet-server ensure=latest

Restart the puppet master after upgrading
Step 4: Installing the Agent nodes:
On all the other nodes run the following command

sudo yum install puppet

Step 5: To upgrade the puppet agent, use the following command

sudo puppet resource package puppet ensure=latest

After all the above steps, Puppet is now installed but still not configured. Just follow the following steps and your puppet will be configured in no time:

Watch this interesting video on ‘Who Is a DevOps Engineer?’:

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,


If you have any doubts or Queries related to DevOps, get it clarifies from DevOps Experts on DevOps Community.

Configurations

Step 1: Creating Puppet master’s certificate.
You need to make sure that you have a main name for Puppet services at your site and that the DNS resolves it to puppet master.
Go to “main” section of the puppet.conf file of master and make a list of comma separated hostname that the master is allowed to use and set that as the value of

dns_alt_names:

dns_alt_names =puppet,puppet.example.com,puppetmaster,puppetmaster.example.com

To generate the puppet certificate, use the following command:

sudo puppet master --verbose --no-daemonize

press ctrl+C once it displays the Puppet master version.

Watch this interesting video on CI CD Pipeline Using Jenkins

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,


Step 2: Starting and enabling the puppet master service
Use the following command

systemctl start puppetmastersystemctl enable puppetmaster

Step 3: Configuring the agent node:
In the agent section of the puppet.conf file of agent node, add:

server= puppet.example.com

Step 4: use the following command to start the puppet agent service:

sudo puppet resource service <NAME> ensure=running enable=true

(In windows, to start the agent service, just omit the sudo from the command)
Step 5: Generating signing request for puppet agent node:
When the agent nodes attempt to run for the first time, they will request certificates. The admin has to approve the certificates.
Log into the puppet master and run the following command to view the outstanding requests:

sudo puppet cert list

Run the following command to sign all requests:

sudo puppet cert sign --all

step 6: Use the following command to start and enable the puppet agent:

systemctl start puppetsystemctl enable puppet

Step 7: To verify if the certificates were signed properly, use the following command

puppet agent --fingerprint

And with this last command, your puppet is all installed, configured and ready to be used.
Wondering what’s next?
Well, next comes, turning your infrastructure administration into a codebase, describing all the processes required for the configuration management of a server. How do you do that? Let’s understand that in the next section of the tutorial.
Interested in becoming DevOps Expert? Click here to learn more in this DevOps Course in Toronto!

Understanding Puppet Manifest files – How to use and write Puppet manifest files

For the process of configuration management using puppet you will have to create a set of provisioning scripts or puppet codes that will configure our systems. Puppet code is primarily composed of manifests.

 Let’s look a little deeper into Puppet Manifest through this Video

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

What are Puppet manifest files?

Puppet manifest files are the files where all the resources, that is, services, packages or files that need to be checked and changed are declared. Puppet manifest files are created on the Puppet master end and have the extension “.pp”.
Manifest files consist of the following components:

  • Files: Plain text files that are to be imported and placed in the target location
  • Resources: Resources represent the element that you need to evaluate or change. Resources can be files, Packages etc.
  • Node definition: A block of code in puppet where all the information and definition about the client node is defined.
  • Templates: Templates are used to create configuration files on nodes and can be reused later.
  • Classes: Classes is what we use to group together different types of resources.

Syntax of manifest file

Following is the syntax for writing a basic manifest file:

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

Why do we need Puppet manifest?

Writing manifest files is the closest to what you might consider as puppet programming. Manifest files are used to define how resources should be configured. Manifest files are where we declare the resources and are the fundamental component for puppet codes. Manifests are the building blocks of the complex Puppet modules.

Interested in getting an industry-recognized certification in DevOps? Enroll in Intellipaat’s DevOps Course in Bangalore now!

Writing a basic manifest file with examples

Let’s start off by writing the most basic and smallest component of the manifest file, that is, Resource.

file { 'intellipaat_file':ensure => present,
path   => 'intellipaat_file.txt', }

Note: When writing multiple resources, keep in mind that the resources of the same type cannot have the same title. However you can use same title for different types of resources as that will not cause any conflicts.
It’s also important to know that in case of multiple resources puppet does not evaluate and execute the resources in the same sequence as they are defined. You have to explicitly define the priority and dependency between all the resources that you have defined.
For example:
In the following code block, we have defined two types of resources, first one is a package and the other is an exec package which implies that it is a command. When you use a package resource, make sure that it is installed. The before keyword is used to make sure that the Package resource is executed before the command.

package { 'curl':ensure => 'installed'
before => Exec['install script']
}
exec { 'install script':
command => '/usr/bin/curl'
}

Also, notice that the exec package (lowercase) is used for declaring the resources however we use Exec (uppercase) with already defined resources.

Watch this video on Nagios Installation for Beginners:

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

How to automate the changes using puppet to all infrastructure servers?

Example:
Objective: To modify the etc/motd file in all infrastructure servers and use puppet automation to add content of our choice in that file.
Note:For those of you who aren’t familiar with the /etc/motd file, it is a file available on Unix-like system. This file consists of a message referred to as the “message of the day”.
Steps to implement the above example:

  • Making sure that the file is present
  • If present, then making the required changes
  • Changing the file permissions (optional)

Following is the code block of manifest file to perform the above mentioned operations:

file {'/etc/motd':name    => '/etc/motd'
ensure=> present,
owner   => 'root',
group   => 'root',
content => 'The Testing content', }
}

In this example, the resource type is a file and the title is /etc/motd. The content that we have added to the file is “The Testing content”.

Understanding Puppet Modules

What is Puppet Module?

Modules are where you will keep all your Puppet codes. There is a specific task for each module in your infrastructure, for example, installing and configuring a part of software. Basically modules are self contained collection of manifest files and data, such as facts, files and templates having a specific directory structure. This directory structure allows puppet to load and find classes, facts, functions, defined types and tasks.
While naming a module you need to make sure that the name only consists of lowercase letters.
Modules cannot be nested and that is why module names cannot have namespace separator(::) between them.

Why do we need Puppet Modules?

Modules are very useful when it comes to organizing the puppet code. Modules in puppet provide a means to split the code in multiple manifests. They are reusable which makes it very favorable to use modules. Using modules in puppet is considered best practice to organize the manifest files. Using Modules also provides another benefit, that is, code sharing. Since modules are self contained you can just include any model from anywhere and drop it onto the module path.

Now, you know the most important skill set of a DevOps Engineer. But, do you know, DevOps Engineers are among the highest paid professionals in the technology domain? so join DevOps training in Hyderabad!

Do we really require programming Language for writing puppet modules?

Keeping it crisp and clear, yes, for writing modules in Puppet you do need a programming language. Having a basic knowledge of what are classes and manifests and how to write the manifests and the syntax, will definitely help and is required if you are writing puppet modules.
Although, for those who do not have a basic programming knowledge, there is one more option if they want to use puppet modules. They can use pre-existing Puppet modules. But what exactly are these pre-existing puppet modules?
Moving further in the tutorial let’s learn more about pre-existing Puppet modules.

What are pre-existing puppet modules?

The open source puppet and puppet enterprise IT automation software have huge communities. These pre-existing puppet modules are written and developed by the folks of these communities only. Anyone can contribute to writing these pre-existing modules. These modules are public and available for anyone to download, install and use.
Currently there are over 5000+ pre existing puppet modules for anyone to use.
Now that we know what are pre-existing puppet modules let’s see how to download one of these.

Watch this interesting video on ‘Lean vs Agile vs Waterfall’:

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

Installation of Puppet Modules online and offline

We will be downloading Vim module from puppet forge which will install and configure vim package, you can download any module by following the same steps.
Before downloading Vim module, for those who are not familiar with vim package, vim is a popular, free andopen source text editor.

How to install Puppet modules manually?

Step 1: Click here or visit the official puppet forge website.
Clicking on the above provided link will take you to a web page that looks like the following screenshot:
How to install Puppet modules manually
Step 2: Enter the name of the module that you want to download in the search bar under “what do you want to automate”. In our case we are looking for vim module as you can see in the following screenshot:
Step 2
Step 3: You will find multiple results for your search, choose the appropriate one. You can click on the individual module to look at the basic introduction of the module so as to make your choice. In our case we have chosen the dhoppe vim module.
step 3
Step 4: To download the module just click on download latest.tar.gz and you will get the module in tarball.
Step 4

How to install the module after downloading it?

Execute the following command in the master server to install the module from the tarball.

puppet module install /path/dhoppe-vim-1.4.1.tar.gz

Note: The “path” is the path to the directory where you have saved the tarball.

Get in touch with Intellipaat for a comprehensive DevOps Training and be a certified DevOps Engineer!

How to install Puppet modules online?

You can also search and install the module from the puppet module tool using the following command:

puppet module install dhoppe-vim –version 1.4.1

Before executing this command make sure you are using the latest version of the module in the command.

You can go through this DevOps end to end video lecture where our expert is discussing each & every nuance of the technology.

Puppet Tutorial Introduction With the advancement in DevOps, the use cases and applications of puppet has also increased. Puppet is one of the earliest configuration management tools that came into play and hence has gained a huge community of supporters and users. Puppet is a powerful tool when it comes to deploying,

Conclusion

Puppet is on its way to becoming a de facto standard for configuration management. More than 75% of the Fortune 100 companies are using Puppet these days. With Puppet in the picture, the system administrators are now able to do all those tasks that were once considered tedious to do. The tasks such as testing, maintaining, operating and enforcing the changes in software, regardless of where it runs, don’t make the system administrators sweat anymore since this DevOps tool, Puppet came to the rescue
To learn puppet in detail, checkout the DevOps Certification training by Intellipaat where along with Puppet, you will also get to learn about other DevOps tools such as Git, Jenkins, Chef .

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
27 × 10 =