This brief tutorial shows students and new users how to install and manage Puppet automation server and agent on Ubuntu 20.04 | 18.04 LTS.
Puppet is an open source, cross-platform, enterprise automation tool that allows IT admins to automate infrastructure and complex workflows enabling continuous compliance in a simply, yet powerful way.
Puppet can be setup in a client – server model that has multiple modules from Puppet orchestrator to Puppet Access to Code Manger and PuppetDB.
This tutorial should not serve as complete documentation for Puppet implementation. Use other resources along with the guide below to get Puppet installed in your environment.
To get started with Puppet in Ubuntu, follow the steps below:
For this tutorial, we’re going to be using Ubuntu as our Puppet master or Puppet server. In this case you’ll want to prepare Ubuntu in order to get Puppet working correctly.
Run the commands below to open Ubuntu hosts file.
sudo nano /etc/hosts
Then define or add Puppet server and client IP in the file. For this tutorial, our Puppet server IP is 192.168.1.1 and Puppet client IP is 192.168.1.2.
192.168.1.1 puppetmaster puppet 192.168.1.2 puppetclient
Save the file and exit.
Add Puppet Repository
Now that Ubuntu server has IP defined, run the commands below to add Puppet 7 release repository.
cd /tmp wget https://apt.puppetlabs.com/puppet7-release-focal.deb
After that, run the commands below to install the repository.
sudo apt install ./puppet7-release-focal.deb
Install Puppet Server
Now that the repository is installed, run the commands below to install Puppet Server.
sudo apt update sudo apt install puppetserver
That should install the server on Ubuntu. After installing, the commands below can be used to stop, start and enable server to automatically start up when the server boots.
sudo systemctl stop puppetserver sudo systemctl start puppetserver sudo systemctl enable puppetserver
To validate that Puppet is installed and ready, run the commands below.
sudo systemctl status puppetserver
That should display similar lines as shown below
● puppetserver.service - puppetserver Service Loaded: loaded (/lib/systemd/system/puppetserver.service; enabled; vendor > Active: active (running) since Sun 2021-04-11 20:03:05 CDT; 21s ago Main PID: 5746 (java) Tasks: 44 (limit: 4915) Memory: 980.8M CGroup: /system.slice/puppetserver.service └─5746 /usr/bin/java -Xms2g -Xmx2g -Djruby.logger.class=com.puppet> Apr 11 20:02:19 ubuntu2004 systemd: Starting puppetserver Service… Apr 11 20:03:05 ubuntu2004 systemd: Started puppetserver Service.
I you have Ubuntu firewall enable then make sure to allow this port through the firewall.
sudo ufw allow 8140/tcp
Install Puppet Agent
Now that the server is install, switch to the client node and install Puppet client version on the node. For this tutorial, we’re going to be using Ubuntu machine as our client node.
Puppet agents and the master servers communicate over an encrypted tunnel (HTTPS) with client verification. To install Puppet client on Ubuntu, use the commands below to download and install Puppet client repository.
cd /tmp/ wget https://apt.puppetlabs.com/puppet7-release-focal.deb sudo apt install ./puppet7-release-focal.deb
After installing the repository above, run the commands below to install Puppet agent.
sudo apt update sudo apt install puppet-agent
On the client, run the commands below to open Puppet configuration file.
sudo nano /etc/puppetlabs/puppet/puppet.conf
Then add the highlighted lines below to define Puppet master server. You should make sure these hostnames are defined in the /etc/hosts file on the client.
# This file can be used to override the default puppet settings. # See the following links for more details on what settings are available: # - https://puppet.com/docs/puppet/latest/config_important_settings.html # - https://puppet.com/docs/puppet/latest/config_about_settings.html # - https://puppet.com/docs/puppet/latest/config_file_main.html # - https://puppet.com/docs/puppet/latest/configuration.html [main] certname = puppetclient server = puppetmaster
Save the exit.
After installing, the commands below can be used to stop, start and enable Puppet agent to automatically start up when the client boots.
sudo systemctl stop puppet sudo systemctl start puppet sudo systemctl enable puppet
To verify that Puppet agent is installed and running, run the commands below:
sudo systemctl status puppet
That should display similar lines as shown below:
● puppet.service - Puppet agent Loaded: loaded (/lib/systemd/system/puppet.service; enabled; vendor preset> Active: active (running) since Mon 2021-04-12 08:41:39 CDT; 1min 22s ago Main PID: 2562 (puppet) Tasks: 1 (limit: 4648) Memory: 78.2M CGroup: /system.slice/puppet.service └─2562 /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/puppet/bin/> Apr 12 08:41:39 Ubuntu2010 systemd: Started Puppet agent.
Sign Puppet Agent Certificates
Now switch back to the back to the server node and run the commands below to list all available certificates on the server.
sudo /opt/puppetlabs/bin/puppetserver ca list --all
That should display lists of certificates found. Now run the commands below to sign all the certificates listed.
sudo /opt/puppetlabs/bin/puppetserver ca sign --all
That should do it!
Now go back to Puppet client node and run the commands below to test communication between client and server nodes.
sudo /opt/puppetlabs/bin/puppet agent --test
If communication is successful, then your job is done. You can now start configuring your server tasks.
This post showed you how to install Puppet server and client nodes on Ubuntu. If you find any error above, please use the form below to report.
You may also like the post below: