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