Table of contents
1.
Introduction
2.
System Requirements
2.1.
Hardware Requirements
2.2.
Software Requirements
2.2.1.
Operating Systems
2.2.2.
Dependencies
2.3.
Network Requirements
2.3.1.
Time-Keeping
2.3.2.
Name Resolution
2.3.3.
Firewall
3.
Installation Guide
4.
Configuration
5.
Testing
6.
Frequently Asked Questions
6.1.
Do developers have to pull configuration files manually?
6.2.
What if my system configurations aren't mentioned in Puppet Server list?
6.3.
Are communications between Master and Agent nodes safe?
7.
Conclusion
Last Updated: Mar 27, 2024
Medium

Installation 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. Puppet manages the set-up, infrastructure, and configuration of servers. It does this through a combination of Master/Server and Agent nodes. 

Installation of Puppet

The master node - or the Puppet Server, is where the developers enter the desired configuration of all the agent nodes. It is then the Puppet Server's job, to propagate all the changes to all the agent nodes in the network. Puppet handles the intricacies and details of managing different hardware and OSes in the agents.

Let's now look at how we can install Puppet Agent and Puppet Server (also known as Puppet Master), and test to know how they work. 

System Requirements

As with any software, certain requirements must be met before installing it.

Let us see what those are for Puppet.

Hardware Requirements

  • Puppet Agent is versatile and can be installed on nearly any platform using any hardware. The weakest specifications tested successfully have had 2.4 GHz Processors with only 0.5-1 GB RAM.
     
  • Puppet Server, on the other hand, is resource intensive. It has to handle multiple agent nodes and configure changes across them. It must be installed on a robust and dedicated server

    The minimum hardware requirements given by the Puppet team are:
    2 cores, with 1 GB RAM, for dozens of agent nodes
    2-4 cores, with 4 GB RAM, for thousands of agent nodes. A reserved code cache of 512 MB is also needed in this case.

Software Requirements

Operating Systems

Puppet Agent supports the following OSes and versions:

Debian - 9, 10, 11

Fedora - 34 (64-bit package only), 36 (x86_64)

macOS - 10.15 Catalina, 11 Big Sur (64-bit packages only), 12 Monterey (64-bit packages only), 12 (M1)

Microsoft Windows - 10 Enterprise, 11 Enterprise (x86_64)

Microsoft Windows Server - 2012R2, 2016, 2019, 2022

Red Hat Enterprise Linux, including: - Amazon Linux v1 (using RHEL 6 packages) ,Amazon Linux v2 (using RHEL 7 packages), 6, 7, 8, 8 Power, 9

SUSE Linux Enterprise Server- 12, 15

AlmaLinux - 8 (x86_64)

Rocky Linux- 8 (x86_64)

Oracle Linux - 6 (x86_64), 6 (i386), 7 (x86_64), 7 (aarch64), 8 (x86_64), 8 (aarch64), 8 (ppc64le)

Scientific Linux - 6 (x86_64), 6 (i386), 7 (x86_64), 7 (aarch64), 8 (x86_64), 8 (aarch64), 8 (ppc64le)

Ubuntu - 18.04, 18.04 AARCH, 20.04, 20.04 AARCH, 22.04 (x86_64)

Puppet Server, only supports the following:

Red Hat Enterprise Linux - 7, 8

Debian - 9 (Stretch), 10 (Buster), 11 (Bullseye)

Ubuntu - 16.04 (Xenial, amd64 only), 18.04 (Bionic), 20.04 (Focal)

SLES0 - 12 SP1, 15 (x86_64)

Dependencies

If an official package manager, such as apt-get, or yum is being used - it will install all the dependencies along with Puppet. However, if Puppet is being installed without an official package - it is important to install the following dependencies:

  1. Ruby 2.5.x
  2. Facter 2.0 or above
  3. Optional tools such as hiera-eyaml, hocon,msgpack,ruby-shadow,etc.

Network Requirements

Time-Keeping

It is important to synchronize time between server and agent nodes. NTP (Network Time Protocol), or an equivalent service is suggested. If time drifts out of sync, then it can cause issues like outdated certificates being issued to agents. NTP keeps precise global time, with an accuracy of 50ms

