From 495bfedc0d35f983000185c469e941501d126d10 Mon Sep 17 00:00:00 2001 From: HarHarLinks Date: Sat, 8 Jan 2022 16:51:52 +0100 Subject: [PATCH] refine hookshot role using `--test` --- roles/matrix-bridge-hookshot/defaults/main.yml | 1 + roles/matrix-bridge-hookshot/tasks/init.yml | 14 +++++++------- .../matrix-bridge-hookshot/tasks/setup_install.yml | 4 ++-- .../matrix-bridge-hookshot/templates/config.yml.j2 | 2 +- .../templates/registration.yml.j2 | 2 +- .../templates/systemd/matrix-hookshot.service.j2 | 12 ++++++------ setup.yml | 1 + 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/roles/matrix-bridge-hookshot/defaults/main.yml b/roles/matrix-bridge-hookshot/defaults/main.yml index f1f98c04e..d96f08228 100644 --- a/roles/matrix-bridge-hookshot/defaults/main.yml +++ b/roles/matrix-bridge-hookshot/defaults/main.yml @@ -10,6 +10,7 @@ matrix_hookshot_docker_image_force_pull: "{{ matrix_hookshot_docker_image.endswi matrix_hookshot_base_path: "{{ matrix_base_data_path }}/hookshot" matrix_hookshot_homeserver_address: "{{ matrix_homeserver_container_url }}" +matrix_hookshot_container_url: 'matrix-hookshot' matrix_hookshot_public_endpoint: /hookshot diff --git a/roles/matrix-bridge-hookshot/tasks/init.yml b/roles/matrix-bridge-hookshot/tasks/init.yml index 11ac01380..f6c7c107f 100644 --- a/roles/matrix-bridge-hookshot/tasks/init.yml +++ b/roles/matrix-bridge-hookshot/tasks/init.yml @@ -35,13 +35,13 @@ - name: Generate Matrix hookshot proxying configuration for matrix-nginx-proxy set_fact: - matrix_appservice_webhooks_matrix_nginx_proxy_configuration: | + matrix_hookshot_matrix_nginx_proxy_configuration: | {% if matrix_hookshot_metrics_enabled %} location {{ matrix_hookshot_metrics_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; - set $backend "matrix-hookshot:{{ matrix_hookshot_metrics_port }}"; + set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_metrics_port }}"; proxy_pass http://$backend/metrics; {% else %} {# Generic configuration for use outside of our container setup #} @@ -58,7 +58,7 @@ {% 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-hookshot:{{ matrix_hookshot_appservice_port }}"; + set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_appservice_port }}"; proxy_pass http://$backend/$1; {% else %} {# Generic configuration for use outside of our container setup #} @@ -71,7 +71,7 @@ {% 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-hookshot:{{ matrix_hookshot_provisioning_port }}"; + set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_provisioning_port }}"; proxy_pass http://$backend/$1; {% else %} {# Generic configuration for use outside of our container setup #} @@ -84,7 +84,7 @@ {% 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-hookshot:{{ matrix_hookshot_webhook_port }}"; + set $backend "{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_webhook_port }}"; proxy_pass http://$backend/$1; {% else %} {# Generic configuration for use outside of our container setup #} @@ -93,7 +93,7 @@ proxy_set_header Host $host; } - - name: Register webhooks Appservice proxying configuration with matrix-nginx-proxy + - name: Register hookshot proxying configuration with matrix-nginx-proxy set_fact: matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: | {{ @@ -113,4 +113,4 @@ Please make sure that you're proxying the `{{ matrix_hookshot_public_endpoint }}` URL endpoint to the matrix-hookshot container. You can expose the container's ports using the `matrix_hookshot_container_http_host_bind_ports` variable. - when: "matrix_appservice_webhooks_enabled|bool and matrix_nginx_proxy_enabled is not defined" + when: "matrix_hookshot_enabled|bool and matrix_nginx_proxy_enabled is not defined" diff --git a/roles/matrix-bridge-hookshot/tasks/setup_install.yml b/roles/matrix-bridge-hookshot/tasks/setup_install.yml index 2254d91cd..13bc324ba 100644 --- a/roles/matrix-bridge-hookshot/tasks/setup_install.yml +++ b/roles/matrix-bridge-hookshot/tasks/setup_install.yml @@ -21,7 +21,7 @@ - name: Check if hookshot passkey exists stat: - path: "{{ matrix_hookshot_data_path }}/passkey.pem" + path: "{{ matrix_hookshot_base_path }}/passkey.pem" register: hookshot_passkey_file - name: Generate hookshot passkey if it doesn't exist @@ -32,7 +32,7 @@ - name: Ensure hookshot config.yaml installed if provided copy: - content: "{{ matrix_hookshot_config|to_nice_yaml }}" + content: "{{ matrix_hookshot_configuration|to_nice_yaml }}" dest: "{{ matrix_hookshot_base_path }}/config.yaml" mode: 0644 owner: "{{ matrix_user_username }}" diff --git a/roles/matrix-bridge-hookshot/templates/config.yml.j2 b/roles/matrix-bridge-hookshot/templates/config.yml.j2 index 2dc87f3c6..83d84863d 100644 --- a/roles/matrix-bridge-hookshot/templates/config.yml.j2 +++ b/roles/matrix-bridge-hookshot/templates/config.yml.j2 @@ -4,7 +4,7 @@ bridge: # domain: {{ matrix_domain }} url: {{ matrix_hookshot_homeserver_address }} - mediaUrl: { matrix_hookshot_homeserver_address }} + mediaUrl: {{ matrix_hookshot_homeserver_address }} port: {{ matrix_hookshot_appservice_port }} bindAddress: 0.0.0.0 {% if matrix_hookshot_github_enabled %} diff --git a/roles/matrix-bridge-hookshot/templates/registration.yml.j2 b/roles/matrix-bridge-hookshot/templates/registration.yml.j2 index 24cd1f4cd..e86426c80 100644 --- a/roles/matrix-bridge-hookshot/templates/registration.yml.j2 +++ b/roles/matrix-bridge-hookshot/templates/registration.yml.j2 @@ -12,5 +12,5 @@ namespaces: exclusive: true sender_localpart: hookshot -url: "http://{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_hookshot_port }}" # This should match the bridge.port in your config file +url: "http://{{ matrix_hookshot_container_url }}:{{ matrix_hookshot_appservice_port }}" # This should match the bridge.port in your config file rate_limited: false diff --git a/roles/matrix-bridge-hookshot/templates/systemd/matrix-hookshot.service.j2 b/roles/matrix-bridge-hookshot/templates/systemd/matrix-hookshot.service.j2 index a291de987..16ff05920 100644 --- a/roles/matrix-bridge-hookshot/templates/systemd/matrix-hookshot.service.j2 +++ b/roles/matrix-bridge-hookshot/templates/systemd/matrix-hookshot.service.j2 @@ -13,10 +13,10 @@ DefaultDependencies=no [Service] Type=simple Environment="HOME={{ matrix_systemd_unit_home_path }}" -ExecStartPre=-{{ matrix_host_command_docker }} kill matrix-hookshot -ExecStartPre=-{{ matrix_host_command_docker }} rm matrix-hookshot +ExecStartPre=-{{ matrix_host_command_docker }} kill {{ matrix_hookshot_container_url }} +ExecStartPre=-{{ matrix_host_command_docker }} rm {{ matrix_hookshot_container_url }} -ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-hookshot \ +ExecStart={{ matrix_host_command_docker }} run --rm --name {{ matrix_hookshot_container_url }} \ --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ @@ -30,11 +30,11 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-hookshot \ {% endfor %} {{ matrix_hookshot_docker_image }} -ExecStop=-{{ matrix_host_command_docker }} kill matrix-hookshot -ExecStop=-{{ matrix_host_command_docker }} rm matrix-hookshot +ExecStop=-{{ matrix_host_command_docker }} kill {{ matrix_hookshot_container_url }} +ExecStop=-{{ matrix_host_command_docker }} rm {{ matrix_hookshot_container_url }} Restart=always RestartSec=30 -SyslogIdentifier=matrix-hookshot +SyslogIdentifier={{ matrix_hookshot_container_url }} [Install] WantedBy=multi-user.target diff --git a/setup.yml b/setup.yml index edd212057..81ab79b04 100755 --- a/setup.yml +++ b/setup.yml @@ -36,6 +36,7 @@ - matrix-bridge-mx-puppet-instagram - matrix-bridge-sms - matrix-bridge-heisenbridge + - matrix-bridge-hookshot - matrix-bot-matrix-reminder-bot - matrix-bot-go-neb - matrix-bot-mjolnir