include postgre setup to the synapse role

This commit is contained in:
histausse 2021-07-27 04:28:48 +02:00
parent b4e5dbf548
commit b2bc03ca49
Signed by: histausse
GPG key ID: 67486F107F62E9E9
2 changed files with 22 additions and 7 deletions

View file

@ -3,6 +3,7 @@
apt:
update_cache: yes
name:
- acl # Don't ask me, required by postgresql_user
- postgresql
- postgresql-contrib
- libpq-dev
@ -45,21 +46,21 @@
become: true
become_user: postgres
postgresql_query:
query: "ALTER ROLE {{ item.name }} SET client_encoding TO 'utf8'"
loop: "{{ databases }}"
query: "ALTER ROLE {{ item }} SET client_encoding TO 'utf8'"
loop: "{{ postgres_users | map(attribute='name') }}"
- name: Set encoding
become: true
become_user: postgres
postgresql_query:
query: "ALTER ROLE {{ item.name }} SET default_transaction_isolation TO 'read committed'"
when: "{{ item.read_committed | default(false) }}"
loop: "{{ databases }}"
query: "ALTER ROLE {{ item }} SET default_transaction_isolation TO 'read committed'"
when: item.read_committed | default(false)
loop: "{{ postgres_users | map(attribute='name') }}"
- name: Set timezone
become: true
become_user: postgres
postgresql_query:
query: "ALTER ROLE {{ item.name }} SET timezone TO 'CET'"
loop: "{{ databases }}"
query: "ALTER ROLE {{ item }} SET timezone TO 'CET'"
loop: "{{ postgres_users | map(attribute='name') }}"

View file

@ -1,4 +1,18 @@
---
- name: Setup postgres
include_role:
name: postgre
vars:
postgres_users:
- name: synapse_user
password: some password for now
databases:
- name: synapse
owner: synapse_user
local: C
template: template0
- name: Install apt transport https
apt:
name: