Update to 2021-03-01 19:00

master
Daniel Berteaud 4 years ago
parent 09f75c740c
commit 5d3e11225d
  1. 3
      roles/matrix_synapse/defaults/main.yml
  2. 10
      roles/matrix_synapse/tasks/archive_post.yml
  3. 30
      roles/matrix_synapse/tasks/archive_pre.yml
  4. 1
      roles/matrix_synapse/tasks/cleanup.yml
  5. 10
      roles/matrix_synapse/tasks/facts.yml
  6. 7
      roles/matrix_synapse/tasks/install.yml
  7. 5
      roles/matrix_synapse/tasks/main.yml
  8. 5
      roles/matrix_synapse/tasks/write_version.yml

@ -3,6 +3,9 @@
# Synapse version to deploy # Synapse version to deploy
synapse_version: 1.28.0 synapse_version: 1.28.0
# Should ansible handle Synapse upgrades ? If false, only initial install will be done
synapse_manage_upgrade: True
# Synapse install dir # Synapse install dir
synapse_root_dir: /opt/matrix/synapse synapse_root_dir: /opt/matrix/synapse

@ -0,0 +1,10 @@
---
- name: Compress previous version
command: tar cf {{ synapse_root_dir }}/archives/{{ synapse_current_version }}.tar.zst --use-compress-program=zstd ./
args:
chdir: "{{ synapse_root_dir }}/archives/{{ synapse_current_version }}"
warn: False
environment:
ZSTD_CLEVEL: 10
tags: matrix

@ -0,0 +1,30 @@
---
- name: Create archive dir
file: path={{ synapse_root_dir }}/archives/{{ synapse_current_version }} state=directory
tags: matrix
- name: Archive previous version
synchronize:
src: "{{ synapse_root_dir }}/{{ item }}"
dest: "{{ synapse_root_dir }}/archives/{{ synapse_current_version }}/"
delete: True
compress: False
loop:
- etc
- res
- venv
delegate_to: "{{ inventory_hostname }}"
tags: matrix
- name: Archive a database dump
command: >
/usr/pgsql-13/bin/pg_dump
--clean
--host={{ synapse_pg_db_server }}
--port={{ synapse_pg_db_port }}
--username=sqladmin {{ synapse_pg_db_name }}
--file={{ synapse_root_dir }}/archives/{{ synapse_current_version }}/{{ synapse_pg_db_name }}.sql
environment:
- PGPASSWORD: "{{ pg_admin_pass }}"
tags: matrix

@ -11,5 +11,6 @@
- "{{ synapse_root_dir }}/res/synapse_janitor.sql" - "{{ synapse_root_dir }}/res/synapse_janitor.sql"
- "{{ synapse_root_dir }}/venv/bin/synapse_janitor.sh" - "{{ synapse_root_dir }}/venv/bin/synapse_janitor.sh"
- /etc/cron.d/matrix_synapse - /etc/cron.d/matrix_synapse
- "{{ synapse_root_dir }}/archives/{{ synapse_current_version }}"
tags: matrix tags: matrix

@ -7,6 +7,16 @@
- vars/{{ ansible_os_family }}.yml - vars/{{ ansible_os_family }}.yml
tags: matrix tags: matrix
# Detect installed version (if any)
- block:
- import_tasks: ../includes/webapps_set_install_mode.yml
vars:
- root_dir: "{{ synapse_root_dir }}"
- version: "{{ synapse_version }}"
- set_fact: synapse_install_mode={{ (install_mode == 'upgrade' and not synapse_manage_upgrade) | ternary('none',install_mode) }}
- set_fact: synapse_current_version={{ current_version | default('') }}
tags: matrix
- when: synapse_pg_db_pass is not defined - when: synapse_pg_db_pass is not defined
block: block:
- import_tasks: ../includes/get_rand_pass.yml - import_tasks: ../includes/get_rand_pass.yml

@ -22,9 +22,14 @@
when: synapse_old_venv.stat.exists when: synapse_old_venv.stat.exists
tags: matrix tags: matrix
- name: Wipe the venv during upgrades
file: path={{ synapse_root_dir }}/venv state=absent
when: synapse_install_mode == 'upgrade'
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: "{{ (synapse_install_mode == 'upgrade') | ternary('latest','present') }}"
virtualenv: "{{ synapse_root_dir }}/venv" virtualenv: "{{ synapse_root_dir }}/venv"
virtualenv_command: /usr/bin/virtualenv-3 virtualenv_command: /usr/bin/virtualenv-3
virtualenv_python: /usr/bin/python3 virtualenv_python: /usr/bin/python3

@ -3,10 +3,15 @@
- include: user.yml - include: user.yml
- include: directories.yml - include: directories.yml
- include: facts.yml - include: facts.yml
- include: archive_pre.yml
when: synapse_install_mode == 'upgrade'
- include: install.yml - include: install.yml
- include: conf.yml - include: conf.yml
- include: iptables.yml - include: iptables.yml
when: iptables_manage | default(True) when: iptables_manage | default(True)
- include: service.yml - include: service.yml
- include: write_version.yml
- include: archive_post.yml
when: synapse_install_mode == 'upgrade'
- include: cleanup.yml - include: cleanup.yml

@ -0,0 +1,5 @@
---
- name: Write current version
copy: content={{ synapse_version }} dest={{ synapse_root_dir }}/meta/ansible_version
tags: matrix
Loading…
Cancel
Save