Official postgresql module from puppetlabs allow granting privileges on specific database.
postgresql::database_grant{'grant to myuser':
privilege => 'CREATE',
db => 'app_production',
role => 'myuser',
}
this would execute:
GRANT ${privilege} ON database ${db} TO ${role};
However I'd like to execute query on global permissions for given user:
ALTER role myuser login createdb;
Is there a way how to do this? Or should I use different puppet module for PostgreSQL?
The solution that works for me is to use 'postgresql::server::role' with createdb => true instead of 'postgresql::database_grant'. It makes sense as you want to alter user's global behaviour, not the one related to the particular database.
This is an example directive that adds the user along with createdb privileges:
Given 'vagrant' as the user name, this is the expected output:
Important: If you use version 2 of the module, you can use postgresql::role instead of postgresql::server::role. See https://forge.puppetlabs.com/puppetlabs/postgresql#upgrading