Table of contents
1.
Introduction
2.
Puppet Overview
2.1.
What does Puppet do?
2.2.
Why use Puppet?
3.
Puppet Platform And Architecture
3.1.
Puppet Tools
3.1.1.
Facter
3.1.2.
Catalog
3.1.3.
Reports
3.1.4.
Modules
3.1.5.
Hiera 
3.1.6.
PuppetDB
3.2.
Puppet Flow
4.
Puppet Key Concepts
4.1.
Infrastructure as Code
4.2.
Idempotency
4.3.
Agile Methodology
4.4.
Git and Version Control
5.
Puppet as a Software
5.1.
Open-Source Puppet vs Puppet Enterprise
5.2.
Puppet Release Cycle
5.3.
Managing Platform Versions
6.
Frequently Asked Questions
6.1.
Are there any alternatives to Puppet?
6.2.
Are hundreds and thousands of servers realistic?
6.3.
Isn't it better to write custom scripts to manage configurations across servers?
7.
Conclusion
Last Updated: Mar 27, 2024
Medium

Key Concepts of Puppet

Author Satvik Gupta
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Puppet is a software configuration management tool. Sounds confusing, doesn't it? 
This means Puppet is basically a software that manages how other softwares are set up, how they operate, and how we can make changes to them.

Key Concepts of Puppet

In other words, it is precisely what its name suggests - it controls other software like they're puppets! We have a central node, called the primary node - or the puppet server, that controls all the other nodes - called the agent nodes. 

Let's take a look at it in more depth.

Puppet Overview

What does Puppet do?

Puppet allows you to manage the configuration of Windows and UNIX-like (e.g., Linux) systems. When you have a large server architecture with multiple servers (sometimes they may be in the hundreds or thousands), you need an easy way to manage their configuration so that you can make updates and tests.

Puppet allows you to write the configuration of your servers as Puppet CodeWe just have to describe the desired state of our systems declaratively. Declaratively means that we don't have to describe how that desired state should be achieved - no! Puppet handles all of that for us. Puppet will see our desired state and automatically apply it across all our nodes. 

Even if all the servers run on different hardware and OS's, we won't have to manage that separately. Puppet will configure the changes to run across all hardware and OS's. All we have to do is define the desired state. 

Why use Puppet?

Puppet offers many benefits, the most important being:

  1. Consistency
    With Puppet, we can be sure that all the 100s of servers we have will consistently run the latest version of our configuration. We won't need to manage package versions, hardware configurations, OS differences, or anything. We can guarantee that whatever configuration we set up in Puppet will be active in all the nodes we want it to be in.
     
  2. Automation
    Managing many servers, with all of them having different configurations, is difficult. If we just have 5-10 servers running on the same OS with the same hardware, then Puppet will not provide much benefit. But, if we have thousands of heterogenous servers, then a tool like Puppet can help eliminate the task of managing them separately.

Puppet Platform And Architecture

Puppet Platform and Architecture

Puppet follows a server-client architecture. Puppet Server is the server software installed on one or many nodes. Puppet Agent is the client software installed on all the nodes that need to be managed. Servers and agents communicate using SSL certificates that are managed by Puppet automatically. 

Let's look at the various tools Puppet uses to perform its functions.

Puppet Tools

Facter

This is Puppet's inventory tool. It gathers facts about an agent node, such as its IP address, OS, and hardware information. The agent sends these facts to the server node, in the form of a Puppet code file called a manifest.

Catalog

The Puppet server receives the manifests and compiles a catalog, a JSON document describing the desired state of a specific node. Each agent sends requests and receives their own catalog. 

Reports

Puppet Agent enforces the desired state defined in the catalog on the node. This way, all the nodes in your architecture have the desired state you defined for them. Puppet Agent makes necessary changes and then records those changes in a report. This report is sent to the server.

Modules

Almost all the Puppet code you write, such as manifests,  will be stored in modules. Each module manages a specific task - such as adding a user, installing a piece of software, etc. Modules contain both code and data. 

Hiera 

Modules have both code and data. Data is what allows customization of the configuration. Using Puppet's Hiera tool, we can separate the data from the code and place all the data in a single, centralized location. This allows us to define parameters and variations. It makes testing, debugging and validating easier - as all data is in a single location.

PuppetDB

All of the data that Puppet generates, such as catalogs, manifests, and reports, are stored in PuppetDB. Using PuppetDB improves the performance of Puppet. It also provides an API for other applications and software to access the data that Puppet has collected. We can query PuppetDB to perform analysis and reports.

Puppet Flow

Puppet Flow
 

A typical flow of Puppet looks like this:

  1. The developer writes the manifests that contain the desired states for all of the nodes and stores them on the Puppet Server.
     
  2. An agent sends facts from Facter to the server in the form of a manifest.
     
  3. Puppet builds a graph of all the resources, their dependencies, and the order in which they need to be configured (e.g., a server software like Nginx will need to be added before a Node.js server is started). This information is stored in a catalog and sent to the agent.
     
  4. The actual state of the system is configured according to the catalog by the agent. No changes will be made if the system is already in the desired state. This makes Puppet transactions idempotent. 
     
  5. The agent sends a report to the server listing all the changes made.

