diff --git a/docs/configuring-playbook-bridge-matrix-bridge-sms.md b/docs/configuring-playbook-bridge-matrix-bridge-sms.md index f6c5482dc..c3d733dba 100644 --- a/docs/configuring-playbook-bridge-matrix-bridge-sms.md +++ b/docs/configuring-playbook-bridge-matrix-bridge-sms.md @@ -21,23 +21,23 @@ The bridge uses [android-sms-gateway-server](https://github.com/RebekkaMa/androi To enable the bridge, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file: ```yaml -matrix_sms_bridge_enabled: true +matrix_bridge_sms_enabled: true # (optional but recommended) a room ID to a default room -matrix_sms_bridge_default_room: "" +matrix_bridge_sms_default_room: "" # (optional but recommended) configure your server location -matrix_sms_bridge_default_region: DE -matrix_sms_bridge_default_timezone: Europe/Berlin +matrix_bridge_sms_default_region: DE +matrix_bridge_sms_default_timezone: Europe/Berlin # Settings to connect to android-sms-gateway-server -matrix_sms_bridge_provider_android_baseurl: https://192.168.24.24:9090 -matrix_sms_bridge_provider_android_username: admin -matrix_sms_bridge_provider_android_password: supeSecretPassword +matrix_bridge_sms_provider_android_baseurl: https://192.168.24.24:9090 +matrix_bridge_sms_provider_android_username: admin +matrix_bridge_sms_provider_android_password: supeSecretPassword # (optional) if your android-sms-gateway-server uses a self signed vertificate, the bridge needs a "truststore". This can be the certificate itself. -matrix_sms_bridge_provider_android_truststore_local_path: android-sms-gateway-server.p12 -matrix_sms_bridge_provider_android_truststore_password: 123 +matrix_bridge_sms_provider_android_truststore_local_path: android-sms-gateway-server.p12 +matrix_bridge_sms_provider_android_truststore_password: 123 ``` ### Extending the configuration @@ -46,7 +46,7 @@ There are some additional things you may wish to configure about the bridge. Take a look at: -- `roles/custom/matrix-bridge-sms/defaults/main.yml` for some variables that you can customize via your `vars.yml` file. You can override settings (even those that don't have dedicated playbook variables) using the `matrix_sms_bridge_configuration_extension_yaml` variable +- `roles/custom/matrix-bridge-sms/defaults/main.yml` for some variables that you can customize via your `vars.yml` file. You can override settings (even those that don't have dedicated playbook variables) using the `matrix_bridge_sms_configuration_extension_yaml` variable ## Installing diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 81b27c73a..c905724b6 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -144,7 +144,7 @@ matrix_homeserver_container_extra_arguments_auto: | + (['--mount type=bind,src=' + matrix_bridge_mx_puppet_steam_config_path + '/registration.yaml,dst=/matrix-mx-puppet-steam-registration.yaml,ro'] if matrix_bridge_mx_puppet_steam_enabled else []) + - (['--mount type=bind,src=' + matrix_sms_bridge_config_path + '/registration.yaml,dst=/matrix-sms-bridge-registration.yaml,ro'] if matrix_sms_bridge_enabled else []) + (['--mount type=bind,src=' + matrix_bridge_sms_config_path + '/registration.yaml,dst=/matrix-sms-bridge-registration.yaml,ro'] if matrix_bridge_sms_enabled else []) + (['--mount type=bind,src=' + matrix_steam_bridge_config_path + '/registration.yaml,dst=/matrix-steam-bridge-registration.yaml,ro'] if matrix_steam_bridge_enabled else []) + @@ -203,7 +203,7 @@ matrix_homeserver_app_service_config_files_auto: | + (['/matrix-mx-puppet-steam-registration.yaml'] if matrix_bridge_mx_puppet_steam_enabled else []) + - (['/matrix-sms-bridge-registration.yaml'] if matrix_sms_bridge_enabled else []) + (['/matrix-sms-bridge-registration.yaml'] if matrix_bridge_sms_enabled else []) + (['/matrix-cactus-comments.yaml'] if matrix_cactus_comments_enabled else []) + @@ -541,9 +541,9 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-sms-bridge.service', 'priority': 2000, - 'restart_necessary': (matrix_sms_bridge_restart_necessary | bool), + 'restart_necessary': (matrix_bridge_sms_restart_necessary | bool), 'groups': ['matrix', 'bridges', 'sms'], - }] if matrix_sms_bridge_enabled else []) + }] if matrix_bridge_sms_enabled else []) + ([{ 'name': 'matrix-steam-bridge.service', @@ -2486,27 +2486,27 @@ matrix_bridge_mautrix_whatsapp_database_password: "{{ (matrix_homeserver_generic ###################################################################### # We don't enable bridges by default. -matrix_sms_bridge_enabled: false +matrix_bridge_sms_enabled: false -matrix_sms_bridge_systemd_required_services_list_auto: | +matrix_bridge_sms_systemd_required_services_list_auto: | {{ matrix_addons_homeserver_systemd_services_list }} -matrix_sms_bridge_container_image_registry_prefix_upstream: "{{ matrix_container_global_registry_prefix_override if matrix_container_global_registry_prefix_override else matrix_sms_bridge_container_image_registry_prefix_upstream_default }}" +matrix_bridge_sms_container_image_registry_prefix_upstream: "{{ matrix_container_global_registry_prefix_override if matrix_container_global_registry_prefix_override else matrix_bridge_sms_container_image_registry_prefix_upstream_default }}" -matrix_sms_bridge_container_network: "{{ matrix_addons_container_network }}" +matrix_bridge_sms_container_network: "{{ matrix_addons_container_network }}" -matrix_sms_bridge_container_additional_networks_auto: |- +matrix_bridge_sms_container_additional_networks_auto: |- {{ ([] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network]) }} -matrix_sms_bridge_appservice_token: "{{ (matrix_homeserver_generic_secret_key + ':sms.as.token') | hash('sha512') | to_uuid }}" +matrix_bridge_sms_appservice_token: "{{ (matrix_homeserver_generic_secret_key + ':sms.as.token') | hash('sha512') | to_uuid }}" -matrix_sms_bridge_homeserver_hostname: "{{ (matrix_homeserver_container_client_api_endpoint | split(':'))[0] }}" -matrix_sms_bridge_homeserver_port: "{{ (matrix_homeserver_container_client_api_endpoint | split(':'))[1] }}" -matrix_sms_bridge_homeserver_token: "{{ (matrix_homeserver_generic_secret_key + ':sms.hs.token') | hash('sha512') | to_uuid }}" +matrix_bridge_sms_homeserver_hostname: "{{ (matrix_homeserver_container_client_api_endpoint | split(':'))[0] }}" +matrix_bridge_sms_homeserver_port: "{{ (matrix_homeserver_container_client_api_endpoint | split(':'))[1] }}" +matrix_bridge_sms_homeserver_token: "{{ (matrix_homeserver_generic_secret_key + ':sms.hs.token') | hash('sha512') | to_uuid }}" ###################################################################### # @@ -5201,7 +5201,7 @@ matrix_ketesa_config_asManagedUsers_auto: | ([ '^@smsbot:'+(matrix_domain | regex_escape)+'$', '^@sms_[a-zA-Z0-9]+:'+(matrix_domain | regex_escape)+'$', - ] if matrix_sms_bridge_enabled else []) + ] if matrix_bridge_sms_enabled else []) + ([ '^@'+(matrix_wechat_appservice_bot_username | default('') | regex_escape)+':'+(matrix_domain | regex_escape)+'$', diff --git a/roles/custom/matrix-bridge-sms/defaults/main.yml b/roles/custom/matrix-bridge-sms/defaults/main.yml index de160e78a..d2f6127c9 100644 --- a/roles/custom/matrix-bridge-sms/defaults/main.yml +++ b/roles/custom/matrix-bridge-sms/defaults/main.yml @@ -12,61 +12,61 @@ # matrix-sms-bridge is a Matrix <-> SMS bridge # Project source code URL: https://github.com/benkuly/matrix-sms-bridge -matrix_sms_bridge_enabled: true +matrix_bridge_sms_enabled: true # renovate: datasource=docker depName=folivonet/matrix-sms-bridge -matrix_sms_bridge_version: 0.5.13 -matrix_sms_bridge_container_image: "{{ matrix_sms_bridge_container_image_registry_prefix }}folivonet/matrix-sms-bridge:{{ matrix_sms_bridge_container_image_tag }}" -matrix_sms_bridge_container_image_registry_prefix: "{{ matrix_sms_bridge_container_image_registry_prefix_upstream }}" -matrix_sms_bridge_container_image_registry_prefix_upstream: "{{ matrix_sms_bridge_container_image_registry_prefix_upstream_default }}" -matrix_sms_bridge_container_image_registry_prefix_upstream_default: "docker.io/" -matrix_sms_bridge_container_image_tag: "{{ matrix_sms_bridge_version }}" +matrix_bridge_sms_version: 0.5.13 +matrix_bridge_sms_container_image: "{{ matrix_bridge_sms_container_image_registry_prefix }}folivonet/matrix-sms-bridge:{{ matrix_bridge_sms_container_image_tag }}" +matrix_bridge_sms_container_image_registry_prefix: "{{ matrix_bridge_sms_container_image_registry_prefix_upstream }}" +matrix_bridge_sms_container_image_registry_prefix_upstream: "{{ matrix_bridge_sms_container_image_registry_prefix_upstream_default }}" +matrix_bridge_sms_container_image_registry_prefix_upstream_default: "docker.io/" +matrix_bridge_sms_container_image_tag: "{{ matrix_bridge_sms_version }}" -matrix_sms_bridge_base_path: "{{ matrix_base_data_path }}/matrix-sms-bridge" -matrix_sms_bridge_config_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/config" -matrix_sms_bridge_data_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data" +matrix_bridge_sms_base_path: "{{ matrix_base_data_path }}/matrix-sms-bridge" +matrix_bridge_sms_config_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/config" +matrix_bridge_sms_data_path: "{{ matrix_base_data_path }}/matrix-sms-bridge/data" -matrix_sms_bridge_appservice_token: '' -matrix_sms_bridge_homeserver_token: '' +matrix_bridge_sms_appservice_token: '' +matrix_bridge_sms_homeserver_token: '' -matrix_sms_bridge_container_http_host_bind_port: '' +matrix_bridge_sms_container_http_host_bind_port: '' -matrix_sms_bridge_container_network: "" +matrix_bridge_sms_container_network: "" -matrix_sms_bridge_container_additional_networks: "{{ matrix_sms_bridge_container_additional_networks_auto + matrix_sms_bridge_container_additional_networks_custom }}" -matrix_sms_bridge_container_additional_networks_auto: [] -matrix_sms_bridge_container_additional_networks_custom: [] +matrix_bridge_sms_container_additional_networks: "{{ matrix_bridge_sms_container_additional_networks_auto + matrix_bridge_sms_container_additional_networks_custom }}" +matrix_bridge_sms_container_additional_networks_auto: [] +matrix_bridge_sms_container_additional_networks_custom: [] # A list of extra arguments to pass to the container -matrix_sms_bridge_container_extra_arguments: [] +matrix_bridge_sms_container_extra_arguments: [] # List of systemd services that service depends on. -matrix_sms_bridge_systemd_required_services_list: "{{ matrix_sms_bridge_systemd_required_services_list_default + matrix_sms_bridge_systemd_required_services_list_auto + matrix_sms_bridge_systemd_required_services_list_custom }}" -matrix_sms_bridge_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" -matrix_sms_bridge_systemd_required_services_list_auto: [] -matrix_sms_bridge_systemd_required_services_list_custom: [] +matrix_bridge_sms_systemd_required_services_list: "{{ matrix_bridge_sms_systemd_required_services_list_default + matrix_bridge_sms_systemd_required_services_list_auto + matrix_bridge_sms_systemd_required_services_list_custom }}" +matrix_bridge_sms_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" +matrix_bridge_sms_systemd_required_services_list_auto: [] +matrix_bridge_sms_systemd_required_services_list_custom: [] # List of systemd services that service wants -matrix_sms_bridge_systemd_wanted_services_list: [] +matrix_bridge_sms_systemd_wanted_services_list: [] -matrix_sms_bridge_appservice_url: 'http://matrix-sms-bridge:8080' -matrix_sms_bridge_homeserver_hostname: '' -matrix_sms_bridge_homeserver_port: "" +matrix_bridge_sms_appservice_url: 'http://matrix-sms-bridge:8080' +matrix_bridge_sms_homeserver_hostname: '' +matrix_bridge_sms_homeserver_port: "" -matrix_sms_bridge_homserver_domain: "{{ matrix_domain }}" -matrix_sms_bridge_default_room: '' -matrix_sms_bridge_default_region: '' -matrix_sms_bridge_default_timezone: '' -matrix_sms_bridge_single_mode_enabled: false +matrix_bridge_sms_homserver_domain: "{{ matrix_domain }}" +matrix_bridge_sms_default_room: '' +matrix_bridge_sms_default_region: '' +matrix_bridge_sms_default_timezone: '' +matrix_bridge_sms_single_mode_enabled: false -matrix_sms_bridge_provider_android_baseurl: '' -matrix_sms_bridge_provider_android_username: '' -matrix_sms_bridge_provider_android_password: '' -matrix_sms_bridge_provider_android_truststore_local_path: '' -matrix_sms_bridge_provider_android_truststore_password: '' +matrix_bridge_sms_provider_android_baseurl: '' +matrix_bridge_sms_provider_android_username: '' +matrix_bridge_sms_provider_android_password: '' +matrix_bridge_sms_provider_android_truststore_local_path: '' +matrix_bridge_sms_provider_android_truststore_password: '' -matrix_sms_bridge_configuration_yaml: | +matrix_bridge_sms_configuration_yaml: | #jinja2: lstrip_blocks: True # Database connection @@ -75,30 +75,30 @@ matrix_sms_bridge_configuration_yaml: | sms: # (optional) SMS messages without a valid token a routed to this room. # Note that you must invite @smsbot:yourHomeServer to this room. - defaultRoomId: "{{ matrix_sms_bridge_default_room }}" - defaultRegion: "{{ matrix_sms_bridge_default_region }}" - defaultTimeZone: "{{ matrix_sms_bridge_default_timezone }}" - singleModeEnabled: "{{ matrix_sms_bridge_single_mode_enabled }}" + defaultRoomId: "{{ matrix_bridge_sms_default_room }}" + defaultRegion: "{{ matrix_bridge_sms_default_region }}" + defaultTimeZone: "{{ matrix_bridge_sms_default_timezone }}" + singleModeEnabled: "{{ matrix_bridge_sms_single_mode_enabled }}" provider: android: # (optional) default is disabled enabled: true # The url to the android-sms-gateway-server - baseUrl: {{ matrix_sms_bridge_provider_android_baseurl }} + baseUrl: {{ matrix_bridge_sms_provider_android_baseurl }} # The username of the gateway - username: {{ matrix_sms_bridge_provider_android_username }} + username: {{ matrix_bridge_sms_provider_android_username }} # The password of the gateway - password: {{ matrix_sms_bridge_provider_android_password }} + password: {{ matrix_bridge_sms_provider_android_password }} # (optional) if you use a self signed certificate, you can add the public key here - {% if matrix_sms_bridge_provider_android_truststore_local_path %} + {% if matrix_bridge_sms_provider_android_truststore_local_path %} trustStore: path: /config/matrix-sms-gateway-server.p12 - password: {{ matrix_sms_bridge_provider_android_truststore_password }} + password: {{ matrix_bridge_sms_provider_android_truststore_password }} type: PKCS12 {% endif %} bot: # The domain-part of matrix-ids. E. g. example.org when your userIds look like @unicorn:example.org - serverName: {{ matrix_sms_bridge_homserver_domain }} + serverName: {{ matrix_bridge_sms_homserver_domain }} migration: url: "jdbc:h2:file:/data/database/db" username: sa @@ -108,48 +108,48 @@ matrix_sms_bridge_configuration_yaml: | client: homeServer: # The hostname of your Homeserver. - hostname: {{ matrix_sms_bridge_homeserver_hostname }} + hostname: {{ matrix_bridge_sms_homeserver_hostname }} # (optional) The port of your Homeserver. Default is 443. - port: {{ matrix_sms_bridge_homeserver_port }} + port: {{ matrix_bridge_sms_homeserver_port }} # (optional) Use http or https. Default is true (so uses https). secure: false # The token to authenticate against the Homeserver. - token: {{ matrix_sms_bridge_appservice_token }} + token: {{ matrix_bridge_sms_appservice_token }} appservice: # A unique token for Homeservers to use to authenticate requests to this application service. - hsToken: {{ matrix_sms_bridge_homeserver_token }} + hsToken: {{ matrix_bridge_sms_homeserver_token }} -matrix_sms_bridge_configuration_extension_yaml: | +matrix_bridge_sms_configuration_extension_yaml: | # Your custom YAML configuration goes here. - # This configuration extends the default starting configuration (`matrix_sms_bridge_configuration_yaml`). + # This configuration extends the default starting configuration (`matrix_bridge_sms_configuration_yaml`). # # You can override individual variables from the default configuration, or introduce new ones. # # If you need something more special, you can take full control by - # completely redefining `matrix_sms_bridge_configuration_yaml`. + # completely redefining `matrix_bridge_sms_configuration_yaml`. -matrix_sms_bridge_configuration_extension: "{{ matrix_sms_bridge_configuration_extension_yaml | from_yaml if matrix_sms_bridge_configuration_extension_yaml | from_yaml is mapping else {} }}" +matrix_bridge_sms_configuration_extension: "{{ matrix_bridge_sms_configuration_extension_yaml | from_yaml if matrix_bridge_sms_configuration_extension_yaml | from_yaml is mapping else {} }}" -matrix_sms_bridge_configuration: "{{ matrix_sms_bridge_configuration_yaml | from_yaml | combine(matrix_sms_bridge_configuration_extension, recursive=True) }}" +matrix_bridge_sms_configuration: "{{ matrix_bridge_sms_configuration_yaml | from_yaml | combine(matrix_bridge_sms_configuration_extension, recursive=True) }}" -matrix_sms_bridge_registration_yaml: | +matrix_bridge_sms_registration_yaml: | id: sms - as_token: "{{ matrix_sms_bridge_appservice_token }}" - hs_token: "{{ matrix_sms_bridge_homeserver_token }}" + as_token: "{{ matrix_bridge_sms_appservice_token }}" + hs_token: "{{ matrix_bridge_sms_homeserver_token }}" namespaces: users: - exclusive: true - regex: '^@sms_.+:{{ matrix_sms_bridge_homserver_domain | regex_escape }}$' + regex: '^@sms_.+:{{ matrix_bridge_sms_homserver_domain | regex_escape }}$' aliases: - exclusive: true - regex: '^#sms_.+:{{ matrix_sms_bridge_homserver_domain | regex_escape }}$' - url: {{ matrix_sms_bridge_appservice_url }} + regex: '^#sms_.+:{{ matrix_bridge_sms_homserver_domain | regex_escape }}$' + url: {{ matrix_bridge_sms_appservice_url }} sender_localpart: smsbot rate_limited: false -matrix_sms_bridge_registration: "{{ matrix_sms_bridge_registration_yaml | from_yaml }}" +matrix_bridge_sms_registration: "{{ matrix_bridge_sms_registration_yaml | from_yaml }}" -# matrix_sms_bridge_restart_necessary controls whether the service +# matrix_bridge_sms_restart_necessary controls whether the service # will be restarted (when true) or merely started (when false) by the # systemd service manager role (when conditional restart is enabled). # @@ -157,4 +157,4 @@ matrix_sms_bridge_registration: "{{ matrix_sms_bridge_registration_yaml | from_y # any configuration files, the systemd service file, or the container image changed. # The default of `false` means "no restart needed" — appropriate when the role's # installation tasks haven't run (e.g., due to --tags skipping them). -matrix_sms_bridge_restart_necessary: false +matrix_bridge_sms_restart_necessary: false diff --git a/roles/custom/matrix-bridge-sms/tasks/main.yml b/roles/custom/matrix-bridge-sms/tasks/main.yml index 574dba74b..3bb04af7e 100644 --- a/roles/custom/matrix-bridge-sms/tasks/main.yml +++ b/roles/custom/matrix-bridge-sms/tasks/main.yml @@ -12,15 +12,15 @@ - install-all - install-matrix-sms-bridge block: - - when: matrix_sms_bridge_enabled | bool + - when: matrix_bridge_sms_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" - - when: matrix_sms_bridge_enabled | bool + - when: matrix_bridge_sms_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml" - tags: - setup-all - setup-matrix-sms-bridge block: - - when: not matrix_sms_bridge_enabled | bool + - when: not matrix_bridge_sms_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml" diff --git a/roles/custom/matrix-bridge-sms/tasks/setup_install.yml b/roles/custom/matrix-bridge-sms/tasks/setup_install.yml index b3470466b..ee5b6af28 100644 --- a/roles/custom/matrix-bridge-sms/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-sms/tasks/setup_install.yml @@ -12,12 +12,12 @@ - name: Ensure matrix-sms-bridge image is pulled community.docker.docker_image_pull: - name: "{{ matrix_sms_bridge_container_image }}" + name: "{{ matrix_bridge_sms_container_image }}" pull: always - register: matrix_sms_bridge_container_image_pull_result + register: matrix_bridge_sms_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: matrix_sms_bridge_container_image_pull_result is not failed + until: matrix_bridge_sms_container_image_pull_result is not failed - name: Ensure matrix-sms-bridge paths exist ansible.builtin.file: @@ -27,43 +27,43 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" with_items: - - "{{ matrix_sms_bridge_base_path }}" - - "{{ matrix_sms_bridge_config_path }}" - - "{{ matrix_sms_bridge_data_path }}" + - "{{ matrix_bridge_sms_base_path }}" + - "{{ matrix_bridge_sms_config_path }}" + - "{{ matrix_bridge_sms_data_path }}" - name: Ensure matrix-sms-bridge application.yml installed ansible.builtin.copy: - content: "{{ matrix_sms_bridge_configuration | to_nice_yaml(indent=2, width=999999) }}" - dest: "{{ matrix_sms_bridge_config_path }}/application.yml" + content: "{{ matrix_bridge_sms_configuration | to_nice_yaml(indent=2, width=999999) }}" + dest: "{{ matrix_bridge_sms_config_path }}/application.yml" mode: '0644' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" - register: matrix_sms_bridge_config_result + register: matrix_bridge_sms_config_result - name: Ensure matrix-sms-bridge registration.yaml installed ansible.builtin.copy: - content: "{{ matrix_sms_bridge_registration | to_nice_yaml(indent=2, width=999999) }}" - dest: "{{ matrix_sms_bridge_config_path }}/registration.yaml" + content: "{{ matrix_bridge_sms_registration | to_nice_yaml(indent=2, width=999999) }}" + dest: "{{ matrix_bridge_sms_config_path }}/registration.yaml" mode: '0644' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" - register: matrix_sms_bridge_registration_result + register: matrix_bridge_sms_registration_result - name: Ensure android-sms-gateway-server cert installed ansible.builtin.copy: - src: "{{ matrix_sms_bridge_provider_android_truststore_local_path }}" - dest: "{{ matrix_sms_bridge_config_path }}/matrix-sms-gateway-server.p12" + src: "{{ matrix_bridge_sms_provider_android_truststore_local_path }}" + dest: "{{ matrix_bridge_sms_config_path }}/matrix-sms-gateway-server.p12" mode: '0644' owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" - when: matrix_sms_bridge_provider_android_truststore_local_path != "" - register: matrix_sms_bridge_cert_result + when: matrix_bridge_sms_provider_android_truststore_local_path != "" + register: matrix_bridge_sms_cert_result - name: Ensure matrix-sms-bridge container network is created - when: matrix_sms_bridge_container_network != 'host' + when: matrix_bridge_sms_container_network != 'host' community.general.docker_network: enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}" - name: "{{ matrix_sms_bridge_container_network }}" + name: "{{ matrix_bridge_sms_container_network }}" driver: bridge driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}" @@ -72,15 +72,15 @@ src: "{{ role_path }}/templates/systemd/matrix-sms-bridge.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-sms-bridge.service" mode: '0644' - register: matrix_sms_bridge_systemd_service_result + register: matrix_bridge_sms_systemd_service_result - name: Determine whether matrix-sms-bridge needs a restart ansible.builtin.set_fact: - matrix_sms_bridge_restart_necessary: >- + matrix_bridge_sms_restart_necessary: >- {{ - matrix_sms_bridge_config_result.changed | default(false) - or matrix_sms_bridge_registration_result.changed | default(false) - or matrix_sms_bridge_cert_result.changed | default(false) - or matrix_sms_bridge_systemd_service_result.changed | default(false) - or matrix_sms_bridge_container_image_pull_result.changed | default(false) + matrix_bridge_sms_config_result.changed | default(false) + or matrix_bridge_sms_registration_result.changed | default(false) + or matrix_bridge_sms_cert_result.changed | default(false) + or matrix_bridge_sms_systemd_service_result.changed | default(false) + or matrix_bridge_sms_container_image_pull_result.changed | default(false) }} diff --git a/roles/custom/matrix-bridge-sms/tasks/setup_uninstall.yml b/roles/custom/matrix-bridge-sms/tasks/setup_uninstall.yml index f6e1e2a6e..c16eb5d6b 100644 --- a/roles/custom/matrix-bridge-sms/tasks/setup_uninstall.yml +++ b/roles/custom/matrix-bridge-sms/tasks/setup_uninstall.yml @@ -9,7 +9,7 @@ - name: Check existence of matrix-sms-bridge service ansible.builtin.stat: path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-sms-bridge.service" - register: matrix_sms_bridge_service_stat + register: matrix_bridge_sms_service_stat - name: Ensure matrix-sms-bridge is stopped ansible.builtin.service: @@ -17,10 +17,10 @@ state: stopped enabled: false daemon_reload: true - when: "matrix_sms_bridge_service_stat.stat.exists" + when: "matrix_bridge_sms_service_stat.stat.exists" - name: Ensure matrix-sms-bridge.service doesn't exist ansible.builtin.file: path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-sms-bridge.service" state: absent - when: "matrix_sms_bridge_service_stat.stat.exists" + when: "matrix_bridge_sms_service_stat.stat.exists" diff --git a/roles/custom/matrix-bridge-sms/tasks/validate_config.yml b/roles/custom/matrix-bridge-sms/tasks/validate_config.yml index ffa6c4caf..0cac7dc72 100644 --- a/roles/custom/matrix-bridge-sms/tasks/validate_config.yml +++ b/roles/custom/matrix-bridge-sms/tasks/validate_config.yml @@ -14,12 +14,12 @@ Please rename the variable (`{{ item.old }}` -> `{{ item.new }}`) on your configuration file (vars.yml). when: "lookup('ansible.builtin.varnames', ('^' + item.old + '$'), wantlist=True) | length > 0" with_items: - - {'old': 'matrix_sms_bridge_docker_image', 'new': 'matrix_sms_bridge_container_image'} - - {'old': 'matrix_sms_bridge_docker_image_registry_prefix', 'new': 'matrix_sms_bridge_container_image_registry_prefix'} - - {'old': 'matrix_sms_bridge_docker_image_registry_prefix_upstream', 'new': 'matrix_sms_bridge_container_image_registry_prefix_upstream'} - - {'old': 'matrix_sms_bridge_docker_image_registry_prefix_upstream_default', 'new': 'matrix_sms_bridge_container_image_registry_prefix_upstream_default'} - - {'old': 'matrix_sms_bridge_docker_image_tag', 'new': 'matrix_sms_bridge_container_image_tag'} - - {'old': 'matrix_sms_bridge_container_image_force_pull', 'new': ' (the new community.docker.docker_image_pull module handles this natively)'} + - {'old': 'matrix_bridge_sms_docker_image', 'new': 'matrix_bridge_sms_container_image'} + - {'old': 'matrix_bridge_sms_docker_image_registry_prefix', 'new': 'matrix_bridge_sms_container_image_registry_prefix'} + - {'old': 'matrix_bridge_sms_docker_image_registry_prefix_upstream', 'new': 'matrix_bridge_sms_container_image_registry_prefix_upstream'} + - {'old': 'matrix_bridge_sms_docker_image_registry_prefix_upstream_default', 'new': 'matrix_bridge_sms_container_image_registry_prefix_upstream_default'} + - {'old': 'matrix_bridge_sms_docker_image_tag', 'new': 'matrix_bridge_sms_container_image_tag'} + - {'old': 'matrix_bridge_sms_container_image_force_pull', 'new': ' (the new community.docker.docker_image_pull module handles this natively)'} - name: Fail if required matrix-bridge-sms settings not defined @@ -28,13 +28,13 @@ You need to define a required configuration setting (`{{ item }}`). when: "lookup('vars', item, default='') == ''" with_items: - - "matrix_sms_bridge_appservice_token" - - "matrix_sms_bridge_homeserver_hostname" - - "matrix_sms_bridge_homeserver_port" - - "matrix_sms_bridge_homeserver_token" - - "matrix_sms_bridge_default_region" - - "matrix_sms_bridge_default_timezone" - - "matrix_sms_bridge_provider_android_baseurl" - - "matrix_sms_bridge_provider_android_username" - - "matrix_sms_bridge_provider_android_password" - - "matrix_sms_bridge_container_network" + - "matrix_bridge_sms_appservice_token" + - "matrix_bridge_sms_homeserver_hostname" + - "matrix_bridge_sms_homeserver_port" + - "matrix_bridge_sms_homeserver_token" + - "matrix_bridge_sms_default_region" + - "matrix_bridge_sms_default_timezone" + - "matrix_bridge_sms_provider_android_baseurl" + - "matrix_bridge_sms_provider_android_username" + - "matrix_bridge_sms_provider_android_password" + - "matrix_bridge_sms_container_network" diff --git a/roles/custom/matrix-bridge-sms/templates/systemd/matrix-sms-bridge.service.j2 b/roles/custom/matrix-bridge-sms/templates/systemd/matrix-sms-bridge.service.j2 index 69f2017c8..6219c9c9d 100644 --- a/roles/custom/matrix-bridge-sms/templates/systemd/matrix-sms-bridge.service.j2 +++ b/roles/custom/matrix-bridge-sms/templates/systemd/matrix-sms-bridge.service.j2 @@ -1,11 +1,11 @@ #jinja2: lstrip_blocks: True [Unit] Description=Matrix sms bridge -{% for service in matrix_sms_bridge_systemd_required_services_list %} +{% for service in matrix_bridge_sms_systemd_required_services_list %} Requires={{ service }} After={{ service }} {% endfor %} -{% for service in matrix_sms_bridge_systemd_wanted_services_list %} +{% for service in matrix_bridge_sms_systemd_wanted_services_list %} Wants={{ service }} {% endfor %} DefaultDependencies=no @@ -22,20 +22,20 @@ ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \ --log-driver=none \ --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \ --cap-drop=ALL \ - --network={{ matrix_sms_bridge_container_network }} \ - {% if matrix_sms_bridge_container_http_host_bind_port %} - -p {{ matrix_sms_bridge_container_http_host_bind_port }}:8080 \ + --network={{ matrix_bridge_sms_container_network }} \ + {% if matrix_bridge_sms_container_http_host_bind_port %} + -p {{ matrix_bridge_sms_container_http_host_bind_port }}:8080 \ {% endif %} - --mount type=bind,src={{ matrix_sms_bridge_config_path }},dst=/config \ - --mount type=bind,src={{ matrix_sms_bridge_data_path }},dst=/data \ + --mount type=bind,src={{ matrix_bridge_sms_config_path }},dst=/config \ + --mount type=bind,src={{ matrix_bridge_sms_data_path }},dst=/data \ --env SPRING_CONFIG_ADDITIONAL_LOCATION=/config/application.yml \ - {% for arg in matrix_sms_bridge_container_extra_arguments %} + {% for arg in matrix_bridge_sms_container_extra_arguments %} {{ arg }} \ {% endfor %} - {{ matrix_sms_bridge_container_image }} + {{ matrix_bridge_sms_container_image }} -{% if matrix_sms_bridge_container_network != 'host' %} -{% for network in matrix_sms_bridge_container_additional_networks %} +{% if matrix_bridge_sms_container_network != 'host' %} +{% for network in matrix_bridge_sms_container_additional_networks %} ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-sms-bridge {% endfor %} {% endif %}