Update to 2020-05-06 11:00

master
Daniel Berteaud 5 years ago
parent 70f44c4b1a
commit 02658bcadd
  1. 3
      roles/matrix_synapse/meta/main.yml
  2. 3
      roles/matrix_synapse/tasks/directories.yml
  3. 10
      roles/matrix_synapse/tasks/facts.yml
  4. 48
      roles/matrix_synapse/tasks/install.yml
  5. 1
      roles/matrix_synapse/tasks/main.yml
  6. 7
      roles/matrix_synapse/templates/matrix-synapse.service.j2
  7. 4
      roles/matrix_synapse/templates/post-backup.sh.j2
  8. 4
      roles/matrix_synapse/templates/pre-backup.sh.j2

@ -1,4 +1 @@
--- ---
dependencies:
- role: repo_scl
...

@ -18,6 +18,7 @@
- dir: etc - dir: etc
mode: 750 mode: 750
- dir: res/templates - dir: res/templates
- dir: db_dumps - dir: backup
mode: 700 mode: 700
- dir: venv
tags: matrix tags: matrix

@ -1,10 +1,5 @@
--- ---
- name: Check if a python 2.7 venv aready exists
stat: path={{ synapse_root_dir }}/lib/python2.7
register: synapse_venv_27
tags: matrix
- import_tasks: ../includes/get_rand_pass.yml - import_tasks: ../includes/get_rand_pass.yml
vars: vars:
- pass_file: "{{ synapse_root_dir }}/meta/ansible_dbpass" - pass_file: "{{ synapse_root_dir }}/meta/ansible_dbpass"
@ -28,4 +23,7 @@
- set_fact: synapse_form_secret={{ rand_pass }} - set_fact: synapse_form_secret={{ rand_pass }}
tags: matrix tags: matrix
- name: Check if the old venv is present
stat: path={{ synapse_root_dir }}/lib
register: synapse_old_venv
tags: matrix

@ -23,30 +23,22 @@
- postgresql-devel - postgresql-devel
- libpqxx-devel - libpqxx-devel
- jemalloc - jemalloc
- rh-python36-python-virtualenv - python3-virtualenv
- rh-python36-python-pip - python3-pip
- python-psycopg2
tags: matrix tags: matrix
- name: Stop synapse - name: Wipe pip cache
service: name=matrix-synapse state=stopped file: path=/root/.cache/pip state=absent
when: synapse_venv_27.stat.exists when: synapse_old_venv.stat.exists
tags: matrix
- name: Remove the venv
file: path={{ synapse_root_dir }}/{{ item }} state=absent
loop:
- lib
- lib64
- include
- bin
when: synapse_venv_27.stat.exists
tags: matrix tags: matrix
- name: Install or update dependencies in the virtual env - name: Install or update dependencies in the virtual env
pip: pip:
state: latest state: latest
virtualenv: "{{ synapse_root_dir }}" virtualenv: "{{ synapse_root_dir }}/venv"
virtualenv_command: /opt/rh/rh-python36/root/usr/bin/virtualenv virtualenv_command: /usr/bin/virtualenv-3
virtualenv_python: /usr/bin/python3
name: name:
- bleach - bleach
- matrix-synapse-ldap3 - matrix-synapse-ldap3
@ -62,8 +54,9 @@
- name: Install or update synapse in a virtualenv - name: Install or update synapse in a virtualenv
pip: pip:
virtualenv: "{{ synapse_root_dir }}" virtualenv: "{{ synapse_root_dir }}/venv"
virtualenv_command: /opt/rh/rh-python36/root/usr/bin/virtualenv virtualenv_command: /usr/bin/virtualenv-3
virtualenv_python: /usr/bin/python3
name: name:
- matrix-synapse - matrix-synapse
version: "{{ synapse_version }}" version: "{{ synapse_version }}"
@ -73,6 +66,7 @@
- name: Install the service unit file - name: Install the service unit file
template: src=matrix-synapse.service.j2 dest=/etc/systemd/system/matrix-synapse.service template: src=matrix-synapse.service.j2 dest=/etc/systemd/system/matrix-synapse.service
register: synapse_service_unit register: synapse_service_unit
notify: restart synapse
tags: matrix tags: matrix
- name: Reload systemd - name: Reload systemd
@ -83,7 +77,7 @@
- name: Install REST auth module - name: Install REST auth module
get_url: get_url:
url: https://raw.githubusercontent.com/ma1uta/matrix-synapse-rest-password-provider/master/rest_auth_provider.py url: https://raw.githubusercontent.com/ma1uta/matrix-synapse-rest-password-provider/master/rest_auth_provider.py
dest: "{{ synapse_root_dir }}/lib/python3.6/site-packages/" dest: "{{ synapse_root_dir }}/venv/lib/python3.6/site-packages/"
tags: matrix tags: matrix
- name: Create the PostgreSQL role - name: Create the PostgreSQL role
@ -110,12 +104,10 @@
tags: matrix tags: matrix
- name: Deploy backup scripts - name: Deploy backup scripts
template: src={{ item.src }} dest=/etc/backup/{{ item.dest }}/matrix_synapse.sh mode=750 template: src={{ item }}-backup.sh.j2 dest=/etc/backup/{{ item }}.d/matrix_synapse.sh mode=750
with_items: loop:
- src: pre-backup.sh.j2 - pre
dest: pre.d - post
- src: post-backup.sh.j2
dest: post.d
tags: matrix tags: matrix
- name: Install synapse_janitor.sql script - name: Install synapse_janitor.sql script
@ -125,7 +117,7 @@
tags: matrix tags: matrix
- name: Deploy janitor script - name: Deploy janitor script
template: src=synapse_janitor.sh.j2 dest={{ synapse_root_dir }}/bin/synapse_janitor.sh mode=700 template: src=synapse_janitor.sh.j2 dest={{ synapse_root_dir }}/venv/bin/synapse_janitor.sh mode=700
tags: matrix tags: matrix
- name: Setup cron job to clean synapse database - name: Setup cron job to clean synapse database
@ -133,7 +125,7 @@
name: matrix_synapse_janitor name: matrix_synapse_janitor
special_time: weekly special_time: weekly
user: root user: root
job: '{{ synapse_root_dir }}/bin/synapse_janitor.sh | /bin/systemd-cat' job: '{{ synapse_root_dir }}/venv/bin/synapse_janitor.sh | /bin/systemd-cat'
cron_file: matrix_synapse cron_file: matrix_synapse
tags: matrix tags: matrix