Puppet Key Concepts

Puppet Key Concepts

The key concepts behind Puppet are:

Infrastructure as Code

Puppet is built around the concept that we can represent infrastructure in the form of code. This concept is the foundation behind DevOps. It is the practice of combining software development and operations. This way, system administrators adopt the same practices as software developers - such as version control, testing, reviewing, etc. This allows us to test our infrastructure the same way we test our software.

Idempotency

Idempotent simply means - that the same operation, applied multiple times, will have the same effect as if it were applied once. For example, HTTP GET requests are generally created to be idempotent. Requesting the same web page repeatedly does not affect the system state or the data in the database. 

Puppet transactions are also idempotent. If a system is already in the desired state, Puppet does not make any more changes to it. Thus, even if the server sends an agent the same catalog multiple times, the server's state will still be the desired state we want.

Agile Methodology

Agile Methodology is a software development methodology built around the concepts of working in incremental units, reusing code, and being open to changes.  Agile does not try to do everything at once - instead, we create the software (or, in this case, configurations) in incremental steps. This allows better scaling, better division of work, and increases efficiency.

Git and Version Control

Git is a version control system that is the industry standard for tracking changes in code. It allows us to work on multiple branches at once so that one new feature does not affect another new feature. It is not required to store Puppet code in a version control system, but it is recommended. 

It lets us track changes easily, work across multiple branches, review changes before they are put into production, and much more.

Check out most important Git Interview Questions here.

Puppet as a Software

Puppet manages servers and software - but it itself is also a software. We need to understand certain things about it to use it better.

Open-Source Puppet vs Puppet Enterprise

Pupper was initially released as open-source software, i.e., free to use by everyone. The source code was also openly published, meaning anyone could see it. 

Puppet Enterprise was built for commercial users - businesses and companies with many developers working in different teams. It provides all the functionality of open-source Puppet with additional features. It has GUI, point-and-click deployment, CI-CD workflows, etc. It even has the feature to predict the impact of code before its deployed.

Puppet Release Cycle

Like most software, Puppet is versioned in the format MAJOR.MINOR.PATCH, which is known as semantic versioning. It is also denoted as x.y.z. 

  1. The major version is updated when a new breaking change is introduced. 
     
  2. The minor version is updated when a minor change that is still compatible with the old versions is introduced.
     
  3. The patch version is updated when a bug fix is made, such that it’s still compatible with the older versions. 


Puppet Open-source has 2 release tracks:

  1. Update Track
    Puppet versions that aren't associated with any Puppet Enterprise versions get minor updates (y). Fixes and new features are implemented in this track. This track generally doesn't get z releases.
     
  2. Long-Term Release
    Puppet Versions that are associated with Puppet Enterprise get z releases quarterly. Each release contains bug fixes and security fixes but no new features.


Along with these, Puppet maintains tables for package versions, versions of Puppet Agent and Server - and their compatibility with each other. They are all available on the Puppet website.

Managing Platform Versions

Puppet is a tool for managing software. So naturally, it can also manage itself. We can use Puppet to manage the versions of the installed Puppet software, such as Puppet Agent and Pupper Server.

class { '::puppet_agent':
  collection      => 'puppet7',
  package_version => '7.0.0',
}


We can use this resource code to set our Puppet Agent version as 7.0.0. To upgrade to newer versions within puppet7, we can change the package_version. To upgrade from puppet7, we can simply change the collection.

Frequently Asked Questions

Are there any alternatives to Puppet?

Yes, there are. Puppet has many competitors - such as Gitlab, Ansible, Chef, etc. They have certain advantages and disadvantages over Puppet. Puppet is very widely used. Thus it has better security, acceptability, and compatibility with other software. On the other hand, some alternatives are easier to set up and use, and some offer performance improvements too.

Are hundreds and thousands of servers realistic?

This might seem like a large amount, but software has the potential to scale to hundreds of millions of users. When you have that number of users trying to access your servers from all over the world - a large number of servers becomes a necessity. Otherwise, most of your users will be left waiting or, worse, getting incorrect results.

Isn't it better to write custom scripts to manage configurations across servers?

If you have just 10-15 servers, custom scripts could work. However, in larger numbers - and heterogeneous environments, scripts soon become too complicated. Your script would need to handle different hardware and OS's, different configurations, manage security, and much more. In effect, you would be building your own version of Puppet! This would not be a good use of time since Puppet is available freely.

Conclusion

This blog has explored what Puppet is, how it functions and what its workflows are. We have seen the parts that constitute Puppet, where and why it should be used, and we have studied its key concepts in great detail. In the end, we have also seen how Puppet is as a software itself.

We hope you leave this article with a broader knowledge of Puppet, Internet architecture, and networks. We recommend that you explore our different articles on these topics as well, such as:


You can practice questions on various problems on Coding Ninjas Studio, attempt mock tests, go through interview experiences, interview bundle, go along guided paths for preparations, and a lot more!

Keep coding and keep reading Ninjas. 

Live masterclass