Install Puppet on Ubuntu5 min read

Introduction

Puppet is a powerful configuration management tool that helps in setting up the nodes/machines for the production environment. Puppet follows master-slave architecture where there is one master and one or more than one slave machines. It is available for multiple platforms such as Linux, Unix, and Windows. In this tutorial, we will be looking at the step-by-step process to install Puppet on Ubuntu 20.04. You can follow these steps for Ubuntu 18.04 as well.

Pre-requisites

  • At least 2 Ubuntu 20.04/18.04 machines. One for the puppet server/master and one for the puppet agent/client.
  • Root privileges in both the machines
  • Terminal access

Steps to install Puppet on Ubuntu

Step 1. Update the packages

Before installing Puppet, let us update the available packages. Execute the below command for the same in all the machines

sudo apt update -y

Step 2. Setting hostname

In Puppet, the server/master and the agent/client communicate with each other through hostnames and therefore we need to set a hostname along with the IP address of the master node in all the machines.

a. Open the hosts file

sudo nano /etc/hosts

b. Provide the hostname and IP address as below

[master machine ip] puppetmaster puppet 

Note: Provide the static IP of your master machine. If you are using cloud instances, provide the private IP of your master instance.

master machine
agent machine

Save and exit by pressing Ctrl+X, then type Y, and then hit the Enter key.

Step 3. Install Puppet Server on the master machine

1. Download Puppet with the below command on master machine

wget https://apt.puppetlabs.com/puppet6-release-focal.deb
Downloading Puppet on Ubuntu

2. The Puppet package is downloaded. Now, we need to install it

sudo dpkg -i puppet6-release-focal.deb

3. Update the package repository before installing the Puppet server

sudo apt update -y

4. Install Puppet server with the below command

sudo apt install puppetserver -y

5. Once the installation is complete, open the puppetserver configuration file so that we can change the memory size required for Puppet. Execute the below command

sudo nano /etc/default/puppetserver

6. Change the memory size in the following line and set memory to 512MB

JAVA_ARGS="-Xms512m -Xmx512m -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"

Save and exit. The default memory size is set to 2 GB and therefore we need to change it to a lower number as per our machine configuration.

7. Start and enable the Puppet service with the below commands

sudo systemctl start puppetserver
sudo systemctl enable puppetserver

8. Check Puppet server status with the below command to determine if it is running or not

sudo systemctl status puppetserver
install puppet on master node

Step 4. Install Puppet agent on the agent/slave node

1. Download Puppet on the agent node

wget https://apt.puppetlabs.com/puppet6-release-focal.deb

2. Once the download is complete, install the puppet package with the below command

sudo dpkg -i puppet6-release-focal.deb

3. Update the package repository before installing the Puppet agent

sudo apt-get update -y

4. Install Puppet agent by executing the below command

sudo apt-get install puppet-agent -y

5. Start and enable the Puppet agent service with the following commands

sudo systemctl start puppet
sudo systemctl enable puppet

6. Check if the Puppet agent service is running with the below command

sudo systemctl status puppet
Installed Puppet on agent node

Step 5. Sign Puppet Agent Certificate from Master machine

Once we create a Puppet Agent, we need to sign the agent certificate from the Master machine so that both get connected.

1. Execute the below command in the Master machine to list all the pending certificates. In this case, there shall be only one certificate as we have created only one agent node

sudo /opt/puppetlabs/bin/puppetserver ca list --all
puppet certificate list

2. Now sign the requested/pending certificate with the below command

sudo /opt/puppetlabs/bin/puppetserver ca sign --all

3. Once the certificate is signed, we can test the connection between the master and the agent node by executing the below command in the agent node

sudo /opt/puppetlabs/bin/puppet agent --test
Puppet master agent connection

Conclusion

Following the above steps you are able to successfully install Puppet on Ubuntu. Now you should be able to configure your nodes with this configuration management tool.

Reference


Share:

Leave a Reply