synapse launches as Docker container, huray

This commit is contained in:
LUXEY Adrien 2020-06-29 18:33:37 +02:00
parent 6c254b9db0
commit 28e51ec012
6 changed files with 48 additions and 20 deletions

View file

@ -13,7 +13,10 @@ wordpress:
gitea: gitea:
version: 1.11.4 version: 1.11.4
synapse: synapse:
version: v1.14.0-py3 version: v1.15.1-py3
postgres:
pg_hba_path: "/etc/postgresql/9.6/main/pg_hba.conf"
sites: sites:
# - slug: rdb # Shorthand name to use as directory/file name # - slug: rdb # Shorthand name to use as directory/file name
@ -145,7 +148,7 @@ sites:
subnet_gateway_ip: 172.27.7.1 subnet_gateway_ip: 172.27.7.1
subnet_site_ip: 172.27.7.2 subnet_site_ip: 172.27.7.2
# PostgreSQL # PostgreSQL
postgres_host: /var/run/postgresql #postgres_host: db
postgres_database: synapse_test postgres_database: synapse_test
postgres_username: synapse_test postgres_username: synapse_test
postgres_password: "{{ vault_synapse_test_postgres_password }}" postgres_password: "{{ vault_synapse_test_postgres_password }}"

View file

@ -5,11 +5,15 @@
- name: "Create database {{ site.postgres_database }} if inexistent" - name: "Create database {{ site.postgres_database }} if inexistent"
postgresql_db: postgresql_db:
name: "{{ site.postgres_database }}" name: "{{ site.postgres_database }}"
encoding: "UTF-8"
lc_collate: "C"
lc_ctype: "C"
template: template0
state: present state: present
become: yes become: yes
become_user: postgres become_user: postgres
- name: "Add database user {{ site.postgres_username }}@{{ site.subnet_site_ip }} and grant all privileges on {{ site.postgres_database }}" - name: "Add database user {{ site.postgres_username }} and grant all privileges on {{ site.postgres_database }}"
postgresql_user: postgresql_user:
# Credentials of the new db user # Credentials of the new db user
name: "{{ site.postgres_username }}" name: "{{ site.postgres_username }}"
@ -18,4 +22,16 @@
priv: ALL priv: ALL
# host: "{{ site.subnet_site_ip }}" # host: "{{ site.subnet_site_ip }}"
become: yes become: yes
become_user: postgres
- name: "Authorize {{ site.subnet_site_ip }} to login to Postres as user {{ site.postgres_username }}"
postgresql_pg_hba:
dest: "{{ postgres.pg_hba_path }}"
contype: host
users: "{{ site.postgres_username }}"
source: "{{ site.subnet_site_ip }}"
databases: "{{ site.postgres_database }}"
method: md5
state: present
become: yes
become_user: postgres become_user: postgres

View file

@ -17,23 +17,16 @@
- name: "Create folder {{ site_data_path }}" - name: "Create folder {{ site_data_path }}"
file: file:
path: "{{ site_data_path }}" path: "{{ site_data_path }}/site"
state: directory state: directory
mode: "770" mode: "770"
group: "www-data" group: "www-data"
tags: config tags: config
# - name: "Set {{ site_data_path }} permissions"
# file:
# path: "{{ site_data_path }}"
# mode: '770'
# group: "www-data"
# become: true
# tags: config
- name: "Copy homeserver.yaml to {{ site_data_path }}" - name: "Copy homeserver.yaml to {{ site_data_path }}/site"
copy: copy:
src: "{{ sites_path }}/{{ site.slug }}/homeserver.yaml" src: "{{ sites_path }}/{{ site.slug }}/homeserver.yaml"
dest: "{{ site_data_path }}/homeserver.yaml" dest: "{{ site_data_path }}/site/homeserver.yaml"
remote_src: yes remote_src: yes
tags: config tags: config
@ -43,7 +36,7 @@
image: "matrixdotorg/synapse:{{ synapse.version }}" image: "matrixdotorg/synapse:{{ synapse.version }}"
command: "generate" command: "generate"
volumes: volumes:
- "{{ site_data_path }}:/data" - "{{ site_data_path }}/site:/data"
env: env:
SYNAPSE_SERVER_NAME: "{{ site.url }}" SYNAPSE_SERVER_NAME: "{{ site.url }}"
SYNAPSE_REPORT_STATS: "no" SYNAPSE_REPORT_STATS: "no"

View file

@ -15,11 +15,20 @@ services:
- UID={{ site.user_uid }} - UID={{ site.user_uid }}
- GID={{ site.user_gid }} - GID={{ site.user_gid }}
volumes: volumes:
- "{{ site_data_path }}:/data" - "{{ site_data_path }}/site:/data"
- "/var/run/postgresql:/var/run/postgresql"
networks: networks:
net: net:
ipv4_address: "{{ site.subnet_site_ip }}" ipv4_address: "{{ site.subnet_site_ip }}"
# db:
# image: postgres:latest
# environment:
# - POSTGRES_USER="{{ site.postgres_username }}"
# - POSTGRES_PASSWORD="{{ site.postgres_password }}"
# # ensure the database gets created correctly
# # https://github.com/matrix-org/synapse/blob/master/docs/postgres.md#set-up-database
# - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
# volumes:
# - "{{ site_data_path }}/db:/var/lib/postgresql/data"
networks: networks:
net: net:

View file

@ -219,10 +219,16 @@ listeners:
tls: false tls: false
type: http type: http
x_forwarded: true x_forwarded: true
bind_address: ['127.0.0.1', '{{ site.subnet_gateway_ip }}'] bind_addresses: ['::']
resources: resources:
- names: [client, federation] ## No compression
# - names: [client, federation]
# compress: false
## Client compression
- names: [client]
compress: true
- names: [federation]
compress: false compress: false
# example additional_resources: # example additional_resources:
@ -633,8 +639,7 @@ database:
user: "{{ site.postgres_username }}" user: "{{ site.postgres_username }}"
password: "{{ site.postgres_password }}" password: "{{ site.postgres_password }}"
database: "{{ site.postgres_database }}" database: "{{ site.postgres_database }}"
#host: "{{ site.postgres_host }}" host: "{{ site.subnet_gateway_ip }}"
host: "/var/run/postgresql"
cp_min: 5 cp_min: 5
cp_max: 10 cp_max: 10

View file

@ -1,5 +1,7 @@
--- ---
# TODO: Ensure anacron is installed
- name: Configure logrotate - name: Configure logrotate
include_tasks: logrotate.yml include_tasks: logrotate.yml
tags: logrotate tags: logrotate