Name Resolution

The agents must be able to identify the master/primary server. It needs to be ensured that the master server can be reached by all current and future agents. This can be accomplished easily by using a CNAME record, with the hostname puppet. (if this sounds confusing, don't worry. We will be doing this in the installation section)

Firewall

Primary and Agent nodes must be able to connect to each other via TCP on Port 8140.

Installation Guide

Installation Guide

For our installation guide, we will be using 2 AWS EC2 instances - that both run Ubuntu. One will be our master, the other will be the agent. You can read about EC2 instances and how to launch them here. We assume that you have 2 such instances (or any other similar computers) running and that they satisfy the requirements listed above. (Don't forget to open up Port 8140 if you're on AWS or any other Cloud Provider)

We need to open the Terminal in both of them to execute commands. This is generally done via SSH, and the method to do that varies depending on where your instances are hosted. We will start from the steps after the Terminal is active. Our tutorial will be based on Ubuntu instances, but most steps are similar for other OSes - with just the implementation varying.

1. We have both Master and Agent nodes on the Terminal. In the first step, we will run some basic setup on both. The following steps must be performed on both master and agent nodes:

Empty terminal with Master and Agent nodes connected
  • Run the command 
     
sudo apt-get update 


in the terminal. This updates all the existing packages in the instance. 

  • Enable the Puppet platform repository: 
    This makes the components needed to install Puppet available on our system. First, we will need to identify the URL of the Puppet package we want. The list of available packages is present in repositories such as yum.puppet.com or apt.puppet.com
    We are using apt, and we have identified the URL as https://apt.puppet.com/puppet7-release-focal.deb, where puppet7-release-focal.deb  is the name of the file we will install
     
  • Run the following commands:
     
wget <PACKAGE_URL>
sudo dpkg -i <FILE_NAME>.deb


For us, we will run

wget https://apt.puppet.com/puppet7-release-focal.deb
sudo dpkg -i puppet7-release-focal.deb


wget fetches the necessary files from the URL, and dpkg depackages, or unzips them so that they can be used.
 

2. Now, we will set up puppet-server, or puppet-master first.

In the master node terminal, run 

sudo apt-get install puppet-master.


You should see a screen like this:

Installing Puppet Master

Type Y, and wait for the installation to finish. The terminal will look like this:

Puppet Master installed

Restart the terminal, or run 

exec bash -l 


so that we can use puppet commands immediately.
 

3. Puppet server, by default, is created to use 2 GB of RAM. If your needs do not meet this, or if you are just testing it out, this much won't be necessary. So we will make a change in the Puppet configuration.

Run the command

sudo nano /etc/default/puppet-master 


This will open up a file in the nano text editor. You can also use vim if you prefer. The file should look like this:

Open configuration file for Puppet server

Add the line 

JAVA_ARGS="-Xms512m -Xmx512m"


anywhere in the document. This configures Puppet to use 512 MB of RAM. For 1GB, you can write 

JAVA_ARGS="-Xms1g -Xmx1g".


Save the file and exit the text editor - use Ctrl+X, Y and Enter for nano. Use :wq for vim

Restart puppet server to load using the new configuration - run the command :

sudo system-ctl restart puppet-master.



4. Let's check if we have been successful so far. Run the command

sudo systemctl status puppet-master
Check status of puppet master

We see that puppet-master server is running and active!
 

5. Allow 8140 on the firewall of the instance (this has to be done again even if you configured it in the instance network settings earlier). 

Run the command:

sudo ufw allow 8140/tcp


You should see this:

Allow port 8140 in firewall

Then, run the command: 

sudo ufw enable 


and type Y if prompted.

Enable the firewall

This enables the firewall, and sets it to only allow TCP over 8140.

To verify, run the command:

sudo ufw status. 
View status of firewall to check

If any more entries are listed, you can check and remove them according to your needs.
 

6. Now, we are ready to configure the agent. Go to the agent terminal, and run the command:

sudo apt-get install puppet. 


Type Y if prompted, and let the installation finish.

Installing Puppet Agent
Puppet Agent installed

7. Before we run puppet agent, we must make sure it can contact the master server. We do this by adding the IP address of the master server to our hosts file - in both master and server instances. The hosts file lists names and IP addresses common throughout the OS. E.g., localhost is 127.0.0.1 for all programs running on a system.
The following steps need to be done on both master and agent nodes:

  • Run the command:
     
sudo nano /etc/hosts

 

  • In the file that opens, add the line <IP Address> puppet anywhere, where <IP Address> is the IP address of your master node.
Add IP addresses to host files
  • Save and exit
     

8. In the agent node, run the command:

sudo systemctl start puppet. 


This will start the agent node.

Run the command:

sudo systemctl enable puppet. 


This will make sure that puppet can start if the instance is switched off and on.

Puppet Agent and Puppet Server have now been installed. Now, let's configure and check them.

Configuration

Behind the scenes steps in Puppet

When we do all this, a lot of stuff happens behind the scenes. 

  1. The Agent node will send a request to the Master node to request a master certificate from it. This is done so that the Agent can verify that the master node is actually the master
  2. The Master node sends the certificate to the Agent and requests a slave certificate from it
  3. The Agent sends the slave certificate to the master.
  4. The master signs the slave certificate, and sends it back to the agent.
     

So, let's go to the master node and check if the agent has sent any certificate to sign. Go to the master node, and run the command:

sudo puppet cert list. 
View Certificate Request list at master node

We get this result. We can verify this is from the agent node, as the IP matches.

Agent IP matches the request

Let's sign it and send it back. 

Run the command:

sudo puppet cert sign -- all 


in the master node. This signs all pending certificates.

Sign the certificate and send it

Testing

Now, let's test if Puppet works. 

We will configure Puppet master to create a file and verify that the file has been created in the agent node. 

In the master node, run:

sudo mkdir -p /etc/puppet/code/environments/production/manifests/
sudo nano /etc/puppet/code/environments/production/manifests/site.pp


In the file that opens, type the following:

Configure Puppet Master to create a file in agent nodes

This file should be a text file, in the /tmp directory, with the name test.txt. 

It should contain the line - The agent IP is <AGENT IP>, where <AGENT IP> would be the actual IP of the Agent.

Save it, and exit. 

Restart puppet master by running the command:

sudo systemctl restart puppet-master. 


Now, go to the Agent node. Since Puppet is based on pulling, we will have to request new configurations from the master manually. 

Run the command:

sudo puppet agent -- test
Pull configuration changes in Puppet Agent

This is the result. Let's verify if our file contains what it should. Go to the tmp directory by running 

cd /tmp

 

and see all the files in it by running 

ls
We see that Puppet Agent has created our file

We do have a test.txt here! Let's see what it contains. 

Run the command:

cat test.txt
The file contains the correct data

It contains the correct IP of the Agent node. Thus, we see, Puppet has correctly configured our Agent node.

Frequently Asked Questions

Do developers have to pull configuration files manually?

No, a background program called a daemon is run in real-life situations. This program fetches files from the master server periodically, thus eliminating the need for humans to do it manually.

What if my system configurations aren't mentioned in Puppet Server list?

Puppet Server can be run on any x86_64 Linux system with JDK 8 or 11 installed. It will have to be downloaded and compiled from the source code. Dependencies, upgrades and verification of certificates will also have to be manually managed. If your system isn't x86_64 Linux, sadly Puppet server won't run on it.

Are communications between Master and Agent nodes safe?

Yes - they are! All communications between Puppet Server and Agent nodes are encrypted with TLS. Puppet manages issuing, verification and renewal of TLS certificates so that we don't have to worry about it. 

Conclusion

This blog has explored how we can install Puppet. We have seen the necessary system requirements, including software, hardware and network. We have gone through the steps of installing Puppet and tested that the installation works.

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 :

Overview of Puppet Server
Overview of PuppetDB
Installing and Configuring Puppet Enterprise. 

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, keep reading Ninjas. 

Live masterclass