Timotej Lazar
8ba6959065
Let’s uncomplicate our lives. Also I’m not sure if the ~/.pgpass stuff ever worked properly or even at all.
40 lines
858 B
YAML
40 lines
858 B
YAML
- 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
|
|
|