Puppetlabs-Postgresql: A Puppet Enterprise Supported Module
So, you've upgraded to Puppet Enterprise 3.2, and you want to get started with the new supported modules. Or you are thinking about upgrading, and want some idea of how it's going to affect your most commonly used modules, such as puppetlabs-postgresql.
Let's try installing puppetlabs-posgresql on your Puppet Master and see what comes up:
Hmmm. What happened there?
Puppet Labs has been shipping the postgresql module for configuring PuppetDB since the release of Puppet Enterprise 3.0.0. In our recent release of Puppet Enterprise 3.2, we updated our setup of PuppetDB so it is no longer dependent on the puppetlabs-postgresql module.
However, we are still shipping the same version of the postgresql module to ensure a stable base for your Puppet code. Any code you wrote against the version of puppetlabs-postgresql that shipped with earlier versions of Puppet Enterprise will continue to work with Puppet Enterprise 3.2 — but now you can freely upgrade your postgresql module to the newest version, without any worries.
If you have not yet upgraded to Puppet Enterprise 3.2, you should not upgrade puppetlabs-postgresql, because it will break functionality of the pe_puppetdb module. However, there are plenty of other, and even better, reasons to upgrade to Puppet Enterprise 3.2, including the fact that puppetlabs-postgresql is supported only if you are running Puppet Enterprise 3.2. You can read more about the benefits of upgrading to Puppet Enterprise 3.2 here.
For those of you who do not have any code relying on the older version of the postgresql module, we can go ahead and install the new version with the
Now that the module is installed, we can write some actual Puppet code with it.
Let's Install PostgreSQL with Puppet
You will want to run the following code on a node other than your Puppet Master. The Puppet Master already has PostgreSQL running on it as the backend to the Puppet Enterprise Console and to PuppetDB. Trying to manage two instances of PostgreSQL on the same node is not recommended.
If you just want to test out the module with defaults, you could simply apply the
postgresql::server class to your node and you'll get the default version of PostgreSQL from your distro's repos.
A more interesting use case is to get the newest version of PostgreSQL installed and managed. At this time, the newest version is 9.3.
You can see that, in order to change the version, you also need to allow the module to manage the package repo so it can point to a repo that has the newer version.
Maybe You Want to Connect to PostgreSQL from Another Server
In order to allow connecting from another host, you're going to need to modify
pg_hba.conf to allow remote connections and
postgresql.conf to change the listening interface. Let's see how we can do that within the module.
Upon applying that manifest to our PostgreSQL server, it will edit both
pg_hba.conf, then restart the postgresql-9.3 service so the changes are in effect. That means you can log in from, in this case, 10.20.1.3.
What Good is PostgreSQL Without a Database?
So you've installed PostgreSQL, made sure the service is started, and configured connection settings so you can remotely connect to your instance. None of this will be very helpful unless you also create a database to store some data in.
From your PostgreSQL server, you can now verify that the database has been created.
Voila! You have a PostgreSQL 9.3 instance that you can connect to from another server, and you’ve created a database called “my_application_database”. Now all you need to do is write an application that uses your new database, and you’re off and running.
Nick Walker is a support engineer at Puppet Labs.
- Read all about the Puppet Enterprise supported modules program.
- Interested in use cases and example code for other new supported modules? Read about puppetlabs-registry, puppetlabs-ntp and puppetlabs-apache.
- Supported modules are just one of the improvements you'll find in Puppet Enterprise 3.2.
- Search the Forge for modules you need by compatibility with your operating system and version of Puppet or Puppet Enterprise.