Introduction
Puppet is an open-source configuration management tool used to perform administrative tasks and server management remotely. The official Puppet Server packages are designed to support Linux distributions exclusively.
However, the Puppet agent application, used for creating client nodes, is available on a broader range of operating systems, including Linux, Unix, Windows, and macOS.
In this step-by-step tutorial, we will cover the installation of Puppet on Ubuntu 20.04 and 22.04 on master and client nodes.
Prerequisites
- Two systems running Ubuntu (one for the master node and one or more for client nodes).
- Access to an account with sudo privileges.
- Access to the terminal.
How to Install Puppet on Ubuntu 20.04 and 22.04
The Puppet installation process for Ubuntu 20.04 and 22.04 is the same. The following text elaborates on the necessary steps to get Puppet on these Ubuntu versions.
Step 1: Update Package List
Before starting the installation process, update the list of available packages on both nodes. Run the following command:
sudo apt update
The output on the master and the client nodes is the same:
Step 2: Set up Hostname Resolution
With Puppet, master and client nodes communicate using hostnames. Before installing Puppet, set up a unique hostname on each node. Take the following steps:
1. Open the hosts file on each node via a text editor. For example, use Vim:
sudo vim /etc/hosts
2. Paste the following lines at the end of each hosts file:
[puppet master ip] puppetmaster puppet
[puppet client ip] puppetclient
Replace [puppet master ip]
with the master node IP address, and [puppet client ip]
with the client node IP address.
3. Save and exit the file on both machines.
Step 3: Install Puppet Server (Master Node)
1. Download the latest Puppet version on the master node:
wget https://apt.puppetlabs.com/puppet8-release-jammy.deb
In our case, the latest release is 8. Replace the package URL from the command above with the version you want to install.
Note: If you are using Ubuntu 20.04, replace jammy
with focal
in the command. The command should be: wget https://apt.puppetlabs.com/puppet8-release-focal.deb
.
2. Once the download is complete, install the package by using:
sudo dpkg -i puppet8-release-jammy.deb
Note: On Ubuntu 20.04, replace jammy
with focal
in the command.
3. Update the package repository again:
sudo apt update
4. Install the Puppet server with the following command:
sudo apt install puppetserver
5. Open the puppetserver file by using:
sudo vim /etc/default/puppetserver
6. Modify Xms
and Xmx
values in the following line to change the memory settings to 1GB:
JAVA_ARGS="-Xms1g -Xmx1g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
7. Save and exit the file.
8. Start the Puppet service.
sudo systemctl start puppetserver
9. Enable the Puppet service to start on boot with:
sudo systemctl enable puppetserver
10. Check if the Puppet service is running with:
sudo systemctl status puppetserver
Step 4: Install and Configure Puppet Agent (Client Node)
1. Download the latest version of Puppet on a client node. Use the following command:
wget https://apt.puppetlabs.com/puppet8-release-jammy.deb
Note that the latest version is 8 at the time of writing the article. Change the package URL to install the desired version.
Note: If you are using Ubuntu 20.04, replace jammy
with focal
in the command.
2. Once the download is complete, install the package by using:
sudo dpkg -i puppet8-release-jammy.deb
Note: If you are using Ubuntu 20.04, replace jammy
with focal
in the command.
3. Update the package repository one more time:
sudo apt update
4. Install the Puppet agent by using:
sudo apt install puppet-agent
5. Open the Puppet configuration file:
sudo nano /etc/puppetlabs/puppet/puppet.conf
6. Add the following lines to the end of the Puppet configuration file to define the Puppet master information:
[main]
certname = puppetclient
server = puppetmaster
7. Save and exit the file.
8. Start the Puppet service with the following command :
sudo systemctl start puppet
9. Set Puppet to launch on system boot by using:
sudo systemctl enable puppet
Step 5: Check Puppet Agent Status
Check if the Puppet service is running with:
sudo systemctl status puppet
The output shows active (running).
Step 6: Sign Puppet Agent Certificate
1. Using the Puppet master node, list all the available certificates:
sudo /opt/puppetlabs/bin/puppetserver ca list --all
2. Sign the certificates with:
sudo /opt/puppetlabs/bin/puppetserver ca sign --all
The command either has no output or confirms the certificate is successfully signed.
Troubleshooting a Puppet Installation
Following the steps above generally results in a successful installation. However, users sometimes encounter issues while going through the installation process.
The following text presents the two most common Puppet installation issues and their solutions.
Issue 1: DNS Misconfiguration
When installing Puppet, a common issue is misconfigured DNS. Correct DNS configuration is crucial for a successful installation.
Solution
Ensure DNS is configured correctly for the installation to fix this issue. Use tools like nslookup or dig to confirm DNS resolution.
Confirm the agent is able to reach the primary server using the designated hostname. To validate this, perform a network test from the agent machine.
Issue 2: Security Settings Misconfiguration
Another potential problem during Puppet installation is misconfigured security settings, including firewall configurations.
Solution
Ensure the firewall settings are correctly configured to allow Puppet-related traffic. Verify inbound traffic is permitted on ports 8140 and 443 on the primary server, which are crucial for Puppet communication.
If the primary server has multiple network interfaces, ensure it allows traffic via the IP address corresponding to the valid DNS names. Avoid restricting traffic only to internal interfaces.
Conclusion
After following this tutorial, you have fully set up Puppet master and client nodes on Ubuntu 20.04 and 22.04. This configuration management tool helps automate the server infrastructure management and configuration.
Learn more about Puppet by finding out how it stacks up against Terraform in our article Terraform vs Puppet.