lab-ansible/roles/postgresql/tasks/database.yml
2023-12-25 00:58:55 +01:00

25 lines
670 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
- 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 }}"
type: database
privs: ALL
state: present