lab-ansible/roles/postgresql/tasks/database.yml

26 lines
720 B
YAML
Raw Normal View History

2023-11-26 16:37:17 +00:00
# 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