39 lines
898 B
YAML
39 lines
898 B
YAML
|
- name: Create database user
|
||
|
postgresql_user:
|
||
|
name: "{{ database_name }}"
|
||
|
password: "{{ database_password }}"
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
notify: restart postgres
|
||
|
|
||
|
- name: Create database
|
||
|
postgresql_db:
|
||
|
name: "{{ database_name }}"
|
||
|
owner: "{{ database_user }}"
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
notify: restart postgres
|
||
|
|
||
|
- name: Grant access to database
|
||
|
postgresql_privs:
|
||
|
type: database
|
||
|
database: "{{ database_name }}"
|
||
|
role: "{{ database_user }}"
|
||
|
grant_option: no
|
||
|
privs: all
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
notify: restart postgres
|
||
|
|
||
|
- name: Allow remote access to database
|
||
|
postgresql_pg_hba:
|
||
|
dest: /etc/postgresql/15/main/pg_hba.conf
|
||
|
contype: host
|
||
|
databases: "{{ database_name }}"
|
||
|
users: "{{ database_user }}"
|
||
|
address: all
|
||
|
create: true
|
||
|
become: true
|
||
|
become_user: postgres
|
||
|
notify: restart postgres
|