@ -8,4 +8,5 @@
- include: iptables.yml - include: iptables.yml
when: iptables_manage | default(True) when: iptables_manage | default(True)
- include: service.yml - include: service.yml
- include: cleanup.yml

@ -6,8 +6,13 @@ Type=simple
User={{ synapse_user }} User={{ synapse_user }}
Group={{ synapse_user }} Group={{ synapse_user }}
Environment=LD_PRELOAD=/usr/lib64/libjemalloc.so.1 Environment=LD_PRELOAD=/usr/lib64/libjemalloc.so.1
{% if system_proxy is defined and system_proxy != '' %}
{% for env in ['http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY'] %}
Environment={{ env }}={{ system_proxy | urlsplit('hostname') }}:{{ system_proxy | urlsplit('port') }}
{% endfor %}
{% endif %}
PermissionsStartOnly=yes PermissionsStartOnly=yes
ExecStart={{ synapse_root_dir }}/bin/python3 -m synapse.app.homeserver -c {{ synapse_root_dir }}/etc/homeserver.yaml -n ExecStart={{ synapse_root_dir }}/venv/bin/python3 -m synapse.app.homeserver -c {{ synapse_root_dir }}/etc/homeserver.yaml -n
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
PrivateTmp=yes PrivateTmp=yes
PrivateDevices=yes PrivateDevices=yes

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/bash -e
rm -f {{ synapse_root_dir }}/db_dumps/* rm -f {{ synapse_root_dir }}/backup/*

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/bash -e
PGPASSWORD='{{ synapse_pg_db_pass }}' /usr/pgsql-11/bin/pg_dump \ PGPASSWORD='{{ synapse_pg_db_pass }}' /usr/pgsql-11/bin/pg_dump \
--clean \ --clean \
--create \ --create \
--username={{ synapse_pg_db_user }} \ --username={{ synapse_pg_db_user }} \
--host={{ synapse_pg_db_server }} \ --host={{ synapse_pg_db_server }} \
{{ synapse_pg_db_name }} | lz4 -c > {{ synapse_root_dir }}/db_dumps/{{ synapse_pg_db_name }}.sql.lz4 {{ synapse_pg_db_name }} | zstd -T0 -c > {{ synapse_root_dir }}/backup/{{ synapse_pg_db_name }}.sql.zst

Loading…
Cancel
Save