This article is for those looking for a detailed and clear guide on how to install 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.

Zabbix is an open-source, enterprise-class distributed monitoring solution.

In this guide, we will consider the case when you already have a server with the Ubuntu Server 20.04 LTS operating system installed on it.

You can read more about how to install Ubuntu Server 20.04 LTS in my guide “Install Ubuntu Server 20.04 LTS”.

Also, the Puppet Server must be installed on the server.

You can find out how to install Puppet on Ubuntu Server by reading “Install Puppet на Ubuntu Server”.

In addition, 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:

sudo apt install openssh-server

If you plan to connect to the server using the Windows operating system, you can use PuTTY, a free client for various remote access protocols, including SSH, Telnet, rlogin.

This guide describes how to connect to a server using the iTerm2 terminal emulator installed on the macOS operating system.

Please note that you will need to open the following TCP ports to access your server:

  • 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:

sudo puppet agent -t

Instead:

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:

sudo apt update

Install PuppetDB on Ubuntu Server

Now install PostgreSQL using the command:

sudo apt install -y postgresql

Please note that this tutorial will use PostgreSQL as a database management system.

Install PuppetDB on Ubuntu Server

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:

sudo su - postgres

Install PuppetDB on Ubuntu Server

We create a new user using the command:

createuser -DRSP puppetdb

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

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

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

createdb -E UTF8 -O puppetdb puppetdb

Install PuppetDB on Ubuntu Server

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

psql puppetdb -c 'create extension pg_trgm'

Install PuppetDB on Ubuntu Server

Log out as user “postgres” using the command:

exit

Install PuppetDB on Ubuntu Server

Now install PuppetDB using the command:

sudo puppet resource package puppetdb ensure=latest

Install PuppetDB on Ubuntu Server

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

sudo puppet resource package puppetdb-termini ensure=latest

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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:

sudo puppetdb ssl-setup

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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

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

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

Install PuppetDB on Ubuntu Server

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:

sudo vim /etc/default/puppetdb

Install PuppetDB on Ubuntu Server

Click on 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.

Please note that in this tutorial the “Xmx” parameter will be 256 MB.

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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

---
master:
  facts:
    terminus: puppetdb
    cache: yaml

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

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

sudo puppet resource service puppetdb ensure=running enable=true

Install PuppetDB on Ubuntu Server

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

sudo systemctl restart puppetserver

Install PuppetDB on Ubuntu Server

Check that Puppet Server has started successfully using the command:

sudo systemctl status puppetserver

Install PuppetDB on Ubuntu Server

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:

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

Install PuppetDB on Ubuntu Server

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

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

Install PuppetDB on Ubuntu Server

Restart Puppet to apply the changes, using the command:

sudo systemctl restart puppet

Install PuppetDB on Ubuntu Server

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

sudo systemctl status puppet

Install PuppetDB on Ubuntu Server

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:

sudo puppet agent -t

Install PuppetDB on Ubuntu Server

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

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:

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

Install PuppetDB on Ubuntu Server

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.

Please note that 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

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

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

Install PuppetDB on Ubuntu Server

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.

Please note that 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

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:

psql -h localhost puppetdb puppetdb

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

Turn on the expanded table output mode using the command:

\x

Install PuppetDB on Ubuntu Server

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:

select * from catalogs;

Install PuppetDB on Ubuntu Server

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

Install PuppetDB on Ubuntu Server

Vladimir Mikhalev
hey, I’m Vladimir Mikhalev, but my friends call me Valdemar. I have a lot of experience in the design and maintenance of various information systems.

Recent Posts