Fix linting errors

This commit is contained in:
Johan Swetzén 2022-07-23 22:18:58 +02:00
parent 873ca2821a
commit 32de006eaf
7 changed files with 56 additions and 55 deletions

View File

@ -1,3 +1,4 @@
---
# mautrix-wsproxy is a Matrix <-> websocket bridge # mautrix-wsproxy is a Matrix <-> websocket bridge
# See: https://github.com/mautrix/wsproxy # See: https://github.com/mautrix/wsproxy

View File

@ -1,9 +1,10 @@
- set_fact: ---
- ansible.builtin.set_fact:
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-wsproxy.service'] }}" matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-wsproxy.service'] }}"
when: matrix_mautrix_wsproxy_enabled|bool when: matrix_mautrix_wsproxy_enabled|bool
# If the matrix-synapse role is not used, these variables may not exist. # If the matrix-synapse role is not used, these variables may not exist.
- set_fact: - ansible.builtin.set_fact:
matrix_synapse_container_extra_arguments: > matrix_synapse_container_extra_arguments: >
{{ matrix_synapse_container_extra_arguments|default([]) }} {{ matrix_synapse_container_extra_arguments|default([]) }}
+ +
@ -17,44 +18,44 @@
- block: - block:
- name: Fail if matrix-nginx-proxy role already executed - name: Fail if matrix-nginx-proxy role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
Trying to append Mautrix Wsproxy reverse-proxying configuration to matrix-nginx-proxy, Trying to append Mautrix Wsproxy reverse-proxying configuration to matrix-nginx-proxy,
but it's pointless since the matrix-nginx-proxy role had already executed. but it's pointless since the matrix-nginx-proxy role had already executed.
To fix this, please change the order of roles in your playbook, To fix this, please change the order of roles in your playbook,
so that the matrix-nginx-proxy role would run after the matrix-bridge-mautrix-wsproxy role. so that the matrix-nginx-proxy role would run after the matrix-bridge-mautrix-wsproxy role.
when: matrix_nginx_proxy_role_executed|default(False)|bool when: matrix_nginx_proxy_role_executed|default(False)|bool
- name: Generate Mautrix Wsproxy proxying configuration for matrix-nginx-proxy - name: Generate Mautrix Wsproxy proxying configuration for matrix-nginx-proxy
set_fact: ansible.builtin.set_fact:
matrix_mautrix_wsproxy_matrix_nginx_proxy_configuration: | matrix_mautrix_wsproxy_matrix_nginx_proxy_configuration: |
location ~ ^/(_matrix/wsproxy/.*) { location ~ ^/(_matrix/wsproxy/.*) {
{% if matrix_nginx_proxy_enabled|default(False) %} {% if matrix_nginx_proxy_enabled|default(False) %}
{# Use the embedded DNS resolver in Docker containers to discover the service #} {# Use the embedded DNS resolver in Docker containers to discover the service #}
resolver 127.0.0.11 valid=5s; resolver 127.0.0.11 valid=5s;
set $backend "matrix-mautrix-wsproxy:{{ matrix_mautrix_wsproxy_port }}"; set $backend "matrix-mautrix-wsproxy:{{ matrix_mautrix_wsproxy_port }}";
proxy_pass http://$backend; proxy_pass http://$backend;
{% else %} {% else %}
{# Generic configuration for use outside of our container setup #} {# Generic configuration for use outside of our container setup #}
proxy_pass http://127.0.0.1:{{ matrix_mautrix_wsproxy_port }}; proxy_pass http://127.0.0.1:{{ matrix_mautrix_wsproxy_port }};
{% endif %} {% endif %}
} }
- name: Register Mautrix Wsproxy proxying configuration with matrix-nginx-proxy - name: Register Mautrix Wsproxy proxying configuration with matrix-nginx-proxy
set_fact: ansible.builtin.set_fact:
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
{{ {{
matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
+ +
[matrix_mautrix_wsproxy_matrix_nginx_proxy_configuration] [matrix_mautrix_wsproxy_matrix_nginx_proxy_configuration]
}} }}
tags: tags:
- always - always
when: matrix_mautrix_wsproxy_enabled|bool when: matrix_mautrix_wsproxy_enabled|bool
- name: Warn about reverse-proxying if matrix-nginx-proxy not used - name: Warn about reverse-proxying if matrix-nginx-proxy not used
debug: ansible.builtin.debug:
msg: >- msg: >-
NOTE: You've enabled the Mautrix wsproxy bridge but are not using the matrix-nginx-proxy NOTE: You've enabled the Mautrix wsproxy bridge but are not using the matrix-nginx-proxy
reverse proxy. reverse proxy.
@ -62,4 +63,3 @@
URL endpoint to the matrix-mautrix-wsproxy container. URL endpoint to the matrix-mautrix-wsproxy container.
You can expose the container's port using the `matrix_mautrix_wsproxy_container_http_host_bind_port` variable. You can expose the container's port using the `matrix_mautrix_wsproxy_container_http_host_bind_port` variable.
when: "matrix_mautrix_wsproxy_enabled|bool and matrix_nginx_proxy_enabled is not defined" when: "matrix_mautrix_wsproxy_enabled|bool and matrix_nginx_proxy_enabled is not defined"

View File

@ -1,3 +1,4 @@
---
- import_tasks: "{{ role_path }}/tasks/init.yml" - import_tasks: "{{ role_path }}/tasks/init.yml"
tags: tags:
- always - always

View File

@ -3,12 +3,12 @@
# If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist. # If the matrix-synapse role is not used, `matrix_synapse_role_executed` won't exist.
# We don't want to fail in such cases. # We don't want to fail in such cases.
- name: Fail if matrix-synapse role already executed - name: Fail if matrix-synapse role already executed
fail: ansible.builtin.fail:
msg: >- msg: >-
The matrix-bridge-mautrix-wsproxy role needs to execute before the matrix-synapse role. The matrix-bridge-mautrix-wsproxy role needs to execute before the matrix-synapse role.
when: "matrix_synapse_role_executed|default(False)" when: "matrix_synapse_role_executed|default(False)"
- set_fact: - ansible.builtin.set_fact:
matrix_mautrix_wsproxy_requires_restart: false matrix_mautrix_wsproxy_requires_restart: false
- name: Ensure Mautrix wsproxy image is pulled - name: Ensure Mautrix wsproxy image is pulled
@ -19,7 +19,7 @@
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_wsproxy_docker_image_force_pull }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mautrix_wsproxy_docker_image_force_pull }}"
- name: Ensure Mautrix wsproxy paths exists - name: Ensure Mautrix wsproxy paths exists
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: 0750 mode: 0750
@ -31,12 +31,12 @@
- "{{ matrix_mautrix_wsproxy_data_path }}" - "{{ matrix_mautrix_wsproxy_data_path }}"
- name: Check if an old matrix state file exists - name: Check if an old matrix state file exists
stat: ansible.builtin.stat:
path: "{{ matrix_mautrix_wsproxy_base_path }}/mx-state.json" path: "{{ matrix_mautrix_wsproxy_base_path }}/mx-state.json"
register: matrix_mautrix_wsproxy_stat_mx_state register: matrix_mautrix_wsproxy_stat_mx_state
- name: Ensure mautrix-wsproxy config.yaml installed - name: Ensure mautrix-wsproxy config.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_mautrix_wsproxy_configuration|to_nice_yaml }}" content: "{{ matrix_mautrix_wsproxy_configuration|to_nice_yaml }}"
dest: "{{ matrix_mautrix_wsproxy_config_path }}/config.yaml" dest: "{{ matrix_mautrix_wsproxy_config_path }}/config.yaml"
mode: 0644 mode: 0644
@ -44,7 +44,7 @@
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure mautrix-wsproxy registration.yaml installed - name: Ensure mautrix-wsproxy registration.yaml installed
copy: ansible.builtin.copy:
content: "{{ matrix_mautrix_wsproxy_registration|to_nice_yaml }}" content: "{{ matrix_mautrix_wsproxy_registration|to_nice_yaml }}"
dest: "{{ matrix_mautrix_wsproxy_config_path }}/registration.yaml" dest: "{{ matrix_mautrix_wsproxy_config_path }}/registration.yaml"
mode: 0644 mode: 0644
@ -52,19 +52,19 @@
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-mautrix-wsproxy.service installed - name: Ensure matrix-mautrix-wsproxy.service installed
template: ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy.service.j2" src: "{{ role_path }}/templates/systemd/matrix-mautrix-wsproxy.service.j2"
dest: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service" dest: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service"
mode: 0644 mode: 0644
register: matrix_mautrix_wsproxy_systemd_service_result register: matrix_mautrix_wsproxy_systemd_service_result
- name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service installation - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service installation
service: ansible.builtin.service:
daemon_reload: yes daemon_reload: true
when: "matrix_mautrix_wsproxy_systemd_service_result.changed" when: "matrix_mautrix_wsproxy_systemd_service_result.changed"
- name: Ensure matrix-mautrix-wsproxy.service restarted, if necessary - name: Ensure matrix-mautrix-wsproxy.service restarted, if necessary
service: ansible.builtin.service:
name: "matrix-mautrix-wsproxy.service" name: "matrix-mautrix-wsproxy.service"
state: restarted state: restarted
when: "matrix_mautrix_wsproxy_requires_restart|bool" when: "matrix_mautrix_wsproxy_requires_restart|bool"

