akumria / puppet-postgresql

Manage and install Postgresql databases and users
37 stars 20 forks source link

Declaring users is silently ignored #11

Closed psy-q closed 11 years ago

psy-q commented 11 years ago

We declared this user in our manifest:

pg_user {'jenkins': name => 'jenkins', password => 'jenkins', ensure => 'present', createdb => 'true', createrole => 'true', superuser => 'true', }

But the role is never created. Running with --debug shows nothing about creating PostgreSQL users, but the rest of the PostgreSQL instructions (ensuring the server is up, rewriting pg_hba.conf etc.) works.

How could we debug this issue further?

akumria commented 11 years ago

I've seen that occur when the postgres user, for whatever reason, has not been created.

The lib/puppet/provider/pg_user/debian_postgresql.rb documents how the command is constructed.

So, the command to check if the role exists is:

(as root) $ su - postgres -c "psql --quiet -A -t -c \"select 1 from pg_roles where rolname = 'jenkins';\""

Does that command work when run manually?

psy-q commented 11 years ago

The command works and returns nothing (and exit code 0). So that means the role does not exist, I think pg_user should create it in this case, right?

However, the user 'jenkins' is not created even though it does not exist. The user 'postgres' exists and is a superuser (default Debian installation).

I will try to run the command generated by Puppet::Type.type(:pg_user)#create by hand if I can somehow extract the constructed command.

psy-q commented 11 years ago

It seems none of the code from ./lib/puppet/provider/pg_user/debian_postgresql.rb is ever run on our Debian machines. I can write complete nonsense all over the file and Puppet happily accepts the pg_user configuration from our node configuration, but does absolutely nothing with that.

I will try to find out why nothing is executed. Debugging Puppet seems to be a bit of a pain :(

psy-q commented 11 years ago

We didn't have pluginsync enabled, thus none of the custom types worked:

https://github.com/akumria/puppet-postgresql/pull/12

akumria commented 11 years ago

Ahh. Yes, I was going to mention that next.

I'll write-up a short section on debugging and put it into the README.