-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgres: create a database with an owner already set #57
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,28 +42,17 @@ | |
enabled: true | ||
become: true | ||
|
||
- name: Setup postgresql databases | ||
community.postgresql.postgresql_db: | ||
name: "{{ item.database }}" | ||
with_items: "{{ postgres_users }}" | ||
become: true | ||
become_user: postgres | ||
|
||
- name: Setup postgresql users | ||
community.postgresql.postgresql_user: | ||
db: "{{ item.database }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was useless, as the option controls which database to connect to, and not which database to grant permissions on. We connect as admin role |
||
user: "{{ item.username }}" | ||
with_items: "{{ postgres_users }}" | ||
become: true | ||
become_user: postgres | ||
|
||
- name: Grant users permissions to create tables in the schema `public` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I now think that my fix in 3ccb652 was wrong an I misunderstood what changed in PostgreSQL 15. The database owner will have the necessary permissions on the schema |
||
community.postgresql.postgresql_privs: | ||
db: "{{ item.database }}" | ||
privs: CREATE | ||
type: schema | ||
objs: public | ||
role: "{{ item.username }}" | ||
- name: Setup postgresql databases | ||
community.postgresql.postgresql_db: | ||
name: "{{ item.database }}" | ||
owner: "{{ item.username }}" | ||
with_items: "{{ postgres_users }}" | ||
become: true | ||
become_user: postgres | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be executed after we create a user, or otherwise setting a database owner will fail due to non-existent role.