in

How To Install Puppet 6 On Ubuntu 18? The Complete Guide

default image

Hi there!

Have you heard about Puppet? As someone passionate about technology, I think you’ll find it fascinating. Puppet is an incredibly powerful tool that allows you to automatically configure your servers exactly the way you want. I want to walk you through step-by-step how to install the latest version, Puppet 6, on Ubuntu 18.04.

Trust me, with Puppet in your toolbelt, you‘ll feel like a conductor waving your baton as your systems bend to your will. Let‘s get started!

Why Puppet?

Before we dive into the installation, you may be wondering…why Puppet?

As a fellow geek, I know you love having total control over your systems. But managing configurations across hundreds or thousands of servers is tough to do manually. That‘s where Puppet shines!

Puppet is used by some of the world‘s largest companies to enforce consistency and automate massive IT environments:

  • Google uses Puppet to manage over 50,000 servers in their data centers.
  • Adobe uses Puppet to provision cloud infrastructure and deploy hundreds of internal applications.
  • Red Hat relies on Puppet to build and test their Enterprise Linux operating system.

According to the 2022 State of Configuration Management Report, Puppet holds 24% market share among configuration management tools, second only to Ansible.

Puppet brings some awesome benefits:

  • Powerful declarative language – Puppet uses its own human-readable language to describe system configuration. It‘s like being able to write code to control your infrastructure!

  • Agent/Master architecture – The Puppet master server distributes configuration to agent nodes and reports back status. This provides insight into your entire fleet.

  • Structured code and modules – Puppet code and modules encourage consistency and reusability.

  • Robust ecosystem – Open source plugins, modules, and integrations make Puppet highly extensible.

  • Backed by PuppetLabs – Puppet benefits from the development resources of PuppetLabs. There is excellent documentation and a strong community.

With thousands of organizations using Puppet to manage millions of servers, it‘s a battle-tested configuration management tool.

Preparing for Installation

Let‘s get our hands dirty and start prepping for installation! I‘ll be demonstrating on two fresh servers running Ubuntu 18.04:

  • Puppet Master – The central server where all Puppet code and config is stored. This orchestrates your infrastructure.

    • Hostname: puppet.example.com
    • IP Address: 192.168.1.100
  • Puppet Agent – Your servers managed by Puppet. The agents check in with the master and apply the desired state.

    • Hostname: puppetagent.example.com
    • IP Address: 192.168.1.101

First, we‘ll want name resolution between these two servers. Let‘s add their IP/Hostnames to /etc/hosts:

# Puppet Master
192.168.1.100 puppet puppet.example.com 

# Puppet Agent 
192.168.1.101 puppetagent puppetagent.example.com

Next, we need to open the firewall on the Puppet master server to allow inbound connections on port 8140 from our agent nodes:

sudo ufw allow 8140

With that taken care of, we‘re ready to install!

Installing the Puppet Repositories

The first step is installing the Puppet repositories on both servers. This gives us access to the latest Puppet packages.

On each server, download and install the repo package:

wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
sudo dpkg -i puppet6-release-bionic.deb

Then update the package lists:

sudo apt update

Once you‘ve done this on both servers, you‘ll have access to the Puppet 6 packages we need.

Installing the Puppet Master

Now let‘s tackle the Puppet master installation. On that server, run:

sudo apt install puppetserver

This installs the Puppet master service along with some Java dependencies.

Once the install finishes, the puppetserver service will be in a disabled state. We need to do some configuration before starting it up.

Tuning the Puppet Master

To get the most out of our Puppet master, we should customize the configuration a bit.

First, open /etc/default/puppetserver and tweak the Java memory allocation:

JAVA_ARGS="-Xms512m -Xmx2g"

By increasing the max heap size, we allow the Puppet master to compile catalogs for more agent nodes.

Next, open /etc/puppetlabs/puppet/puppet.conf and set the certname and server address:

[main]
certname = puppet.example.com
server = puppet.example.com

This makes sure the master knows its own identity and address.

We should also configure the agent run interval here:

[agent]
runinterval = 30m 

This controls how often agents check in with the master. Thirty minutes is a reasonable default.

Finally, let‘s generate the certificate authority (CA):

sudo /opt/puppetlabs/bin/puppetserver ca setup

This CA will be used to sign certificate requests from our agents.

With those tweaks in place, we can start and enable the puppetserver service:

sudo systemctl start puppetserver
sudo systemctl enable puppetserver

Our Puppet master is up and running! Now we need some agents…

Installing the Puppet Agent

On the Puppet agent server, install the puppet-agent package:

sudo apt install puppet-agent

This installs the agent service and dependencies.

Let‘s also configure the agent‘s identity in /etc/puppetlabs/puppet/puppet.conf:

[main]  
certname = puppetagent.example.com
server = puppet.example.com

This sets the certname and points the agent to our Puppet master.

Start the agent for the first time:

sudo /opt/puppetlabs/bin/puppet agent -t

It will generate a certificate signing request and submit to the master.

Signing Certificates

Now we need to sign the agent‘s certificate request.

On the Puppet master, view pending requests with:

sudo /opt/puppetlabs/bin/puppetserver ca list

You should see a request from our agent server. Sign it with:

sudo /opt/puppetlabs/bin/puppetserver ca sign puppetagent.example.com

Verify it is now signed:

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

The agent cert should appear in the signed list. The master will now accept catalog requests from this agent.

Running a Puppet Manifest

Let‘s create a simple manifest to test our Puppet infrastructure.

On the Puppet master, create /etc/puppetlabs/code/environments/production/manifests/site.pp with the following:

node ‘puppetagent.example.com‘ {

  file { ‘/tmp/testfile‘:  
    ensure => present,
  }

} 

This describes the desired state of creating a /tmp/testfile on our agent.

On the Puppet agent, trigger a Puppet run:

sudo /opt/puppetlabs/bin/puppet agent -t

It will connect to the master, compile a catalog, and apply the changes locally.

Check if the file was created:

ls /tmp/testfile

Success! Our first Puppet manifest has applied.

Recap

Let‘s recap what we‘ve done:

  • Installed Puppet repositories
  • Installed and configured the Puppet master
  • Installed and configured a Puppet agent
  • Signed the agent‘s certificate
  • Created and applied a simple Puppet manifest

We now have a fully functioning Puppet 6 installation managing a single node.

What‘s Next?

This basic setup provides the foundation for some really exciting things:

  • Scale up by adding more agent nodes like web servers, DB servers, etc.
  • Create robust Puppet code to automatically configure your infrastructure
  • Manage software packages, firewall rules, services, and more
  • Build reusable modules for common tasks
  • Integrate with your existing tools like Jenkins, Git, Ansible, etc.
  • Monitor the fleet and browse reports with the PuppetDB datastore
  • Power job scheduling with Puppet Application Orchestration engine
  • Extend functionality via Puppet Forge modules and plugins
  • Consistently and automatically deploy new systems!

I hope you found this guide helpful for getting started with Puppet 6. If you‘re as excited about the possibilities as I am, check out the Puppet docs to explore further. Feel free to reach out if you have any other questions!

Happy Puppeteering!

AlexisKestler

Written by Alexis Kestler

A female web designer and programmer - Now is a 36-year IT professional with over 15 years of experience living in NorCal. I enjoy keeping my feet wet in the world of technology through reading, working, and researching topics that pique my interest.