--- - name: Create Config Dir file: path: "{{ matrix_maubot_host_data_dir }}" state: directory mode: 0755 owner: "{{ matrix_user_username }}" when: matrix_maubot_enabled|bool - name: Create User Config Dir file: path: "{{ matrix_maubot_host_config_dir }}" state: directory mode: 0755 owner: "{{ matrix_user_username }}" when: matrix_maubot_enabled|bool and matrix_maubot_host_config_dir|bool - name: Create Config File template: src: maubot_config.yaml.j2 dest: "{{ matrix_maubot_config_path }}" owner: "{{ matrix_user_username }}" mode: "u=rwx" when: matrix_maubot_enabled|bool - name: Ensure Maubot image is pulled docker_image: name: "{{ matrix_maubot_docker_image }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_maubot_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_maubot_docker_image_force_pull }}" when: matrix_maubot_enabled|bool - name: Ensure matrix-maubot.service installed template: src: "{{ role_path }}/templates/matrix-maubot.service.j2" dest: "/etc/systemd/system/matrix-maubot.service" mode: 0644 register: matrix_maubot_systemd_service_result when: matrix_maubot_enabled|bool - set_fact: matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-maubot'] }}" - name: Fail if matrix-nginx-proxy role already executed fail: msg: >- Trying to append Maubot'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-maubot role. when: matrix_nginx_proxy_role_executed|default(False)|bool and matrix_maubot_enabled|bool - name: Generate Maubot proxying configuration for matrix-nginx-proxy set_fact: matrix_maubot_matrix_nginx_proxy_configuration: | location /_matrix/maubot { {% 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; set $backend "matrix-maubot:{{ matrix_maubot_management_port }}"; proxy_pass http://$backend; {% else %} {# Generic configuration for use outside of our container setup #} proxy_pass http://127.0.0.1:{{ matrix_maubot_management_port }}; {% endif %} } when: matrix_maubot_enabled|bool - name: Register Maubot's proxying configuration with matrix-nginx-proxy set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([]) + [matrix_maubot_matrix_nginx_proxy_configuration] }} when: matrix_maubot_enabled|bool - name: Warn about reverse-proxying if matrix-nginx-proxy not used debug: msg: >- NOTE: You've enabled Maubot but are not using the matrix-nginx-proxy reverse proxy. Please make sure that you're proxying the `/_matrix/maubot` URL endpoint to the matrix-maubot container. when: "matrix_maubot_enabled|bool and matrix_nginx_proxy_enabled is not defined" # # Tasks related to getting rid of the maubot (if it was previously enabled) # - name: Check existence of matrix-maubot service stat: path: "/etc/systemd/system/matrix-maubot.service" register: matrix_maubot_service_stat when: "not matrix_maubot_enabled|bool" - name: Ensure matrix-maubot is stopped service: name: matrix-maubot state: stopped daemon_reload: yes register: stopping_result when: "not matrix_maubot_enabled|bool and matrix_maubot_service_stat.stat.exists" - name: Ensure matrix-maubot.service doesn't exist file: path: "/etc/systemd/system/matrix-maubot.service" state: absent when: "not matrix_maubot_enabled|bool and matrix_maubot_service_stat.stat.exists" - name: Ensure systemd reloaded after matrix-maubot.service removal service: daemon_reload: yes when: "not matrix_maubot_enabled|bool and matrix_maubot_service_stat.stat.exists" - name: Ensure maubot Docker image doesn't exist docker_image: name: "{{ matrix_maubot_docker_image }}" state: absent when: "not matrix_maubot_enabled|bool"