2086 words
10 minutes

Install PuppetDB on Ubuntu Server

Cover image for Install PuppetDB on Ubuntu Server

This article is for those looking for a detailed and straightforward guide on installing PuppetDB on Ubuntu Server.

PuppetDB is a scalable and reliable data store for Puppet. PuppetDB collects data generated by Puppet and also provides advanced functionality based on a powerful API.

IMPORTANT

The Puppet Server must be installed on the server.

For step-by-step instructions on installing Puppet on Ubuntu Server, see Install Puppet на Ubuntu Server.

IMPORTANT

OpenSSH must be installed on the server, and port 22 must be open in order to be able to connect to the server using the SSH protocol.

To install OpenSSH on a server, you can use the command:

Terminal window
sudo apt install openssh-server
NOTE

To connect to the server from a Windows system, you can use tools like PuTTY or MobaXterm.

NOTE

This guide walks you through connecting to a server with the iTerm2 terminal emulator on macOS.

CAUTION

You will need to open the following TCP ports for access to the services:

  • TCP port 8081 - for Puppet Agent to work.

This tutorial uses puppet.heyvaldemar.net as the Puppet server name.

The server with the agent installed must resolve the Puppet server name not only by the base name puppet.heyvaldemar.net but also by the name puppetdb.heyvaldemar.net. Also, the Puppet server has to resolve the name of the client-server.

Make sure the Puppet server and client-server have the correct DNS records and update the “/etc/hosts” file if necessary.

Puppet binaries are located in the “/opt/puppetlabs/bin/” directory, which is not in the “PATH” environment variable by default and in the “secure_path” variable that is used for “sudo” operations.

By adding the path to executable files to variables, you can use:

Terminal window
sudo puppet agent -t

Instead:

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

You can learn how to properly prepare the Puppet server to install PuppetDB and add the path to the Puppet executables to variables by reading Install Puppet on Ubuntu Server.

We connect to the Puppet server on which you plan to install PuppetDB.

Update the local package index to the latest changes in the repositories using the command:

Terminal window
sudo apt update

Install PuppetDB on Ubuntu Server - Step 1

Now install PostgreSQL using the command:

Terminal window
sudo apt install -y postgresql
NOTE

This tutorial will use PostgreSQL as a database management system.

Install PuppetDB on Ubuntu Server - Step 2

Now you need to create a database that PuppetDB will use in the future, as well as a user with the necessary rights in this database.

Switch to the “postgres” user who has administrator rights in PostgreSQL using the command:

Terminal window
sudo su - postgres

Install PuppetDB on Ubuntu Server - Step 3

We create a new user using the command:

Terminal window
createuser -DRSP puppetdb
NOTE

In this tutorial, “puppetdb” will be used as the username, with the password sqhrgX8G*RCaYURftzoG89b.

Install PuppetDB on Ubuntu Server - Step 4

Specify a strong password for the new user and press the “Enter” button.

Install PuppetDB on Ubuntu Server - Step 5

Enter the password again and press the “Enter” button.

Install PuppetDB on Ubuntu Server - Step 6

We create a new database and grant the rights to it to the previously created user using the command:

Terminal window
createdb -E UTF8 -O puppetdb puppetdb

Install PuppetDB on Ubuntu Server - Step 7

Next, you need to install the “pg_trgm” index extension optimized for RegExp using the command:

Terminal window
psql puppetdb -c 'create extension pg_trgm'

Install PuppetDB on Ubuntu Server - Step 8

Log out as user “postgres” using the command:

Terminal window
exit

Install PuppetDB on Ubuntu Server - Step 9

Now install PuppetDB using the command:

Terminal window
sudo puppet resource package puppetdb ensure=latest

Install PuppetDB on Ubuntu Server - Step 10

Next, install additional Ruby plugins to use PuppetDB using the command:

Terminal window
sudo puppet resource package puppetdb-termini ensure=latest

Install PuppetDB on Ubuntu Server - Step 11

Now you need to make changes to the PuppetDB configuration file by opening it in a text editor using the command:

Terminal window
sudo vim /etc/puppetlabs/puppetdb/conf.d/database.ini

Install PuppetDB on Ubuntu Server - Step 12

NOTE

In this tutorial, the database for PuppetDB is on the same server as Puppet.

