ansible/ansible — pull request #2536 by b6d (2013-03-30 22:11:50+00:00)
Title: Proposal for a module to manage PostgreSQL privileges

I manage a few PostgreSQL servers and try to automate things using Ansible.

Managing privileges using the existing module "postgresql_user" was not ideal for my use cases because not all types of privileges may be granted with it and revoking privileges may drop the connected role with it in some cases.

In my opinion managing roles and privileges are distinct enough tasks that a module for each is warranted. I've written a module for managing PostgreSQL privileges, which I hope others might find beneficial.

Commit message:

Add module postgresql_privs

This Module allows to manage privileges on PostgreSQL database objects
(currently: tables, sequences, functions, databases, schemas, languages and
tablespaces) as well as group memberships.

It is basically a wrapper around most of the functionality of PostgreSQL's
GRANT and REVOKE statements with additional detection of changes and support
for dry-runs (check-mode).

"postgresql_privs" should work with PostgreSQL 8.4 and above. Python Module
psycopg2 is required on the remote host.