This repository has been archived on 2023-12-26. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-role-postgresql-dat.../tasks/main.yml
2023-06-17 14:15:41 +02:00

38 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