Compare commits
No commits in common. "0a8ac8bb588d8228d185dfc02087915c842639dc" and "3d89f57c31a85e86f6fc92c381b6f4d204e6dd8b" have entirely different histories.
0a8ac8bb58
...
3d89f57c31
41
roles/synapse/defaults/main.yml
Normal file
41
roles/synapse/defaults/main.yml
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
|
||||
synapse_user: synapse
|
||||
synapse_version: "1.91.1"
|
||||
synapse_base_path: /opt/synapse
|
||||
synapse_config_path: "{{ synapse_base_path }}/config"
|
||||
synapse_data_path: "{{ synapse_base_path }}/data"
|
||||
synapse_media_store_path: "{{ synapse_data_path }}/matrix"
|
||||
synapse_homeserver_config_file: "{{ synapse_config_path }}/homeserver.yaml"
|
||||
synapse_logging_config_file: "{{ synapse_config_path }}/{{ synapse_domain }}.log.config"
|
||||
|
||||
synapse_container_name: synapse
|
||||
synapse_container_image_reference: >-2
|
||||
{{ synapse_container_image_repository
|
||||
~ (synapse_container_image_tag
|
||||
| default('v' ~ synapse_version, true) }}
|
||||
synapse_container_image_registry: ghcr.io
|
||||
synapse_container_image_namespace: matrix-org
|
||||
synapse_container_image_name: synapse
|
||||
synapse_container_image_repository: >-2
|
||||
{{ synapse_container_image_registry
|
||||
~ (('/' ~ synapse_container_image_namespace)
|
||||
if synapse_container_image_namespace else '')
|
||||
~ '/' ~ synapse_container_image_name }}
|
||||
#synapse_container_image_tag: ~
|
||||
synapse_container_env: {}
|
||||
synapse_container_user: ~
|
||||
synapse_container_group: ~
|
||||
synapse_container_ports: ~
|
||||
synapse_container_labels: ~
|
||||
synapse_container_ulimits: ~
|
||||
synapse_container_volumes: ~
|
||||
synapse_container_networks: ~
|
||||
synapse_container_purge_networks: ~
|
||||
synapse_container_dns_servers: ~
|
||||
synapse_container_etc_hosts: ~
|
||||
synapse_container_memory: ~
|
||||
synapse_container_memory_reservation: ~
|
||||
synapse_container_memory_swap: ~
|
||||
synapse_container_state: "started"
|
||||
synapse_container_restart_policy: "unless-stopped"
|
78
roles/synapse/tasks/main.yml
Normal file
78
roles/synapse/tasks/main.yml
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
|
||||
- name: Ensure synapse user '{{ synapse_user }}' exists
|
||||
ansible.builtin.user:
|
||||
name: "{{ synapse_user }}"
|
||||
state: "present"
|
||||
system: true
|
||||
create_home: false
|
||||
groups: "{{ synapse_user_groups | default(omit, true) }}"
|
||||
append: "{{ (synapse_user_groups is defined) | ternary(true, omit) }}"
|
||||
register: synapse_user_info
|
||||
|
||||
- name: Ensure directories for synapse are created
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: "directory"
|
||||
mode: "{{ item.mode | default('0750') }}"
|
||||
owner: "{{ item.owner | default(synapse_user_info.uid | default(synapse_user)) }}"
|
||||
group: "{{ item.group | default(synapse_user_info.group | default(synapse_user)) }}"
|
||||
loop:
|
||||
- path: "{{ synapse_base_path }}"
|
||||
mode: "0755"
|
||||
- path: "{{ synapse_config_path }}"
|
||||
- path: "{{ synapse_data_path }}"
|
||||
- path: "{{ synapse_media_store_path }}"
|
||||
loop_control:
|
||||
label: "{{ item.path }}"
|
||||
|
||||
- name: Ensure configuration files are templated
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ config_file.path }}"
|
||||
content: "{{ config_file.content }}"
|
||||
mode: "{{ config_file.mode | default('0640') }}"
|
||||
owner: "{{ config_file.owner | default(synapse_user_info.uid | default(synapse_user)) }}"
|
||||
group: "{{ config_file.group | default(synapse_user_info.group | default(synapse_user)) }}"
|
||||
loop: >-
|
||||
{{ synapse_configs_to_write + synapse_configs | default([]) }}
|
||||
loop_control:
|
||||
loop_var: config_file
|
||||
label: "{{ config_file.path }}"
|
||||
vars:
|
||||
synapse_configs_to_write:
|
||||
- content: "{{ synapse_config | to_nice_yaml(width=1000) }}"
|
||||
path: "{{ synapse_homeserver_config_file }}"
|
||||
- content: "{{ synapse_log_config | to_nice_yaml(width=1000) }}"
|
||||
path: "{{ synapse_logging_config_file }}"
|
||||
|
||||
- name: Ensure container image '{{ synapse_container_image_reference }}' is present on host
|
||||
community.docker.docker_image:
|
||||
name: "{{ synapse_container_image_reference }}"
|
||||
state: present
|
||||
source: pull
|
||||
force_source: "{{ synapse_container_image_tag is defined and synapse_container_image_tag }}"
|
||||
when: synapse_deployment_method == 'docker'
|
||||
register: synapse_container_image_info
|
||||
until: synapse_container_image_info is success
|
||||
retries: 10
|
||||
delay: 5
|
||||
|
||||
- name: Ensure synapse container '{{ synapse_container_name }}' is in the desired state
|
||||
community.docker.docker_container:
|
||||
name: "{{ synapse_container_name }}"
|
||||
env: "{{ synapse_container_env | default(omit, true) }}"
|
||||
user: "{{ synapse_container_user | default(omit, true) }}"
|
||||
group: "{{ synapse_container_group | default(omit, true) }}"
|
||||
ports: "{{ synapse_container_ports | default(omit, true) }}"
|
||||
labels: "{{ synapse_container_labels | default(omit, true) }}"
|
||||
ulimits: "{{ synapse_container_ulimits | default(omit, true) }}"
|
||||
volumes: "{{ synapse_container_volumes | default(omit, true) }}"
|
||||
networks: "{{ synapse_container_networks | default(omit, true) }}"
|
||||
purge_networks: "{{ synapse_container_purge_networks | default(omit, true) }}"
|
||||
dns_servers: "{{ synapse_container_dns_servers | default(omit, true) }}"
|
||||
etc_hosts: "{{ synapse_container_etc_hosts | default(omit, true) }}"
|
||||
memory: "{{ synapse_container_memory | default(omit, true) }}"
|
||||
memory_reservation: "{{ synapse_container_memory_reservation | default(omit, true) }}"
|
||||
memory_swap: "{{ synapse_container_memory_swap | default(omit, true) }}"
|
||||
restart_policy: "{{ synapse_container_restart_policy }}"
|
||||
state: "{{ synapse_container_state }}"
|
Loading…
x
Reference in New Issue
Block a user