diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 74ccafe48..8ebd26e46 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -1339,6 +1339,11 @@ matrix_cactus_comments_enabled: false matrix_cactus_comments_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm32', 'arm64'] }}" +# Normally, matrix-nginx-proxy is enabled and nginx can reach cactus-comments over the container network. +# If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, you can expose +# cactus-comments web-server port. +#matrix_cactus_comments_container_http_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:' + matrix_cactus_comments_container_port | string }}" + matrix_corporal_systemd_required_services_list: | {{ (['docker.service']) diff --git a/roles/matrix-cactus-comments/defaults/main.yml b/roles/matrix-cactus-comments/defaults/main.yml index b925b9efa..c0c1a35ea 100644 --- a/roles/matrix-cactus-comments/defaults/main.yml +++ b/roles/matrix-cactus-comments/defaults/main.yml @@ -10,6 +10,8 @@ matrix_cactus_comments_hs_token: '' matrix_cactus_comments_homeserver_url: '' matrix_cactus_comments_user_id: cactus-comments +matrix_cactus_comments_container_port: 5005 + 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') }}" diff --git a/roles/matrix-cactus-comments/templates/cactus_appservice.yaml.j2 b/roles/matrix-cactus-comments/templates/cactus_appservice.yaml.j2 index b41ceba19..c37fd2fec 100644 --- a/roles/matrix-cactus-comments/templates/cactus_appservice.yaml.j2 +++ b/roles/matrix-cactus-comments/templates/cactus_appservice.yaml.j2 @@ -2,16 +2,16 @@ id: "Cactus Comments" # Where the cactus-appservice is hosted: -url: "http://cactus:5000" +url: "http://matrix-cactus-comments:{{ matrix_cactus_comments_container_port }}" # Unique tokens used to authenticate requests between our service and the # homeserver (and the other way). Use the sha256 hashes of something random. # CHANGE THESE VALUES. -as_token: "a2d7789eedb3c5076af0864f4af7bef77b1f250ac4e454c373c806876e939cca" -hs_token: "b3b05236568ab46f0d98a978936c514eac93d8f90e6d5cd3895b3db5bb8d788b" +as_token: "{{ matrix_cactus_comments_as_token }}" +hs_token: "{{ matrix_cactus_comments_hs_token }}" # User associated with our service. In this case "@cactusbot:example.com" -sender_localpart: "cactusbot" +sender_localpart: "{{ matrix_cactus_comments_user_id }}" namespaces: aliases: diff --git a/roles/matrix-cactus-comments/templates/env.j2 b/roles/matrix-cactus-comments/templates/env.j2 index 21c395e1d..ab0489612 100644 --- a/roles/matrix-cactus-comments/templates/env.j2 +++ b/roles/matrix-cactus-comments/templates/env.j2 @@ -1,6 +1,6 @@ -CACTUS_HS_TOKEN=b3b05236568ab46f0d98a978936c514eac93d8f90e6d5cd3895b3db5bb8d788b -CACTUS_AS_TOKEN=a2d7789eedb3c5076af0864f4af7bef77b1f250ac4e454c373c806876e939cca -CACTUS_HOMESERVER_URL=http://synapse:8008 -CACTUS_USER_ID=@cactusbot:example.com +CACTUS_HS_TOKEN={{ matrix_cactus_comments_hs_token }} +CACTUS_AS_TOKEN={{ matrix_cactus_comments_as_token }} +CACTUS_HOMESERVER_URL={{ matrix_cactus_comments_homeserver_url }} +CACTUS_USER_ID=@{{ matrix_cactus_comments_user_id }}:{{ matrix_domain }} {{ matrix_cactus_comments_environment_variables_extension }} diff --git a/roles/matrix-cactus-comments/templates/systemd/matrix-cactus-comments.service.j2 b/roles/matrix-cactus-comments/templates/systemd/matrix-cactus-comments.service.j2 index cbbb2d390..763fd6896 100644 --- a/roles/matrix-cactus-comments/templates/systemd/matrix-cactus-comments.service.j2 +++ b/roles/matrix-cactus-comments/templates/systemd/matrix-cactus-comments.service.j2 @@ -1,11 +1,11 @@ #jinja2: lstrip_blocks: "True" [Unit] Description=Cactus Comments -{% for service in matrix_bot_matrix_registration_bot_systemd_required_services_list %} +{% for service in matrix_bot_cactus_comments_systemd_required_services_list %} Requires={{ service }} After={{ service }} {% endfor %} -{% for service in matrix_bot_matrix_registration_bot_systemd_wanted_services_list %} +{% for service in matrix_bot_cactus_comments_systemd_wanted_services_list %} Wants={{ service }} {% endfor %} DefaultDependencies=no @@ -13,25 +13,24 @@ DefaultDependencies=no [Service] Type=simple Environment="HOME={{ matrix_systemd_unit_home_path }}" -ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-matrix-registration-bot 2>/dev/null || true' -ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-matrix-registration-bot 2>/dev/null || true' +ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-cactus-comments 2>/dev/null || true' +ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-cactus-comments 2>/dev/null || true' -ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-matrix-registration-bot \ +ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-cactus-comments \ --log-driver=none \ --cap-drop=ALL \ -e "CONFIG_PATH=/config/config.yml" \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --read-only \ - --mount type=bind,src={{ matrix_bot_matrix_registration_bot_config_path }},dst=/config,ro \ - --mount type=bind,src={{ matrix_bot_matrix_registration_bot_data_path }},dst=/data \ + --mount type=bind,src={{ matrix_cactus_comments_config_path }},dst=/config,ro \ --network={{ matrix_docker_network }} \ - {{ matrix_bot_matrix_registration_bot_docker_image }} + {{ matrix_cactus_comments_docker_image }} -ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-matrix-registration-bot 2>/dev/null || true' -ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-matrix-registration-bot 2>/dev/null || true' +ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-cactus-comments 2>/dev/null || true' +ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-cactus-comments 2>/dev/null || true' Restart=always RestartSec=30 -SyslogIdentifier=matrix-bot-matrix-registration-bot +SyslogIdentifier=matrix-cactus-comments [Install] WantedBy=multi-user.target