Postgres user/database/permission LWRPs

Hi,

I had a look at the database cookbook for the first time today and found it
was not an approach I felt comfortable with.

All I wanted to do was create a user, a database and grant some permissions
for user on database. And I was only really concerned with postgres.
However the cookbook had several mandatory dependencies and seemingly tried
to add an abstraction across multiple databases and forced a whole bunch of
activity during the compile phase rather than in the converge phase. So I
basically rewrote them using the CLI tool rather than relying on a library.

The LWRPs usage looks something like the following (as extracted from [1]).

I am also looking to add an attribtue_driven recipe on top of this in the
future. Is this something other people are interested in?

psql_user “myuser” do
host node[‘fqdn’]
port node[‘postgresql’][‘config’][‘port’]
admin_username 'postgres’
admin_password node[‘postgresql’][‘password’][‘postgres’]
password 'secret’
end

psql_database “mydatabase” do
host node[‘fqdn’]
port node[‘postgresql’][‘config’][‘port’]
admin_username 'postgres’
admin_password node[‘postgresql’][‘password’][‘postgres’]
owner 'myuser’
template 'template_postgis’
encoding 'DEFAULT’
tablespace 'MyTablespace’
collation 'fr_FR’
connection_limit -1
end

psql_permission “myuser@mydatabase => all” do
host node[‘fqdn’]
port node[‘postgresql’][‘config’][‘port’]
admin_username 'postgres’
admin_password node[‘postgresql’][‘password’][‘postgres’]
username 'myuser’
database 'mydatabase’
permissions [‘ALL’]
end

[1] https://github.com/realityforge/chef-psql#usage


Cheers,

Peter Donald

On 12/06/2012 12:38 AM, Peter Donald wrote:

Hi,

I had a look at the database cookbook for the first time today and found
it was not an approach I felt comfortable with.

All I wanted to do was create a user, a database and grant some
permissions for user on database. And I was only really concerned with
postgres. However the cookbook had several mandatory dependencies and
seemingly tried to add an abstraction across multiple databases and
forced a whole bunch of activity during the compile phase rather than in
the converge phase. So I basically rewrote them using the CLI tool
rather than relying on a library.

The whole point of the database cookbook (AFAICT) is exactly to provide
an abstraction layer to help configure multiple database systems. If you
don't want the abstraction, there's little use, IMHO, in using the
database cookbook at all -- just use the underlying postgresql cookbook
instead.

http://community.opscode.com/cookbooks/postgresql

Best,
-jay