1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_collection_pretix.git synced 2024-10-28 22:01:03 +01:00
ansible_collection_pretix/roles/postgres/tasks/create_database.yml

67 lines
1.9 KiB
YAML

---
- name: Create pretix postges user
become: true
become_user: postgres
become_method: community.general.sudosu
community.postgresql.postgresql_user:
name: "{{ postgres__user }}"
password: "{{ postgres__password }}"
encrypted: true
- name: Create pretix database
become: true
become_user: postgres
become_method: community.general.sudosu
community.postgresql.postgresql_db:
name: "{{ postgres__database }}"
encoding: 'UTF-8'
lc_collate: 'de_DE.UTF-8'
lc_ctype: 'de_DE.UTF-8'
locale_provider: 'icu'
icu_locale: 'de-DE-x-icu'
template: 'template0'
- name: Make sure pretix database is owned by right user
become: true
become_user: postgres
become_method: community.general.sudosu
community.postgresql.postgresql_user:
name: "{{ postgres__user }}"
db: "{{ postgres__database }}"
password: "{{ postgres__password }}"
encrypted: true
- name: Grant ALL privileges on public schema to pretix database user
become: true
become_user: postgres
become_method: community.general.sudosu
community.postgresql.postgresql_privs:
database: "{{ postgres__database }}"
roles: "{{ postgres__user }}"
privs: 'ALL'
type: 'schema'
objs: 'public'
state: 'present'
- name: Ensure the user can create tables and objects in the public schema
become: true
become_user: postgres
become_method: community.general.sudosu
community.postgresql.postgresql_privs:
database: "{{ postgres__database }}"
roles: "{{ postgres__user }}"
privs: "CREATE,USAGE"
type: 'schema'
objs: 'public'
state: 'present'
- name: Grant create privileges on the database for pretix user
become: true
become_user: postgres
become_method: community.general.sudosu
community.postgresql.postgresql_privs:
database: "{{ postgres__database }}"
roles: "{{ postgres__user }}"
privs: "CREATE"
type: 'database'
state: 'present'