puppetdb

Install PuppetDB with a module

In this blog we are installing puppetdb on a different server using the puppetlabs-puppetdb module, but first let met tell you something about facter. Facter is Puppet’s cross-platform system profiling library. It discovers and reports per-node facts, which are available in your Puppet manifests as variables.

Facter is simple command line tool which provides the node specific information.

# facter processors
{
count => 1,
isa => "x86_64",
models => [
"Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz"
],
physicalcount => 1
}
# facter osfamily
RedHat
# facter memory
{
swap => {
available => "412.00 MiB",
available_bytes => 432009216,
capacity => "0%",
total => "412.00 MiB",
total_bytes => 432009216,
used => "0 bytes",
used_bytes => 0
},
system => {
available => "1.04 GiB",
available_bytes => 1112838144,
capacity => "41.81%",
total => "1.78 GiB",
total_bytes => 1912455168,
used => "762.57 MiB",
used_bytes => 799617024
}
}

For the installation of PuppetDB we are going to use puppetlabs-puppetdb module.

# puppet module install puppetlabs-puppetdb --version 5.1.2
Notice: Preparing to install into         /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/modules
+-- puppetlabs-puppetdb (v5.1.2)
  +-- puppetlabs-firewall (v1.8.1)
  +-- puppetlabs-inifile (v1.6.0)
  +-- puppetlabs-postgresql (v4.8.0)
    +-- puppetlabs-apt (v2.3.0)
    +-- puppetlabs-concat (v2.2.0)
    +-- puppetlabs-stdlib (v4.13.1)

make sure the /etc/hosts file looks like this on the puppetmaster and the puppetdb server.

192.168.178.130 puppetmaster
192.168.178.131 puppetclient
192.168.178.132 puppetdb

The manifests must look like this:

node 'puppetmaster' {
# Here we configure the Puppet master to use PuppetDB,
# telling it the hostname of the PuppetDB node
class { 'puppetdb::master::config':
puppetdb_server => puppetdb,
}
}
node 'puppetdb' {
# Here we install and configure PostgreSQL and the PuppetDB
# database instance, and tell PostgreSQL that it should
# listen for connections to the `$postgres_host`
class { 'puppetdb::database::postgresql':
listen_addresses => puppetdb,
}
# Here we install and configure PuppetDB, and tell it where to
# find the PostgreSQL database.
class { 'puppetdb::server':
listen_address => '192.168.178.132',
database_host => puppetdb,
}
package { 'postgresql94-contrib.x86_64': ensure => 'installed'}
firewall { 'Open port 8081 for sending data to puppetdb and 8080 for dashboard view': # Firewall    implementation firewall puppet needed
          dport   => [8081,8080],
          proto  => tcp,
          action => accept,
}
}

We have to install postgresql94-contrib.x86_64, because of the following error in /var/log/puppetlabs/puppetdb/puppetdb.log

Error:
We are unable to create the recommended pg_trgm indexes due to
the extension not being installed correctly. Run the command:

CREATE EXTENSION pg_trgm;

as the database super user on the PuppetDB database to correct
this, then restart PuppetDB.

To to get rid of the error, we have to do the following.

# sudo -u postgres psql
psql (9.4.10)
Type "help" for help.
postgres-# \connect puppetdb
puppetdb=# CREATE EXTENSION pg_trgm;
CREATE EXTENSION
puppetdb=#\q

When everything is okay, you can open an url:
http://192.168.178.132:8080/pdb/dashboard/index.html?height=240&pollingInterval=1000 and you will de the following screen.

In my next blog I we will install Puppet Enterprise, which can be used for 10 nodes. I will use the long support version 2016.4.2.