sync with previous repo
This commit is contained in:
62
roles/matrix-etherpad/tasks/init.yml
Normal file
62
roles/matrix-etherpad/tasks/init.yml
Normal file
@ -0,0 +1,62 @@
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-etherpad.service'] }}"
|
||||
when: matrix_etherpad_enabled|bool
|
||||
|
||||
- block:
|
||||
- name: Fail if matrix-nginx-proxy role already executed
|
||||
fail:
|
||||
msg: >-
|
||||
Trying to append Etherpad's reverse-proxying configuration to matrix-nginx-proxy,
|
||||
but it's pointless since the matrix-nginx-proxy role had already executed.
|
||||
To fix this, please change the order of roles in your plabook,
|
||||
so that the matrix-nginx-proxy role would run after the matrix-etherpad role.
|
||||
when: matrix_nginx_proxy_role_executed|default(False)|bool
|
||||
|
||||
- name: Generate Etherpad proxying configuration for matrix-nginx-proxy
|
||||
set_fact:
|
||||
matrix_etherpad_matrix_nginx_proxy_configuration: |
|
||||
rewrite ^{{ matrix_etherpad_public_endpoint }}$ $scheme://$server_name{{ matrix_etherpad_public_endpoint }}/ permanent;
|
||||
|
||||
location {{ matrix_etherpad_public_endpoint }}/ {
|
||||
{% if matrix_nginx_proxy_enabled|default(False) %}
|
||||
{# Use the embedded DNS resolver in Docker containers to discover the service #}
|
||||
resolver 127.0.0.11 valid=5s;
|
||||
proxy_pass http://matrix-etherpad:9001/;
|
||||
{# These are proxy directives needed specifically by Etherpad #}
|
||||
proxy_buffering off;
|
||||
proxy_http_version 1.1; # recommended with keepalive connections
|
||||
proxy_pass_header Server;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme; # for EP to set secure cookie flag when https is used
|
||||
# WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
{% else %}
|
||||
{# Generic configuration for use outside of our container setup #}
|
||||
# A good guide for setting up your Etherpad behind nginx:
|
||||
# https://docs.gandi.net/en/cloud/tutorials/etherpad_lite.html
|
||||
proxy_pass http://127.0.0.1:9001/;
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
- name: Register Etherpad proxying configuration with matrix-nginx-proxy
|
||||
set_fact:
|
||||
matrix_nginx_proxy_proxy_dimension_additional_server_configuration_blocks: |
|
||||
{{
|
||||
matrix_nginx_proxy_proxy_dimension_additional_server_configuration_blocks|default([])
|
||||
+
|
||||
[matrix_etherpad_matrix_nginx_proxy_configuration]
|
||||
}}
|
||||
tags:
|
||||
- always
|
||||
when: matrix_etherpad_enabled|bool
|
||||
|
||||
- name: Warn about reverse-proxying if matrix-nginx-proxy not used
|
||||
debug:
|
||||
msg: >-
|
||||
NOTE: You've enabled the Etherpad tool but are not using the matrix-nginx-proxy
|
||||
reverse proxy.
|
||||
Please make sure that you're proxying the `{{ matrix_etherpad_public_endpoint }}`
|
||||
URL endpoint to the matrix-etherpad container.
|
||||
You can expose the container's port using the `matrix_etherpad_container_http_host_bind_port` variable.
|
||||
when: "matrix_etherpad_enabled|bool and matrix_nginx_proxy_enabled is not defined"
|
21
roles/matrix-etherpad/tasks/main.yml
Normal file
21
roles/matrix-etherpad/tasks/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
- import_tasks: "{{ role_path }}/tasks/init.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_install.yml"
|
||||
when: run_setup|bool and matrix_etherpad_enabled|bool
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-etherpad
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"
|
||||
when: run_setup|bool and not matrix_etherpad_enabled|bool
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-etherpad
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
when: run_setup|bool and matrix_etherpad_enabled|bool
|
||||
tags:
|
||||
- setup-all
|
||||
- setup-etherpad
|
36
roles/matrix-etherpad/tasks/setup_install.yml
Normal file
36
roles/matrix-etherpad/tasks/setup_install.yml
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
|
||||
- name: Ensure Etherpad base path exists
|
||||
file:
|
||||
path: "{{ matrix_etherpad_base_path }}"
|
||||
state: directory
|
||||
mode: 0770
|
||||
owner: "{{ matrix_etherpad_user_uid }}"
|
||||
group: "{{ matrix_etherpad_user_gid }}"
|
||||
|
||||
- name: Ensure Etherpad config installed
|
||||
copy:
|
||||
content: "{{ matrix_etherpad_configuration|to_nice_json }}"
|
||||
dest: "{{ matrix_etherpad_base_path }}/settings.json"
|
||||
mode: 0640
|
||||
owner: "{{ matrix_etherpad_user_uid }}"
|
||||
group: "{{ matrix_etherpad_user_gid }}"
|
||||
|
||||
- name: Ensure Etherpad image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_etherpad_docker_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_etherpad_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_etherpad_docker_image_force_pull }}"
|
||||
|
||||
- name: Ensure matrix-etherpad.service installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-etherpad.service.j2"
|
||||
dest: "{{ matrix_systemd_path }}/matrix-etherpad.service"
|
||||
mode: 0644
|
||||
register: matrix_etherpad_systemd_service_result
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-etherpad.service installation
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_etherpad_systemd_service_result.changed|bool"
|
35
roles/matrix-etherpad/tasks/setup_uninstall.yml
Normal file
35
roles/matrix-etherpad/tasks/setup_uninstall.yml
Normal file
@ -0,0 +1,35 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-etherpad service
|
||||
stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-etherpad.service"
|
||||
register: matrix_etherpad_service_stat
|
||||
|
||||
- name: Ensure matrix-etherpad is stopped
|
||||
service:
|
||||
name: matrix-etherpad
|
||||
state: stopped
|
||||
daemon_reload: yes
|
||||
register: stopping_result
|
||||
when: "matrix_etherpad_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure matrix-etherpad.service doesn't exist
|
||||
file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-etherpad.service"
|
||||
state: absent
|
||||
when: "matrix_etherpad_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-etherpad.service removal
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_etherpad_service_stat.stat.exists|bool"
|
||||
|
||||
- name: Ensure Etherpad base directory doesn't exist
|
||||
file:
|
||||
path: "{{ matrix_etherpad_base_path }}"
|
||||
state: absent
|
||||
|
||||
- name: Ensure Etherpad Docker image doesn't exist
|
||||
docker_image:
|
||||
name: "{{ matrix_etherpad_docker_image }}"
|
||||
state: absent
|
11
roles/matrix-etherpad/tasks/validate_config.yml
Normal file
11
roles/matrix-etherpad/tasks/validate_config.yml
Normal file
@ -0,0 +1,11 @@
|
||||
- name: Fail if Etherpad is enabled without the Dimension integrations manager
|
||||
fail:
|
||||
msg: >-
|
||||
To integrate Etherpad notes with Matrix rooms you need to set "matrix_dimension_enabled" to true
|
||||
when: "not matrix_dimension_enabled|bool"
|
||||
|
||||
- name: Fail if no database is configured for Etherpad
|
||||
fail:
|
||||
msg: >-
|
||||
Etherpad requires a dedicated Postgres database. Please enable the built in one, or configure an external DB by redefining "matrix_etherpad_database_hostname"
|
||||
when: matrix_etherpad_database_hostname == "matrix-postgres" and not matrix_postgres_enabled
|
Reference in New Issue
Block a user