Press the “i” button to switch to edit mode, find the “subname” parameter and uncomment it by removing the ”#” symbol.

This tutorial uses “puppetdb” as the database name for PuppetDB.

Next, add new parameters “classname” and “subprotocol” with the following values:

classname = org.postgresql.Driver
subprotocol = postgresql

This tutorial uses “puppetdb” as the database username for PuppetDB.

Find the “username” parameter and uncomment it by removing the ”#” symbol. Then we set the parameter to “puppetdb”.

Find the “password” parameter and uncomment it by removing the ”#” symbol. Then, as a value for the parameter, specify the password assigned to the “puppetdb” user.

Next, add a new parameter “log-slow-statements” with the following value:

log-slow-statements = 10

Install PuppetDB on Ubuntu Server - Step 13

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install PuppetDB on Ubuntu Server - Step 14

Check that the certificates that will be used by PuppetDB are generated and the configuration file “jetty.ini” contains the correct values using the command:

Terminal window
sudo puppetdb ssl-setup

Install PuppetDB on Ubuntu Server - Step 15

Next, you need to create a configuration file for PuppetDB to work correctly using the command:

Terminal window
sudo vim /etc/puppetlabs/puppet/puppetdb.conf

Install PuppetDB on Ubuntu Server - Step 16

Press the “i” button to switch to edit mode, and add a new section [main] with the following parameters:

[main]
server_urls = https://puppet.heyvaldemar.net:8081
NOTE

In this tutorial, the Puppet Server is installed on the puppet.heyvaldemar.net server. You will need to specify your server through which your Puppet Server will be accessible from the Internet or on the local network of your organization.

Install PuppetDB on Ubuntu Server - Step 17

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install PuppetDB on Ubuntu Server - Step 18

By default, PuppetDB JVM is configured to use 192 MB of RAM. This value can be changed in the PuppetDB config file by opening it in a text editor using the command:

Terminal window
sudo vim /etc/default/puppetdb

Install PuppetDB on Ubuntu Server - Step 19

Hit the “i” button to go into edit mode, find the line JAVA_ARGS="-Xmx192m" and change the Xmx parameter in accordance with the requirements for your PuppetDB server.

NOTE

In this tutorial the Xmx parameter will be 256 MB.

Install PuppetDB on Ubuntu Server - Step 20

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install PuppetDB on Ubuntu Server - Step 21

Next, you need to make changes to the Puppet configuration file by opening it in a text editor using the command:

Terminal window
sudo vim /etc/puppetlabs/puppet/puppet.conf

Install PuppetDB on Ubuntu Server - Step 22

Hit the “i” button to go into edit mode, find the [master] section, and add new parameters for PuppetDB to work correctly:

[master]
storeconfigs = true
storeconfigs_backend = puppetdb
reports = store,puppetdb
reportstore = /var/log/puppetlabs/puppet

Install PuppetDB on Ubuntu Server - Step 23

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install PuppetDB on Ubuntu Server - Step 24

Now let’s create a configuration file “routes.yaml” so that information from PuppetDB can be used in Puppet using the command:

Terminal window
sudo vim /etc/puppetlabs/puppet/routes.yaml

Install PuppetDB on Ubuntu Server - Step 25

Hit the “i” button to go into edit mode, then insert the following configuration:

[master]
facts_terminus = puppetdb
facts_cache = yaml

Install PuppetDB on Ubuntu Server - Step 26

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install PuppetDB on Ubuntu Server - Step 27

Assign the correct permissions to files and directories for Puppet to work correctly using the command:

Terminal window
sudo chown -R puppet:puppet `sudo puppet config print confdir`

Install PuppetDB on Ubuntu Server - Step 28

Launch PuppetDB and enable it to autostart when the operating system starts up using the command:

Terminal window
sudo puppet resource service puppetdb ensure=running enable=true

Install PuppetDB on Ubuntu Server - Step 29

Restart Puppet Server to apply the changes made using the command:

Terminal window
sudo systemctl restart puppetserver

Install PuppetDB on Ubuntu Server - Step 30

Check that Puppet Server has started successfully using the command:

Terminal window
sudo systemctl status puppetserver

Install PuppetDB on Ubuntu Server - Step 31

Next, we connect to the server on which the Puppet Agent is installed.

Now you need to make changes to the Puppet configuration file by opening it in a text editor using the command:

