Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PostgreSQL 9.2 with Chef postgresql

I am struggling to get PostgreSQL 9.2 installed with the Opscode postgresql cookbook on a Vagrant VM (Ubuntu 12.04) .

This is the my recipe:

node.set['postgresql']['version']             = "9.2"
node.set['postgresql']['enable_pgdg_apt']     = true
node.set['postgresql']['password']            = {postgres: "pwd"}
node.set['postgresql']['server']['packages']  = ["postgresql-9.2"]

include_recipe "postgresql::apt_pgdg_postgresql"
include_recipe "postgresql::server"
include_recipe "database"

The run results in the following:

[2013-05-23T11:00:52+00:00] FATAL: Chef::Exceptions::EnclosingDirectoryDoesNotExist:
template[/etc/postgresql/9.2/main/postgresql.conf] (postgresql::server line 60) had an error: 
Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/postgresql/9.2/main does not exist.

I am using the latest 3.0.0 version of the poostgresql cookbook.

Rerunning everything from scratch with a clean VM (vagrant destroy, up, etc) gives this error:

[2013-05-23T11:16:37+00:00] FATAL: Chef::Exceptions::EnclosingDirectoryDoesNotExist:
template[/etc/postgresql/9.1/main/postgresql.conf] (postgresql::server line 60) had an error: 
Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /etc/postgresql/9.1/main does not exist.

Suddenly we don't even have the right version.

like image 956
Toby Hede Avatar asked May 23 '13 11:05

Toby Hede


2 Answers

Here's what finally fixed it for me:

  1. run update-alternatives --remove postmaster.1.gz /usr/share/postgresql/9.1/man/man1/postmaster.1.gz

  2. Use the conf below.

Snip:

postgresql: {
    enable_pgdg_apt: true,
    dir: "/etc/postgresql/9.2/main",
    config: {
        data_directory: "/var/lib/postgresql/9.2/main",
        hba_file: "/etc/postgresql/9.2/main/pg_hba.conf",
        ident_file: "/etc/postgresql/9.2/main/pg_ident.conf",
        external_pid_file: "/var/run/postgresql/9.2-main.pid",
        ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key",
        ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem",
    },
    client: {
        packages: ["postgresql-client-9.2",],
    },
    server: {
        packages: ["postgresql-9.2", "postgresql-server-dev-9.2"],
    },
    contrib: {
        packages: ["postgresql-contrib-9.2"],
    },
    password: {
      postgres: 'postgres'
    },
    pg_hba: [
      {type: 'local', db: 'all', user: 'all', addr: nil, method: 'trust'},
      {type: 'host', db: 'all', user: 'all', addr: '127.0.0.1/32', method: 'trust'},
      {type: 'host', db: 'all', user: 'all', addr: '::1/128', method: 'trust'}
    ],
    version: "9.2",
},
like image 135
skoczen Avatar answered Sep 18 '22 23:09

skoczen


I was able to fix this by setting the directory:

node.set['postgresql']['dir'] = "/var/lib/postgresql/9.2/main"

Looks like this is the same issue: http://tickets.opscode.com/browse/COOK-2113

like image 31
Rich Aston Avatar answered Sep 22 '22 23:09

Rich Aston