Skip to content

Commit e9c5c0d

Browse files
committed
postgres: create a database with an owner already set
In the current setup databases are owned by the admin role `postgres`, and we separately grant users the permission to create their own tables in the schema `public`. I believe our intention was to make users owners of the corresponding databases, effectively granting them all permissions w/o any extra steps. This will make the tests and new databases consistent with our production instance where the database is owned by role `xsnippet-api`.
1 parent a8b2356 commit e9c5c0d

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

roles/postgres/tasks/main.yml

+4-15
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,17 @@
4242
enabled: true
4343
become: true
4444

45-
- name: Setup postgresql databases
46-
community.postgresql.postgresql_db:
47-
name: "{{ item.database }}"
48-
with_items: "{{ postgres_users }}"
49-
become: true
50-
become_user: postgres
51-
5245
- name: Setup postgresql users
5346
community.postgresql.postgresql_user:
54-
db: "{{ item.database }}"
5547
user: "{{ item.username }}"
5648
with_items: "{{ postgres_users }}"
5749
become: true
5850
become_user: postgres
5951

60-
- name: Grant users permissions to create tables in the schema `public`
61-
community.postgresql.postgresql_privs:
62-
db: "{{ item.database }}"
63-
privs: CREATE
64-
type: schema
65-
objs: public
66-
role: "{{ item.username }}"
52+
- name: Setup postgresql databases
53+
community.postgresql.postgresql_db:
54+
name: "{{ item.database }}"
55+
owner: "{{ item.username }}"
6756
with_items: "{{ postgres_users }}"
6857
become: true
6958
become_user: postgres

0 commit comments

Comments
 (0)