View File

@ -1,24 +1,24 @@
--- ---
- name: Check existence of matrix-mautrix-wsproxy service - name: Check existence of matrix-mautrix-wsproxy service
stat: ansible.builtin.stat:
path: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service" path: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service"
register: matrix_mautrix_wsproxy_service_stat register: matrix_mautrix_wsproxy_service_stat
- name: Ensure matrix-mautrix-wsproxy is stopped - name: Ensure matrix-mautrix-wsproxy is stopped
service: ansible.builtin.service:
name: matrix-mautrix-wsproxy name: matrix-mautrix-wsproxy
state: stopped state: stopped
daemon_reload: yes daemon_reload: true
when: "matrix_mautrix_wsproxy_service_stat.stat.exists" when: "matrix_mautrix_wsproxy_service_stat.stat.exists"
- name: Ensure matrix-mautrix-wsproxy.service doesn't exist - name: Ensure matrix-mautrix-wsproxy.service doesn't exist
file: ansible.builtin.file:
path: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service" path: "{{ matrix_systemd_path }}/matrix-mautrix-wsproxy.service"
state: absent state: absent
when: "matrix_mautrix_wsproxy_service_stat.stat.exists" when: "matrix_mautrix_wsproxy_service_stat.stat.exists"
- name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service removal - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service removal
service: ansible.builtin.service:
daemon_reload: yes daemon_reload: true
when: "matrix_mautrix_wsproxy_service_stat.stat.exists" when: "matrix_mautrix_wsproxy_service_stat.stat.exists"

