servers/roles/postgres/tasks/main.yml

40 lines
858 B
YAML
Raw Normal View History

- 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 }}'
password: '{{ password.db_pass }}'
- 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