lab-ansible/roles/postgresql/tasks/database.yml
2024-01-09 21:56:17 +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