View File

@ -1,11 +1,10 @@
--- ---
- name: Fail if required settings not defined - name: Fail if required settings not defined
fail: ansible.builtin.fail:
msg: >- msg: >-
You need to define a required configuration setting (`{{ item }}`). You need to define a required configuration setting (`{{ item }}`).
when: "vars[item] == ''" when: "vars[item] == ''"
with_items: with_items:
- "matrix_mautrix_wsproxy_appservice_token" - "matrix_mautrix_wsproxy_appservice_token"
- "matrix_mautrix_wsproxy_homeserver_token" - "matrix_mautrix_wsproxy_homeserver_token"

View File

@ -146,7 +146,7 @@
when: matrix_nginx_proxy_proxy_ntfy_enabled | bool when: matrix_nginx_proxy_proxy_ntfy_enabled | bool
- name: Ensure Matrix nginx-proxy configuration for mautrix wsproxy exists - name: Ensure Matrix nginx-proxy configuration for mautrix wsproxy exists
template: ansible.builtin.template:
src: "{{ role_path }}/templates/nginx/conf.d/matrix-mautrix-wsproxy.conf.j2" src: "{{ role_path }}/templates/nginx/conf.d/matrix-mautrix-wsproxy.conf.j2"
dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-mautrix-wsproxy.conf" dest: "{{ matrix_nginx_proxy_confd_path }}/matrix-mautrix-wsproxy.conf"
mode: 0644 mode: 0644
@ -309,7 +309,7 @@
when: "not matrix_nginx_proxy_proxy_ntfy_enabled | bool" when: "not matrix_nginx_proxy_proxy_ntfy_enabled | bool"
- name: Ensure Matrix nginx-proxy configuration for mautrix wsproxy deleted - name: Ensure Matrix nginx-proxy configuration for mautrix wsproxy deleted
file: ansible.builtin.file:
path: "{{ matrix_nginx_proxy_confd_path }}/matrix-mautrix-wsproxy.conf" path: "{{ matrix_nginx_proxy_confd_path }}/matrix-mautrix-wsproxy.conf"
state: absent state: absent
when: "not matrix_nginx_proxy_proxy_mautrix_wsproxy_enabled|bool" when: "not matrix_nginx_proxy_proxy_mautrix_wsproxy_enabled|bool"