145 lines
3.8 KiB
YAML
145 lines
3.8 KiB
YAML
---
|
|
- name: Install system packages for Matrix Synapse
|
|
apt:
|
|
name:
|
|
- build-essential
|
|
- libffi-dev
|
|
- libjpeg-dev
|
|
- libpq-dev
|
|
- libpq5
|
|
- libssl-dev
|
|
- libxml2-dev
|
|
- libxslt1-dev
|
|
- python3-dev
|
|
- python3-pip
|
|
- python3-setuptools
|
|
- sqlite3
|
|
- virtualenv
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Matrix Synapse system group
|
|
group:
|
|
name: '{{ matrix__synapse__group }}'
|
|
system: true
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Matrix Synapse system user
|
|
user:
|
|
name: '{{ matrix__synapse__user }}'
|
|
group: '{{ matrix__synapse__group }}'
|
|
system: true
|
|
create_home: false
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Matrix Synapse directories
|
|
file:
|
|
state: directory
|
|
path: '{{ item }}'
|
|
mode: 'u=rwx,g=rwx,o=rx'
|
|
owner: '{{ matrix__synapse__user }}'
|
|
group: '{{ matrix__synapse__group }}'
|
|
with_items:
|
|
- '{{ matrix__synapse__conf_dir }}'
|
|
- '{{ matrix__synapse__conf_subdir }}'
|
|
- '{{ matrix__synapse__opt_dir }}'
|
|
- '{{ matrix__synapse__lib_dir }}'
|
|
- '{{ matrix__synapse__log_dir }}'
|
|
- '{{ matrix__synapse__run_dir }}'
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Matrix Synapse config
|
|
template:
|
|
src: '../templates/synapse/config/{{ item }}.yaml'
|
|
dest: '{{ matrix__synapse__conf_subdir }}/{{ item }}.yaml'
|
|
mode: 'u=rw,g=rw,o='
|
|
owner: '{{ matrix__synapse__user }}'
|
|
group: '{{ matrix__synapse__group }}'
|
|
notify: Load, enable and restart Matrix Synapse
|
|
with_items:
|
|
- other
|
|
- database
|
|
- acme
|
|
- listeners
|
|
- url_preview
|
|
- captcha
|
|
- turn
|
|
|
|
- name: Create Matrix Synapse log config
|
|
template:
|
|
src: '../templates/synapse/log_config.yml'
|
|
dest: '{{ matrix__synapse__log_conf_file }}'
|
|
mode: 'u=rw,g=rw,o=r'
|
|
owner: '{{ matrix__synapse__user }}'
|
|
group: '{{ matrix__synapse__group }}'
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Matrix Synapse signing key
|
|
copy:
|
|
content: "{{ matrix__synapse__signing_key }}\n"
|
|
dest: '{{ matrix__synapse__key_file }}'
|
|
mode: 'u=rw,g=rw,o='
|
|
owner: '{{ matrix__synapse__user }}'
|
|
group: '{{ matrix__synapse__group }}'
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Python virtual env
|
|
become_user: '{{ matrix__synapse__user }}'
|
|
command:
|
|
argv:
|
|
- 'virtualenv'
|
|
- '{{ matrix__synapse__venv_dir }}'
|
|
- '-p'
|
|
- 'python3'
|
|
creates: '{{ matrix__synapse__venv_dir }}'
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Check Python packages
|
|
command:
|
|
argv:
|
|
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
|
- 'show'
|
|
- '{{ item }}'
|
|
with_items:
|
|
- 'matrix-synapse'
|
|
- 'lxml'
|
|
- 'netaddr'
|
|
- 'pip'
|
|
- 'psycopg2'
|
|
- 'setuptools'
|
|
ignore_errors: true
|
|
changed_when: false
|
|
register: packages_info
|
|
|
|
- name: Upgrade Python packages
|
|
become_user: '{{ matrix__synapse__user }}'
|
|
command:
|
|
argv:
|
|
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
|
- 'install'
|
|
- '--upgrade'
|
|
- 'pip'
|
|
- 'setuptools'
|
|
when: packages_info | json_query('results[*].rc') | difference([0]) != []
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Install Python packages
|
|
become_user: '{{ matrix__synapse__user }}'
|
|
command:
|
|
argv:
|
|
- '{{ matrix__synapse__venv_dir }}/bin/pip'
|
|
- 'install'
|
|
- 'matrix-synapse'
|
|
- 'lxml'
|
|
- 'netaddr'
|
|
- 'psycopg2'
|
|
when: packages_info | json_query('results[*].rc') | difference([0]) != []
|
|
notify: Load, enable and restart Matrix Synapse
|
|
|
|
- name: Create Matrix Synapse systemd service
|
|
template:
|
|
src: '../templates/synapse/matrix-synapse.service'
|
|
dest: '{{ matrix__synapse__service_file }}'
|
|
mode: 'u=rw,g=rw,o=r'
|
|
owner: root
|
|
group: root
|
|
notify: Load, enable and restart Matrix Synapse
|