Terminal window
sudo vim /etc/puppetlabs/puppet/puppet.conf

Install PuppetDB on Ubuntu Server - Step 32

Press the “i” button to switch to edit mode and add a new [agent] section with the following parameters:

[agent]
report = true
pluginsync = true

Install PuppetDB on Ubuntu Server - Step 33

Now press the “Esc” button to exit edit mode, then type "" and press the “Enter” button to save your changes and exit the editor.

Install PuppetDB on Ubuntu Server - Step 34

Restart Puppet to apply the changes, using the command:

Terminal window
sudo systemctl restart puppet

Install PuppetDB on Ubuntu Server - Step 35

Let’s check that Puppet has started successfully using the command:

Terminal window
sudo systemctl status puppet

Install PuppetDB on Ubuntu Server - Step 36

Now you need to check that the Puppet Agent will receive the configuration from the Puppet server and correctly connect to PuppetDB using the command:

Terminal window
sudo puppet agent -t

Install PuppetDB on Ubuntu Server - Step 37

The Puppet Agent ran without errors and successfully received the configuration from the Puppet server and also successfully connected to PuppetDB.

Install PuppetDB on Ubuntu Server - Step 38

Now you can check that PuppetDB is actually receiving data from the client-server.

We return to the server with Puppet Server and PuppetDB installed.

Open the Puppet Server log to check the correctness of Puppet and PuppetDB using the command:

Terminal window
sudo less /var/log/puppetlabs/puppetserver/puppetserver.log

Install PuppetDB on Ubuntu Server - Step 39

On the keyboard, press the “Shift” and “f” keys to start monitoring changes in the Puppet log in real-time.

The Puppet log should show a record that the information has been sent and saved.

NOTE

In this tutorial Puppet Agent is installed on the puppet-agent.heyvaldemar.net server.

On the keyboard, press the key combination “Ctrl” and “c”, then “q” to close the Puppet log.

Install PuppetDB on Ubuntu Server - Step 40

Next, open the PuppetDB log to check the correctness of Puppet and PuppetDB using the command:

Terminal window
sudo less /var/log/puppetlabs/puppetdb/puppetdb.log

Install PuppetDB on Ubuntu Server - Step 41

On the keyboard, press the key combination “Shift” and “f” to start monitoring changes in the PuppetDB log in real-time.

The PuppetDB log should show a record that the information has been sent and saved.

NOTE

In this tutorial Puppet Agent is installed on the puppet-agent.heyvaldemar.net server.

On the keyboard, press the key combination “Ctrl” and “c”, then “q” to close the PuppetDB log.

Install PuppetDB on Ubuntu Server - Step 42

Now you can verify that the data from the client-server has been successfully transferred to the “puppetdb” database.

This tutorial uses “puppetdb” as the database username for PuppetDB.

This tutorial uses “puppetdb” as the database name for PuppetDB.

Connect to the “puppetdb” database using the command:

Terminal window
psql -h localhost puppetdb puppetdb

Install PuppetDB on Ubuntu Server - Step 43

Specify the password assigned to the user “puppetdb” and press the “Enter” button.

Install PuppetDB on Ubuntu Server - Step 44

Turn on the expanded table output mode using the command:

Terminal window
\x

Install PuppetDB on Ubuntu Server - Step 45

Let’s extract data from the “catalogs” table to make sure that information about the client-server is present in the table using the command:

Terminal window
select * from catalogs;

Install PuppetDB on Ubuntu Server - Step 46

The client-server information is indeed present in the database.

Install PuppetDB on Ubuntu Server - Step 47


Social Channels#


Community of IT Experts#


Is this content AI-generated?

No. Every article on this blog is written by me personally, drawing on decades of hands-on IT experience and a genuine passion for technology.

I use AI tools exclusively to help polish grammar and ensure my technical guidance is as clear as possible. However, the core ideas, strategic insights, and step-by-step solutions are entirely my own, born from real-world work.

Because of this human-and-AI partnership, some detection tools might flag this content. You can be confident, though, that the expertise is authentic. My goal is to share road-tested knowledge you can trust.

Install PuppetDB on Ubuntu Server
https://www.heyvaldemar.com/install-puppetdb-on-ubuntu-server/
Author
Vladimir Mikhalev
Published at
2021-04-19
License
CC BY-NC-SA 4.0