ansible-collections / ansible-collections/community.postgresql
It seems to be impossible to create a read only user using postgres_privs
- Dominant language
- Python
- Stars
- 144
- Forks
- 116
- Avg merge
- 4d 48m
- Merged PRs (30d)
- 9
Description
I need to create a read only user.
The only way I found out to do it was (check the bottom of this `issue`).
It should be simpler. The syntax does not help, ALL_IN_SCHEMA does not always do what it needs, it seems.
```
- community.postgresql.postgresql_query:
login_host: myhost
login_user: myuser
login_password: your_bank_password
db: "{{ item[1] }}"
query: "grant usage on schema {{ item[2] }} to {{ item[0] }}"
loop:
- [ "a_ro_user", "a_db", "a_schema"]
- community.postgresql.postgresql_query:
login_host: myhost
login_user: myuser
login_password: your_bank_password
db: "{{ item[1] }}"
query: "grant select on all tables in schema {{ item[2] }} to {{ item[0] }}"
loop:
- [ "a_ro_user", "a_db", "a_schema"]
- community.postgresql.postgresql_query:
login_host: myhost
login_user: myuser
login_password: your_bank_password
db: "{{ item[1] }}"
query: "alter default privileges in schema {{ item[2] }} grant select on tables to {{ item[0] }}"
loop:
- [ "a_ro_user", "a_db", "a_schema"]
````
Contributor guide
Research direction
Start with the postgres_privs module's syntax and ALL_IN_SCHEMA behavior, then compare it with the postgresql_query SQL examples in the issue. Done means the module offers a clear way to create the requested read-only user, including schema, existing-table, and default-table privileges.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible, postgresql, python
- Domain
- authorization, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100