matrix/roles/synapse/tasks/deploy-virtualenv.yml

68 lines
2.2 KiB
YAML
Raw Normal View History

---
- 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_venv_python_binary }}"
extra_args: "{{ synapse_venv_extra_args | default(omit, true) }}"
state: "{{ synapse_state }}"
- name: Ensure synapse pip package is {{ synapse_state }}
ansible.builtin.pip:
name: "{{ synapse_venv_package }}"
version: "{{ synapse_version }}"
state: "{{ synapse_state }}"
virtualenv: "{{ synapse_venv_path }}"
notify:
- synapse-restart
when: synapse_state != 'absent'
- name: Ensure synapse virtualenv is {{ synapse_state }}
ansible.builtin.file:
path: "{{ synapse_venv_path }}"
state: "{{ synapse_state }}"
when: synapse_state == 'absent'
- name: Ensure systemd unit is {{ synapse_state }}
ansible.builtin.template:
src: "synapse.service.j2"
dest: "{{ synapse_systemd_service_file }}"
notify:
- systemd-daemon-reload
when: synapse_state != 'absent'
- name: Ensure systemd unit is {{ synapse_state }}
ansible.builtin.file:
path: "{{ synapse_systemd_service_file }}"
state: "{{ synapse_state }}"
when: synapse_state == 'absent'
notify:
- systemd-daemon-reload
- name: Ensure handlers are flushed for systemd daemon reload and synapse service state propagation
meta: flush_handlers
- name: Ensure systemd service is {{ synapse_systemd_state }}
ansible.builtin.systemd_service:
name: "{{ synapse_systemd_name }}"
state: "{{ synapse_systemd_state }}"
when: synapse_state != 'absent'
- name: Ensure systemd service is {{ synapse_systemd_enabled | ternary('enabled', 'disabled') }}
ansible.builtin.systemd_service:
name: "{{ synapse_systemd_name }}"
enabled: "{{ synapse_systemd_enabled }}"
when: synapse_state != 'absent'