Last Updated: February 25, 2016
· vaskas
Solarized light

Use the Opscode cookbook to install PostgreSQL 9.2 from pgdg on Debian

The Opscode PostgreSQL Chef cookbook (I'm referring to version 3.0.2) now supports installation from the PGDG repositories. Which means that you can get the latest and greatest PostgreSQL. Not so fast.

The attributes you need to set to enable the repo and 9.2 packages on Debian are:

set['postgresql']['version'] = '9.2
set['postgresql']['enable_pgdg_apt'] = true

Apparently they are not enough and you'll be getting errors like this:

Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory
/etc/postgresql/9.1/main does not exist.

and this

FATAL: could not load server certificate file "server.crt": No such file or directory ... failed!

Turns out, other settings need to be adjusted as well:

set['postgresql']['enable_pgdg_apt'] = true
set['postgresql']['dir'] = "/etc/postgresql/9.2/main"
set['postgresql']['config']['data_directory'] = "/var/lib/postgresql/9.2/main"
set['postgresql']['config']['hba_file'] = "/etc/postgresql/9.2/main/pg_hba.conf"
set['postgresql']['config']['ident_file'] = "/etc/postgresql/9.2/main/pg_ident.conf"
set['postgresql']['config']['external_pid_file'] = "/var/run/postgresql/"
set['postgresql']['config']['ssl_key_file']  = "/etc/ssl/private/ssl-cert-snakeoil.key"
set['postgresql']['config']['ssl_cert_file'] = "/etc/ssl/certs/ssl-cert-snakeoil.pem"
set['postgresql']['client']['packages']  = ["postgresql-client-9.2"]
set['postgresql']['server']['packages']  = ["postgresql-9.2"]
set['postgresql']['contrib']['packages'] = ["postgresql-contrib-9.2"]

This fixes all the relevant locations and sets the correct pgdg package names.

Say Thanks
Filed Under