Issues with postgres 9.2 with postgresql cookbook


#1

Having some issues with the postgresql cookbook.

Using:
postgresql-cookbook 3.0.0
ubuntu 12.04 on vagrant (but I can replicate this behaviour on a 12.04
VM in teh cloud)

The install attempts to restart the pg server nmd is suddenly very
confused about the version

Error executing action restart on resource ‘service[postgresql]’

---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.2 database server
[2013-05-24T11:05:41+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.

My recipe is basically:

node.set[‘postgresql’][‘version’] = "9.2"
node.set[‘postgresql’][‘enable_pgdg_apt’] = true

include_recipe "postgresql::apt_pgdg_postgresql"
include_recipe “postgresql::server”

Any help would be appreciated.

Cheers,
Toby


#2

I had a similar issue on CentOS.

The logic for determining service names etc was a little iffy. Not sure
about Ubuntu but you might want to have a look.

Here is the pull request I had to make for CentOS:
https://github.com/rurounijones/postgresql/commit/3e7b1b798648c3b8d524704377b9ebeca49cfe59

It may give you a clue.

On 25/05/13 13:46, Toby Hede wrote:

Having some issues with the postgresql cookbook.

Using:
postgresql-cookbook 3.0.0
ubuntu 12.04 on vagrant (but I can replicate this behaviour on a 12.04
VM in teh cloud)

The install attempts to restart the pg server nmd is suddenly very
confused about the version

Error executing action restart on resource ‘service[postgresql]’

---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.2 database server
[2013-05-24T11:05:41+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.

My recipe is basically:

node.set[‘postgresql’][‘version’] = "9.2"
node.set[‘postgresql’][‘enable_pgdg_apt’] = true

include_recipe "postgresql::apt_pgdg_postgresql"
include_recipe “postgresql::server”

Any help would be appreciated.

Cheers,
Toby


#3

As written in README of postgresql cookbook (section yum_pgdg_postgresql)

“Also use override_attributes to set a number of values that will need
to have embedded version numbers. For example:”

node[‘postgresql’][‘enable_pgdg_yum’] = true
node[‘postgresql’][‘version’] = "9.2"
node[‘postgresql’][‘dir’] = "/var/lib/pgsql/9.2/data"
node[‘postgresql’][‘client’][‘packages’] = [“postgresql92”]
node[‘postgresql’][‘server’][‘packages’] = [“postgresql92-server”]
node[‘postgresql’][‘server’][‘service_name’] = "postgresql-9.2"
node[‘postgresql’][‘contrib’][‘packages’] = [“postgresql92-contrib”]

Setting those attributes is the way this cookbook work, due to the
fact that it is necessary to change standard RHEL naming conventions.
This approach gives you the finest grained contro and, in my opinioni,
you could need such kind of control because of possible conflicts with
RHEL packages dependencies.
Off course postgresql cookbook could include also an automation for
that choices, but, in my opinion, it should be a little more
sophisticated that your proposed patch.
First of all I would check if I have
node[‘postgresql’][‘enable_pgdg_yum’] = true
and not if node[‘postgresql’][‘version’] != '8.4’
Than I would also manage all ovverrides, as explained inside readme.
On top of that I would introduce a boolean variable to choose if I
want all that stuff automatically managed, or if want fine grained
control.

Marco

On Mon, May 27, 2013 at 3:20 AM, Jeffrey Jones jjones@toppan-f.co.jp wrote:

I had a similar issue on CentOS.

The logic for determining service names etc was a little iffy. Not sure about Ubuntu but you might want to have a look.

Here is the pull request I had to make for CentOS: https://github.com/rurounijones/postgresql/commit/3e7b1b798648c3b8d524704377b9ebeca49cfe59

It may give you a clue.

On 25/05/13 13:46, Toby Hede wrote:

Having some issues with the postgresql cookbook.

Using:
postgresql-cookbook 3.0.0
ubuntu 12.04 on vagrant (but I can replicate this behaviour on a 12.04
VM in teh cloud)

The install attempts to restart the pg server nmd is suddenly very
confused about the version

Error executing action restart on resource ‘service[postgresql]’

---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.2 database server
[2013-05-24T11:05:41+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.

My recipe is basically:

node.set[‘postgresql’][‘version’] = "9.2"
node.set[‘postgresql’][‘enable_pgdg_apt’] = true

include_recipe "postgresql::apt_pgdg_postgresql"
include_recipe “postgresql::server”

Any help would be appreciated.

Cheers,
Toby


#4

Ahoi Marco,

I didn’t actually mean for this to turn into a discussion about my pull
request, maybe move the commenting on the github pull request itself?
(Or the opscode ticket).

Anyway, going back to the original bit.

Re-reading the documentation I can see why Toby didn’t make the changes
to all the settings since IMHO the apt section of the README could do
with being clearer (Having an example like the yum section would be good
for instance and explicitly saying that you will need to set them
manually.).

Re-reading the yum section in light of what you have said it makes more
sense.

But since chef tries to automatically configure some of those attributes
(packages etc.) I think it violates POLS to not do them all. It should
be an all or nothing approach which was why I wrote the pull request.

Cheers

Jeff

On 27/05/13 16:17, Marco Betti wrote:

As written in README of postgresql cookbook (section yum_pgdg_postgresql)
https://github.com/opscode-cookbooks/postgresql/blob/master/README.md

“Also use override_attributes to set a number of values that will need
to have embedded version numbers. For example:”

node[‘postgresql’][‘enable_pgdg_yum’] = true
node[‘postgresql’][‘version’] = "9.2"
node[‘postgresql’][‘dir’] = "/var/lib/pgsql/9.2/data"
node[‘postgresql’][‘client’][‘packages’] = [“postgresql92”]
node[‘postgresql’][‘server’][‘packages’] = [“postgresql92-server”]
node[‘postgresql’][‘server’][‘service_name’] = "postgresql-9.2"
node[‘postgresql’][‘contrib’][‘packages’] = [“postgresql92-contrib”]

Setting those attributes is the way this cookbook work, due to the
fact that it is necessary to change standard RHEL naming conventions.
This approach gives you the finest grained contro and, in my opinioni,
you could need such kind of control because of possible conflicts with
RHEL packages dependencies.
Off course postgresql cookbook could include also an automation for
that choices, but, in my opinion, it should be a little more
sophisticated that your proposed patch.
First of all I would check if I have
node[‘postgresql’][‘enable_pgdg_yum’] = true
and not if node[‘postgresql’][‘version’] != '8.4’
Than I would also manage all ovverrides, as explained inside readme.
On top of that I would introduce a boolean variable to choose if I
want all that stuff automatically managed, or if want fine grained
control.

Marco

On Mon, May 27, 2013 at 3:20 AM, Jeffrey Jones jjones@toppan-f.co.jp wrote:

I had a similar issue on CentOS.

The logic for determining service names etc was a little iffy. Not sure about Ubuntu but you might want to have a look.

Here is the pull request I had to make for CentOS: https://github.com/rurounijones/postgresql/commit/3e7b1b798648c3b8d524704377b9ebeca49cfe59

It may give you a clue.

On 25/05/13 13:46, Toby Hede wrote:

Having some issues with the postgresql cookbook.

Using:
postgresql-cookbook 3.0.0
ubuntu 12.04 on vagrant (but I can replicate this behaviour on a 12.04
VM in teh cloud)

The install attempts to restart the pg server nmd is suddenly very
confused about the version

Error executing action restart on resource ‘service[postgresql]’

---- Begin output of /etc/init.d/postgresql restart ----
STDOUT: * Restarting PostgreSQL 9.2 database server
[2013-05-24T11:05:41+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.

My recipe is basically:

node.set[‘postgresql’][‘version’] = "9.2"
node.set[‘postgresql’][‘enable_pgdg_apt’] = true

include_recipe "postgresql::apt_pgdg_postgresql"
include_recipe “postgresql::server”

Any help would be appreciated.

Cheers,
Toby