| @@ -2,6 +2,7 @@ | |||
| # Cactus Comments is a federated comment system built on Matrix | |||
| matrix_cactus_comments_enabled: true | |||
| matrix_cactus_comments_serve_client_enabled: true | |||
| matrix_cactus_comments_container_image_self_build: false | |||
| matrix_cactus_comments_docker_repo: "https://gitlab.com/cactus-comments/cactus-appservice.git" | |||
| matrix_cactus_comments_docker_repo_version: "{{ matrix_cactus_comments_version if matrix_cactus_comments_version != 'latest' else 'main' }}" | |||
| @@ -10,6 +11,8 @@ matrix_cactus_comments_docker_src_files_path: "{{ matrix_cactus_comments_base_pa | |||
| matrix_cactus_comments_base_path: "{{ matrix_base_data_path }}/cactus-comments" | |||
| matrix_cactus_comments_container_tmp_path: "{{ matrix_cactus_comments_base_path }}/tmp" | |||
| matrix_cactus_comments_client_path: "{{ matrix_cactus_comments_base_path }}/client" | |||
| matrix_cactus_comments_client_file_permissions: "0644" | |||
| matrix_cactus_comments_app_service_config_file: "{{ matrix_cactus_comments_base_path }}/cactus_appservice.yaml" | |||
| matrix_cactus_comments_app_service_env_file: "{{ matrix_cactus_comments_base_path }}/cactus.env" | |||
| @@ -26,6 +29,8 @@ matrix_cactus_comments_version: latest | |||
| matrix_cactus_comments_docker_image: "{{ matrix_container_global_registry_prefix }}cactuscomments/cactus-appservice:{{ matrix_cactus_comments_version }}" | |||
| matrix_cactus_comments_docker_image_force_pull: "{{ matrix_cactus_comments_docker_image.endswith(':latest') }}" | |||
| matrix_cactus_comments_client_endpoint: "/cactus-comments/" | |||
| # List of systemd services that matrix-cactus-comments.service depends on | |||
| matrix_bot_cactus_comments_systemd_required_services_list: ['docker.service'] | |||
| @@ -20,3 +20,48 @@ | |||
| ["/matrix-cactus-comments.yaml"] | |||
| }} | |||
| when: matrix_cactus_comments_enabled | bool | |||
| - block: | |||
| - name: Fail if matrix-nginx-proxy role already executed | |||
| ansible.builtin.fail: | |||
| msg: >- | |||
| Trying to append Cactus Comment'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 playbook, | |||
| so that the matrix-nginx-proxy role would run after the matrix-cactus-comments role. | |||
| when: matrix_nginx_proxy_role_executed | default(False) | bool | |||
| - name: Mount volume | |||
| ansible.builtin.set_fact: | |||
| matrix_nginx_proxy_container_additional_volumes: > | |||
| {{ | |||
| matrix_nginx_proxy_container_additional_volumes | default([]) | |||
| + | |||
| [{"src": "{{ matrix_cactus_comments_client_path }}", "dst": "/cactus-comments/cactus-comments", "options": "ro"}] | |||
| }} | |||
| - name: Generate Cactus Comment proxying configuration for matrix-nginx-proxy | |||
| ansible.builtin.set_fact: | |||
| matrix_cactus_comments_nginx_proxy_configuration: | | |||
| location {{ matrix_cactus_comments_client_endpoint }} { | |||
| root /cactus-comments/; | |||
| } | |||
| when: "matrix_nginx_proxy_enabled | default(False) | bool" | |||
| - name: Register Cactus Comment proxying configuration with matrix-nginx-proxy | |||
| ansible.builtin.set_fact: | |||
| matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | | |||
| {{ | |||
| matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks | default([]) | |||
| + | |||
| [matrix_cactus_comments_nginx_proxy_configuration] | |||
| }} | |||
| - name: Warn about reverse-proxying if matrix-nginx-proxy not used | |||
| ansible.builtin.debug: | |||
| msg: >- | |||
| NOTE: You've enabled Cactus Comments but are not using the matrix-nginx-proxy | |||
| reverse proxy. | |||
| Please make sure that you're proxying client files in {{ matrix_cactus_comments_client_path }} correctly | |||
| when: "not matrix_nginx_proxy_enabled | default(False) | bool" | |||
| tags: | |||
| - always | |||
| when: matrix_cactus_comments_enabled | bool and matrix_cactus_comments_serve_client_enabled | bool | |||
| @@ -9,6 +9,7 @@ | |||
| group: "{{ matrix_user_groupname }}" | |||
| with_items: | |||
| - {path: "{{ matrix_cactus_comments_base_path }}", when: true} | |||
| - {path: "{{ matrix_cactus_comments_client_path }}", when: true} | |||
| - {path: "{{ matrix_cactus_comments_container_tmp_path }}", when: true} | |||
| - {path: "{{ matrix_cactus_comments_docker_src_files_path }}", when: matrix_cactus_comments_container_image_self_build} | |||
| when: "item.when | bool" | |||
| @@ -64,6 +65,17 @@ | |||
| pull: true | |||
| when: "matrix_cactus_comments_container_image_self_build | bool" | |||
| - name: Ensure client javascript file is downloaded | |||
| ansible.builtin.get_url: | |||
| url: https://latest.cactus.chat/cactus.js | |||
| dest: "{{ matrix_cactus_comments_client_path }}/cactus.js" | |||
| mode: "{{ matrix_cactus_comments_client_file_permissions }}" | |||
| - name: Ensure client css file is downloaded | |||
| ansible.builtin.get_url: | |||
| url: https://latest.cactus.chat/style.css | |||
| dest: "{{ matrix_cactus_comments_client_path }}/style.css" | |||
| mode: "{{ matrix_cactus_comments_client_file_permissions }}" | |||
| - name: Ensure matrix-cactus-comments.service installed | |||
| ansible.builtin.template: | |||
| src: "{{ role_path }}/templates/systemd/matrix-cactus-comments.service.j2" | |||