This article is written for those who were searching for a detailed and simple for the understanding guide on how to install PuppetDB on Ubuntu Server.

PuppetDB collects data generated by Puppet. It enables advanced Puppet features like exported resources and can be the foundation for other applications that use Puppet’s data.

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

You can read more about how to install Ubuntu Server 18.04 LTS in my guide «Installing Ubuntu Server 18.04 LTS».

Also, the server must have Puppet Server installed.

You can learn how to install Puppet on Ubuntu Server by reading «Installing Puppet on 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 the server, you can use the command:

sudo apt-get install openssh-server

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

This guide covers connecting 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 PuppetDB.

In this guide, puppet.heyvaldemar.net is used as the name of the Puppet server.

A server with an installed agent must resolve the Puppet server name not only by the main name puppet.heyvaldemar.net but also by the name puppetdb.heyvaldemar.net. The Puppet server must also resolve the name of the client-server.

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

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

By adding the path to the executable files to the variables, you can use sudo puppet agent -t instead of sudo /opt/puppetlabs/bin/puppet agent -t.

To learn how to properly prepare the Puppet server for installing PuppetDB and add the path to the Puppet executable files to the variables, you can read «Installing Puppet on Ubuntu Server».

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

Now install PostgreSQL using the command:

sudo apt-get install -y postgresql

Please note that in this guide PostgreSQL will be used as a database management system.

Now you need to create a database that will be used by PuppetDB, 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

Create a new user using the command:

createuser -DRSP puppetdb

n this manual, “puppetdb” will be used as the username, with the password “W@/Bx<dWx7Hub#=%T]J$}Gf”.

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

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

Create a new database and give it rights to the previously created user using the command:

createdb -E UTF8 -O puppetdb puppetdb

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

psql puppetdb -c 'create extension pg_trgm'

Exit from the user “postgres” using the command:

exit

Now install PuppetDB using the command:

sudo puppet resource package puppetdb ensure=latest

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

sudo puppet resource package puppetdb-termini ensure=latest

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

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

Press the “i” button to enter the editing mode, find the “subname” parameter and uncomment it by deleting the “#” symbol.

In this guide, puppetdb is used as the database name for PuppetDB.

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

classname = org.postgresql.Driver
subprotocol = postgresql

In this manual, “puppetdb” is used as the user name that has the rights to the database for PuppetDB to work.

Find the parameter “username” and uncomment it by removing the symbol “#”. Then we specify the value “puppetdb” for the parameter.

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

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

log-slow-statements = 10

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

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

sudo puppetdb ssl-setup

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

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

Press the “i” button to enter the editing mode, and add a new section “[Main]” with the following parameters:

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

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

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

By default, the PuppetDB JVM is configured to use 192 MB of RAM. You can change this value in the PuppetDB configuration file by opening it in a text editor using the command:

sudo vim /etc/default/puppetdb

Press the “i” button to enter the editing 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 manual the “Xmx” parameter will be set to 256 MB.

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

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

Press the “i” button to enter the editing mode, find the “[master]” section and add new parameters for the correct operation of PuppetDB:

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

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

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

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

Press the “i” button to enter the editing mode, then insert the following configuration:

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

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

Assign the correct permissions to files and directories for the correct operation of Puppet using the command:

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

Start PuppetDB and include it in autorun when the operating system starts up using the command:

sudo puppet resource service puppetdb ensure=running enable=true

Restart Puppet Server to apply the changes using the command:

sudo systemctl restart puppetserver

Verify that the Puppet Server has started successfully using the command:

sudo systemctl status puppetserver

Next, 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

Press on the “i” button to enter the editing mode, and add a new section “[agent]” with the following parameters:

[agent] 
report = true
pluginsync = true

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

Restart Puppet to apply the changes using the command:

sudo systemctl restart puppet

Verify that Puppet started successfully using the command:

sudo systemctl status puppet

Now you need to verify that the Puppet Agent receives the configuration from the Puppet server and connects correctly to PuppetDB using the command:

sudo puppet agent -t

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

You can now verify that PuppetDB is actually receiving data from the client-server.

Return to the server with installed Puppet Server and PuppetDB.

Open the Puppet Server log to verify the correct operation of Puppet and PuppetDB using the command:

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

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

A record should appear in the Puppet log that information has been sent and stored.

Please note that in this manual the 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.

Next, open the PuppetDB log to verify the correct operation of Puppet and PuppetDB using the command:

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

On the keyboard, press the “Shift” and “f” keys to begin to monitor changes in the PuppetDB log in real-time.

A record should appear in the PuppetDB log that information has been sent and stored.

Please note that in this manual the 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.

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

In this manual, “puppetdb” is used as the user name that has the rights to the database for PuppetDB to work.

In this guide, puppetdb is used as the database name for PuppetDB.

Connect to the puppetdb database using the command:

psql -h localhost puppetdb puppetdb

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

Enable the expanded table output mode using the command:

\x

Extract the data from the “catalogs” table to make sure that the client-server information is present in the table using the command:

select * from catalogs;

Information about the client server is indeed present in the database.

Author

Hi, 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. On my website, you will find detailed and clear guides for setting up IT solutions. Dive into the ocean, full of positive and technology! For cooperation: callvaldemar@gmail.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.