lab-ansible/roles/postgresql/tasks/database.yml
2023-12-23 17:41:57 +01:00

26 lines
720 B
YAML

# vim: ft=yaml.ansible
# code: language=ansible
---
- name: Create database user '{{ db_vars.username }}'
community.postgresql.postgresql_user:
name: "{{ db_vars.username }}"
password: "{{ db_vars.password }}"
state: present
environment:
PGOPTIONS: '-c password_encryption=scram-sha-256'
- name: Create database '{{ db_name }}'
community.postgresql.postgresql_db:
name: "{{ db_name }}"
owner: "{{ db_vars.username }}"
template: template0
encoding: UTF-8
state: present
- name: Grant all priviliges to owner on database '{{ db_name }}'
community.postgresql.postgresql_privs:
database: "{{ db_name }}"
roles: "{{ db_vars.username }}"
privs: ALL
state: present