2024-06-05 10:54:55 +00:00
|
|
|
- name: Install packages
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- postgresql
|
|
|
|
- py3-psycopg2
|
|
|
|
|
|
|
|
- name: Enable services
|
|
|
|
service:
|
|
|
|
name: postgresql
|
|
|
|
enabled: true
|
|
|
|
state: started
|
|
|
|
|
|
|
|
- become: yes
|
|
|
|
become_user: postgres
|
|
|
|
block:
|
|
|
|
- name: Create database
|
|
|
|
postgresql_db:
|
|
|
|
name: '{{ database | default(user) }}'
|
|
|
|
|
|
|
|
- name: Create database user
|
|
|
|
postgresql_user:
|
|
|
|
db: '{{ database | default(user) }}'
|
|
|
|
name: '{{ user }}'
|
2024-08-15 10:57:15 +00:00
|
|
|
password: '{{ password.db_pass }}'
|
2024-06-05 10:54:55 +00:00
|
|
|
|
|
|
|
- name: Set schema owner
|
|
|
|
postgresql_owner:
|
|
|
|
db: '{{ database | default(user) }}'
|
|
|
|
new_owner: '{{ user }}'
|
|
|
|
obj_name: public
|
|
|
|
obj_type: schema
|
|
|
|
|
|
|
|
- name: Grant database privileges
|
|
|
|
postgresql_privs:
|
|
|
|
db: '{{ database | default(user) }}'
|
|
|
|
role: '{{ user }}'
|
|
|
|
privs: CREATE
|
|
|
|
type: database
|
|
|
|
|