This should be very simple. I want to make an Ansible statement to create a Postgres user that has connection privileges to a specific database and select/insert/update/delete privileges to all tables within that specific database. I tried the following:
- name: Create postgres user for my app
become: yes
become_user: postgres
postgresql_user:
db: "mydatabase"
name: "myappuser"
password: "supersecretpassword"
priv: CONNECT/ALL:SELECT,INSERT,UPDATE,DELETE
I get relation \"ALL\" does not exist
If I remove ALL:
, I get Invalid privs specified for database: INSERT UPDATE SELECT DELETE
What I had to do was first create the user and then grant the privileges separately. It's working like a charm.
From ansible documentation postgressql module, priv should be "PostgreSQL privileges string in the format: table:priv1,priv2" So your task should be
Here is the playbook I use, using debian and setting up user and db, as well as giving user access to all databases:
Your paths may vary so adjust accordingly.
And for bonus here is my Vagrantfile, using virtualbox:
Cheers!