feat(synapse): add deployment method virtualenv
This commit is contained in:
parent
7764a1dd9f
commit
d379c0469d
@ -20,10 +20,7 @@ The following variables need to be populated:
|
|||||||
|
|
||||||
- `docker`
|
- `docker`
|
||||||
- `podman`
|
- `podman`
|
||||||
|
- `venv` - Python virtual env supervised with `systemd`
|
||||||
|
|
||||||
Set `synapse_deployment_method` to one of the supported deployment methods.
|
Set `synapse_deployment_method` to one of the supported deployment methods.
|
||||||
The current default is `docker`.
|
The current default is `docker`.
|
||||||
|
|
||||||
### Planned deployment methods
|
|
||||||
|
|
||||||
- `venv` - Python virtual env supervised with `systemd`
|
|
||||||
|
@ -11,6 +11,7 @@ synapse_data_path: "{{ synapse_base_path }}/data"
|
|||||||
synapse_media_store_path: "{{ synapse_data_path }}/media_store"
|
synapse_media_store_path: "{{ synapse_data_path }}/media_store"
|
||||||
synapse_log_path: "/var/log/synapse"
|
synapse_log_path: "/var/log/synapse"
|
||||||
synapse_homeserver_log_path: "{{ synapse_log_path }}/homeserver.log"
|
synapse_homeserver_log_path: "{{ synapse_log_path }}/homeserver.log"
|
||||||
|
synapse_venv_path: "{{ synapse_base_path }}/venv"
|
||||||
|
|
||||||
synapse_signing_key: ~
|
synapse_signing_key: ~
|
||||||
synapse_signing_key_file: >-
|
synapse_signing_key_file: >-
|
||||||
|
8
roles/synapse/defaults/main/systemd.yml
Normal file
8
roles/synapse/defaults/main/systemd.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
synapse_systemd_service_name: "synapse.service"
|
||||||
|
synapse_systemd_service_directory: /etc/systemd/system
|
||||||
|
synapse_systemd_service_file: >-2
|
||||||
|
{{ synapse_systemd_service_directory }}/{{ synapse_systemd_service_name }}
|
||||||
|
|
||||||
|
synapse_systemd_service_enabled: >-2
|
||||||
|
{{ (synapse_state == 'present') | bool }}
|
6
roles/synapse/defaults/main/virtualenv.yml
Normal file
6
roles/synapse/defaults/main/virtualenv.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
synapse_venv_package:
|
||||||
|
- synapse
|
||||||
|
synapse_venv_pip_dependencies:
|
||||||
|
- pip
|
||||||
|
- setuptools
|
@ -14,3 +14,8 @@
|
|||||||
state: "{{ synapse_container_state }}"
|
state: "{{ synapse_container_state }}"
|
||||||
force_restart: true
|
force_restart: true
|
||||||
when: synapse_deployment_method == 'podman'
|
when: synapse_deployment_method == 'podman'
|
||||||
|
|
||||||
|
- name: Ensure systemd units are reloaded
|
||||||
|
listen: systemd-daemon-reload
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
51
roles/synapse/tasks/deploy-venv.yml
Normal file
51
roles/synapse/tasks/deploy-venv.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
- name: Ensure directory for virtualenv is {{ synapse_state }}
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ synapse_venv_path }}"
|
||||||
|
owner: >-2
|
||||||
|
{{ synapse_user_info.uid | default(synapse_user) }}
|
||||||
|
group: >-2
|
||||||
|
{{ synapse_user_info.group | default(synapse_user) }}
|
||||||
|
mode: "{{ synapse_venv_path_mode | default('0755') }}"
|
||||||
|
state: >-
|
||||||
|
{{ (synapse_state == 'present')
|
||||||
|
| ternary('directory', 'absent') }}
|
||||||
|
|
||||||
|
- name: Ensure virtual environment is {{ synapse_state }}
|
||||||
|
ansible.builtin.pip:
|
||||||
|
name: "{{ synapse_venv_pip_dependencies }}"
|
||||||
|
virtualenv: "{{ synapse_venv_path }}"
|
||||||
|
virtualenv_python: >-
|
||||||
|
{{ synapse_virtualenv_python_binary
|
||||||
|
| default(ansible_python_interpreter
|
||||||
|
| default(omit, true), true) }}
|
||||||
|
extra_args: "{{ synapse_venv_extra_args }}"
|
||||||
|
state: "{{ synapse_state }}"
|
||||||
|
|
||||||
|
- name: Ensure synapse is {{ synapse_state }}
|
||||||
|
ansible.builtin.pip:
|
||||||
|
name: "{{ synapse_venv_package }}"
|
||||||
|
version: "{{ synapse_version }}"
|
||||||
|
state: "{{ synapse_state }}"
|
||||||
|
virtualenv: "{{ synapse_venv_path }}"
|
||||||
|
notify:
|
||||||
|
- synapse-restart
|
||||||
|
|
||||||
|
- name: Ensure systemd unit is {{ synapse_state }}
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "synapse.service.j2"
|
||||||
|
dest: "{{ synapse_systemd_service_file }}"
|
||||||
|
notify:
|
||||||
|
- systemd-daemon-reload
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Ensure systemd service is {{ synapse_state }}
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ synapse_systemd_service_name }}"
|
||||||
|
state: "{{ synapse_state }}"
|
||||||
|
|
||||||
|
- name: Ensure systemd service is {{ synapse_systemd_service_enabled | ternary('enabled', 'disabled') }}
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ synapse_systemd_service_name }}"
|
||||||
|
enabled: "{{ synapse_systemd_service_enabled }}"
|
@ -6,6 +6,7 @@ synapse_states:
|
|||||||
synapse_deployment_methods:
|
synapse_deployment_methods:
|
||||||
- docker
|
- docker
|
||||||
- podman
|
- podman
|
||||||
|
- venv
|
||||||
|
|
||||||
synapse_required_variables:
|
synapse_required_variables:
|
||||||
- synapse_domain
|
- synapse_domain
|
||||||
|
Loading…
Reference in New Issue
Block a user