diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index f5ef21263..25006590e 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -290,7 +290,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-alertmanager-receiver.service', 'priority': 2200, - 'restart_necessary': true, + 'restart_necessary': (matrix_alertmanager_receiver_restart_necessary | bool), 'groups': ['matrix', 'alertmanager-receiver'], }] if matrix_alertmanager_receiver_enabled else []) + @@ -374,7 +374,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-appservice-draupnir-for-all.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_appservice_draupnir_for_all_restart_necessary | bool), 'groups': ['matrix', 'bridges', 'draupnir-for-all', 'appservice-draupnir-for-all'], }] if matrix_appservice_draupnir_for_all_enabled else []) + @@ -521,14 +521,14 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-mautrix-wsproxy.service', 'priority': 2000, - 'restart_necessary': true, + 'restart_necessary': (matrix_mautrix_wsproxy_restart_necessary | bool), 'groups': ['matrix', 'bridges', 'mautrix-wsproxy'], }] if matrix_mautrix_wsproxy_enabled else []) + ([{ 'name': 'matrix-mautrix-wsproxy-syncproxy.service', 'priority': 2000, - 'restart_necessary': true, + 'restart_necessary': (matrix_mautrix_wsproxy_syncproxy_restart_necessary | bool), 'groups': ['matrix', 'bridges', 'mautrix-wsproxy-syncproxy'], }] if matrix_mautrix_wsproxy_enabled else []) + @@ -570,14 +570,14 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-cactus-comments.service', 'priority': 2000, - 'restart_necessary': true, + 'restart_necessary': (matrix_cactus_comments_restart_necessary | bool), 'groups': ['matrix', 'cactus-comments'], }] if matrix_cactus_comments_enabled else []) + ([{ 'name': 'matrix-cactus-comments-client.service', 'priority': 2000, - 'restart_necessary': true, + 'restart_necessary': (matrix_cactus_comments_client_restart_necessary | bool), 'groups': ['matrix', 'cactus-comments-client'], }] if matrix_cactus_comments_client_enabled else []) + @@ -626,7 +626,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-corporal.service', 'priority': 1500, - 'restart_necessary': true, + 'restart_necessary': (matrix_corporal_restart_necessary | bool), 'groups': ['matrix', 'corporal'], }] if matrix_corporal_enabled else []) + @@ -640,14 +640,14 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-matrixto.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_matrixto_restart_necessary | bool), 'groups': ['matrix', 'matrixto'], }] if matrix_matrixto_enabled else []) + ([{ 'name': 'matrix-rageshake.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_rageshake_restart_necessary | bool), 'groups': ['matrix', 'rageshake'], }] if matrix_rageshake_enabled else []) + @@ -710,7 +710,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-ldap-registration-proxy.service', 'priority': 2000, - 'restart_necessary': true, + 'restart_necessary': (matrix_ldap_registration_proxy_restart_necessary | bool), 'groups': ['matrix', 'ldap-registration-proxy'], }] if matrix_ldap_registration_proxy_enabled else []) + @@ -773,7 +773,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-prometheus-nginxlog-exporter.service', 'priority': 3900, - 'restart_necessary': true, + 'restart_necessary': (matrix_prometheus_nginxlog_exporter_restart_necessary | bool), 'groups': ['matrix', 'monitoring', 'prometheus-exporters', 'prometheus-nginxlog-exporter'], }] if matrix_prometheus_nginxlog_exporter_enabled else []) + @@ -787,14 +787,14 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-pantalaimon.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_pantalaimon_restart_necessary | bool), 'groups': ['matrix', 'pantalaimon'], }] if matrix_pantalaimon_enabled else []) + ([{ 'name': 'matrix-element-admin.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_element_admin_restart_necessary | bool), 'groups': ['matrix', 'element-admin'], }] if matrix_element_admin_enabled else []) + @@ -808,7 +808,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-livekit-jwt-service.service', 'priority': 3500, - 'restart_necessary': true, + 'restart_necessary': (matrix_livekit_jwt_service_restart_necessary | bool), 'groups': ['matrix', 'livekit-jwt-service'], }] if matrix_livekit_jwt_service_enabled else []) + @@ -822,14 +822,14 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-registration.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_registration_restart_necessary | bool), 'groups': ['matrix', 'registration', 'matrix-registration'], }] if matrix_registration_enabled else []) + ([{ 'name': 'matrix-sygnal.service', 'priority': 800, - 'restart_necessary': true, + 'restart_necessary': (matrix_sygnal_restart_necessary | bool), 'groups': ['matrix', 'sygnal'], }] if matrix_sygnal_enabled else []) + @@ -850,42 +850,42 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': 'matrix-synapse-auto-compressor.timer', 'priority': 5000, - 'restart_necessary': true, + 'restart_necessary': (matrix_synapse_auto_compressor_restart_necessary | bool), 'groups': ['matrix', 'synapse-auto-compressor'], }] if matrix_synapse_auto_compressor_enabled else []) + ([{ 'name': 'matrix-synapse-admin.service', 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_synapse_admin_restart_necessary | bool), 'groups': ['matrix', 'synapse-admin'], }] if matrix_synapse_admin_enabled else []) + ([{ 'name': (matrix_synapse_usage_exporter_identifier + '.service'), 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_synapse_usage_exporter_restart_necessary | bool), 'groups': ['matrix', 'synapse-usage-exporter'], }] if matrix_synapse_usage_exporter_enabled else []) + ([{ 'name': 'matrix-synapse-reverse-proxy-companion.service', 'priority': 1500, - 'restart_necessary': true, + 'restart_necessary': (matrix_synapse_reverse_proxy_companion_restart_necessary | bool), 'groups': ['matrix', 'homeservers', 'synapse', 'synapse-reverse-proxy-companion', 'reverse-proxies'], }] if matrix_synapse_reverse_proxy_companion_enabled else []) + ([{ 'name': 'matrix-user-verification-service.service', 'priority': 800, - 'restart_necessary': true, + 'restart_necessary': (matrix_user_verification_service_restart_necessary | bool), 'groups': ['matrix', 'matrix-user-verification-service'], }] if matrix_user_verification_service_enabled else []) + ([{ 'name': (matrix_static_files_identifier + '.service'), 'priority': 4000, - 'restart_necessary': true, + 'restart_necessary': (matrix_static_files_restart_necessary | bool), 'groups': ['matrix', 'matrix-static-files'], }] if matrix_static_files_enabled else []) + diff --git a/roles/custom/matrix-alertmanager-receiver/defaults/main.yml b/roles/custom/matrix-alertmanager-receiver/defaults/main.yml index 0cd469422..020fea127 100644 --- a/roles/custom/matrix-alertmanager-receiver/defaults/main.yml +++ b/roles/custom/matrix-alertmanager-receiver/defaults/main.yml @@ -235,3 +235,13 @@ matrix_alertmanager_receiver_configuration_extension: "{{ matrix_alertmanager_re # Holds the final matrix-alertmanager-receiver configuration (a combination of the default and its extension). # You most likely don't need to touch this variable. Instead, see `matrix_alertmanager_receiver_configuration_yaml`. matrix_alertmanager_receiver_configuration: "{{ matrix_alertmanager_receiver_configuration_yaml | from_yaml | combine(matrix_alertmanager_receiver_configuration_extension, recursive=True) }}" + +# matrix_alertmanager_receiver_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). +# +# This value is automatically computed during installation based on whether +# 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_alertmanager_receiver_restart_necessary: false diff --git a/roles/custom/matrix-alertmanager-receiver/tasks/install.yml b/roles/custom/matrix-alertmanager-receiver/tasks/install.yml index d47c27837..32c94ea6a 100644 --- a/roles/custom/matrix-alertmanager-receiver/tasks/install.yml +++ b/roles/custom/matrix-alertmanager-receiver/tasks/install.yml @@ -28,6 +28,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_alertmanager_receiver_config_result - name: Ensure matrix-alertmanager-receiver support files installed ansible.builtin.template: @@ -38,6 +39,7 @@ group: "{{ matrix_group_name }}" with_items: - labels + register: matrix_alertmanager_receiver_support_files_result - name: Ensure matrix-alertmanager-receiver container image is pulled community.docker.docker_image: @@ -46,10 +48,10 @@ force_source: "{{ matrix_alertmanager_receiver_container_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_alertmanager_receiver_container_image_force_pull }}" when: "not matrix_alertmanager_receiver_container_image_self_build | bool" - register: result + register: matrix_alertmanager_receiver_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_alertmanager_receiver_container_image_pull_result is not failed - when: matrix_alertmanager_receiver_container_image_self_build | bool block: @@ -84,3 +86,14 @@ src: "{{ role_path }}/templates/systemd/matrix-alertmanager-receiver.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-alertmanager-receiver.service" mode: 0644 + register: matrix_alertmanager_receiver_systemd_service_result + +- name: Determine whether matrix-alertmanager-receiver needs a restart + ansible.builtin.set_fact: + matrix_alertmanager_receiver_restart_necessary: >- + {{ + matrix_alertmanager_receiver_config_result.changed | default(false) + or matrix_alertmanager_receiver_support_files_result.changed | default(false) + or matrix_alertmanager_receiver_systemd_service_result.changed | default(false) + or matrix_alertmanager_receiver_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml b/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml index 2a38108bb..462dc1f8a 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/defaults/main.yml @@ -110,3 +110,13 @@ matrix_appservice_draupnir_for_all_configuration_extension: "{{ matrix_appservic # Holds the final configuration (a combination of the default and its extension). # You most likely don't need to touch this variable. Instead, see `matrix_appservice_draupnir_for_all_configuration_yaml`. matrix_appservice_draupnir_for_all_configuration: "{{ matrix_appservice_draupnir_for_all_configuration_yaml | from_yaml | combine(matrix_appservice_draupnir_for_all_configuration_extension, recursive=True) }}" + +# matrix_appservice_draupnir_for_all_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). +# +# This value is automatically computed during installation based on whether +# 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_appservice_draupnir_for_all_restart_necessary: false diff --git a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml index 73f365bb1..10e082e02 100644 --- a/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml +++ b/roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml @@ -32,10 +32,10 @@ force_source: "{{ matrix_appservice_draupnir_for_all_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_appservice_draupnir_for_all_docker_image_force_pull }}" when: "not matrix_appservice_draupnir_for_all_container_image_self_build | bool" - register: result + register: matrix_appservice_draupnir_for_all_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_appservice_draupnir_for_all_container_image_pull_result is not failed - name: Ensure Draupnir repository is present on self-build ansible.builtin.git: @@ -66,6 +66,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_appservice_draupnir_for_all_appservice_config_result - name: Ensure matrix-appservice-draupnir-for-all bot config installed ansible.builtin.copy: @@ -74,6 +75,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_appservice_draupnir_for_all_bot_config_result - name: Ensure matrix-appservice-draupnir-for-all registration.yaml installed ansible.builtin.copy: @@ -82,6 +84,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_appservice_draupnir_for_all_registration_config_result - name: Ensure matrix-appservice-draupnir-for-all container network is created community.general.docker_network: @@ -97,6 +100,18 @@ mode: 0644 register: matrix_appservice_draupnir_for_all_systemd_service_result +- name: Determine whether Draupnir for All needs a restart + ansible.builtin.set_fact: + matrix_appservice_draupnir_for_all_restart_necessary: >- + {{ + matrix_appservice_draupnir_for_all_migration_requires_restart | default(false) + or matrix_appservice_draupnir_for_all_appservice_config_result.changed | default(false) + or matrix_appservice_draupnir_for_all_bot_config_result.changed | default(false) + or matrix_appservice_draupnir_for_all_registration_config_result.changed | default(false) + or matrix_appservice_draupnir_for_all_systemd_service_result.changed | default(false) + or matrix_appservice_draupnir_for_all_container_image_pull_result.changed | default(false) + }} + - name: Ensure matrix-appservice-draupnir-for-all.service restarted, if necessary ansible.builtin.service: name: "matrix-appservice-draupnir-for-all.service" diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml index b55933180..4b612a120 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/defaults/main.yml @@ -178,3 +178,23 @@ matrix_mautrix_wsproxy_syncproxy_database_port: 5432 matrix_mautrix_wsproxy_syncproxy_database_name: 'matrix_mautrix_wsproxy_syncproxy' matrix_mautrix_signal_wsproxy_syncproxy_connection_string: 'postgres://{{ matrix_mautrix_wsproxy_syncproxy_database_username }}:{{ matrix_mautrix_wsproxy_syncproxy_database_password }}@{{ matrix_mautrix_wsproxy_syncproxy_database_hostname }}:{{ matrix_mautrix_wsproxy_syncproxy_database_port }}/{{ matrix_mautrix_wsproxy_syncproxy_database_name }}' + +# matrix_mautrix_wsproxy_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). +# +# This value is automatically computed during installation based on whether +# 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_mautrix_wsproxy_restart_necessary: false + +# matrix_mautrix_wsproxy_syncproxy_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). +# +# This value is automatically computed during installation based on whether +# 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_mautrix_wsproxy_syncproxy_restart_necessary: false diff --git a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml index d683f4900..5801efcaa 100644 --- a/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml +++ b/roles/custom/matrix-bridge-mautrix-wsproxy/tasks/setup_install.yml @@ -43,6 +43,7 @@ with_items: - syncproxy-env - wsproxy-labels + register: matrix_mautrix_wsproxy_support_files_result - name: Ensure Mautrix wsproxy image is pulled community.docker.docker_image: @@ -50,6 +51,7 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_mautrix_wsproxy_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_mautrix_wsproxy_docker_image_force_pull }}" + register: matrix_mautrix_wsproxy_container_image_pull_result - name: Ensure Mautrix syncproxy image is pulled community.docker.docker_image: @@ -57,6 +59,7 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_mautrix_wsproxy_syncproxy_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_mautrix_wsproxy_syncproxy_docker_image_force_pull }}" + register: matrix_mautrix_wsproxy_syncproxy_container_image_pull_result - name: Ensure Mautrix wsproxy paths exists ansible.builtin.file: @@ -81,6 +84,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_mautrix_wsproxy_config_result - name: Ensure mautrix-androidsms registration.yaml installed ansible.builtin.copy: @@ -89,6 +93,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_mautrix_wsproxy_registration_androidsms_result - name: Ensure mautrix-imessage registration.yaml installed ansible.builtin.copy: @@ -97,6 +102,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_mautrix_wsproxy_registration_imessage_result - name: Ensure mautrix-wsproxy container network is created community.general.docker_network: @@ -112,6 +118,19 @@ mode: 0644 register: matrix_mautrix_wsproxy_systemd_service_result +- name: Determine whether Mautrix wsproxy needs a restart + ansible.builtin.set_fact: + matrix_mautrix_wsproxy_restart_necessary: >- + {{ + matrix_mautrix_wsproxy_migration_requires_restart | default(false) + or matrix_mautrix_wsproxy_support_files_result.changed | default(false) + or matrix_mautrix_wsproxy_config_result.changed | default(false) + or matrix_mautrix_wsproxy_registration_androidsms_result.changed | default(false) + or matrix_mautrix_wsproxy_registration_imessage_result.changed | default(false) + or matrix_mautrix_wsproxy_systemd_service_result.changed | default(false) + or matrix_mautrix_wsproxy_container_image_pull_result.changed | default(false) + }} + - name: Ensure systemd reloaded after matrix-mautrix-wsproxy.service installation ansible.builtin.service: daemon_reload: true @@ -130,6 +149,15 @@ mode: 0644 register: matrix_mautrix_wsproxy_syncproxy_systemd_service_result +- name: Determine whether Mautrix wsproxy syncproxy needs a restart + ansible.builtin.set_fact: + matrix_mautrix_wsproxy_syncproxy_restart_necessary: >- + {{ + matrix_mautrix_wsproxy_syncproxy_migration_requires_restart | default(false) + or matrix_mautrix_wsproxy_syncproxy_systemd_service_result.changed | default(false) + or matrix_mautrix_wsproxy_syncproxy_container_image_pull_result.changed | default(false) + }} + - name: Ensure systemd reloaded after matrix-mautrix-wsproxy-syncproxy.service installation ansible.builtin.service: daemon_reload: true diff --git a/roles/custom/matrix-cactus-comments-client/defaults/main.yml b/roles/custom/matrix-cactus-comments-client/defaults/main.yml index 5b647575d..3a684bb5e 100644 --- a/roles/custom/matrix-cactus-comments-client/defaults/main.yml +++ b/roles/custom/matrix-cactus-comments-client/defaults/main.yml @@ -108,3 +108,13 @@ matrix_cactus_comments_client_systemd_required_services_list: "{{ [devture_syste matrix_cactus_comments_client_systemd_wanted_services_list: "{{ matrix_cactus_comments_client_systemd_wanted_services_list_auto + matrix_cactus_comments_client_systemd_wanted_services_list_custom }}" matrix_cactus_comments_client_systemd_wanted_services_list_auto: [] matrix_cactus_comments_client_systemd_wanted_services_list_custom: [] + +# matrix_cactus_comments_client_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). +# +# This value is automatically computed during installation based on whether +# 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_cactus_comments_client_restart_necessary: false diff --git a/roles/custom/matrix-cactus-comments-client/tasks/install.yml b/roles/custom/matrix-cactus-comments-client/tasks/install.yml index f068fa8d3..3cb0c992b 100644 --- a/roles/custom/matrix-cactus-comments-client/tasks/install.yml +++ b/roles/custom/matrix-cactus-comments-client/tasks/install.yml @@ -30,6 +30,7 @@ - src: "{{ role_path }}/templates/labels.j2" dest: "{{ matrix_cactus_comments_client_base_path }}/labels" + register: matrix_cactus_comments_client_support_files_result - when: matrix_cactus_comments_client_local_dir | length == 0 block: @@ -71,10 +72,10 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_cactus_comments_client_container_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_cactus_comments_client_container_image_force_pull }}" - register: result + register: matrix_cactus_comments_client_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_cactus_comments_client_container_image_pull_result is not failed - name: Ensure matrix-cactus-comments-client container network is created community.general.docker_network: @@ -88,3 +89,13 @@ src: "{{ role_path }}/templates/systemd/matrix-cactus-comments-client.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-cactus-comments-client.service" mode: 0644 + register: matrix_cactus_comments_client_systemd_service_result + +- name: Determine whether matrix-cactus-comments-client needs a restart + ansible.builtin.set_fact: + matrix_cactus_comments_client_restart_necessary: >- + {{ + matrix_cactus_comments_client_support_files_result.changed | default(false) + or matrix_cactus_comments_client_systemd_service_result.changed | default(false) + or matrix_cactus_comments_client_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-cactus-comments/defaults/main.yml b/roles/custom/matrix-cactus-comments/defaults/main.yml index 6189f9faf..f8d4d2854 100644 --- a/roles/custom/matrix-cactus-comments/defaults/main.yml +++ b/roles/custom/matrix-cactus-comments/defaults/main.yml @@ -56,3 +56,13 @@ matrix_cactus_comments_systemd_required_services_list: "{{ [devture_systemd_dock matrix_cactus_comments_systemd_wanted_services_list: [] matrix_cactus_comments_environment_variables_extension: '' + +# matrix_cactus_comments_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). +# +# This value is automatically computed during installation based on whether +# 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_cactus_comments_restart_necessary: false diff --git a/roles/custom/matrix-cactus-comments/tasks/setup_install.yml b/roles/custom/matrix-cactus-comments/tasks/setup_install.yml index f68b6dff2..33f3d674e 100644 --- a/roles/custom/matrix-cactus-comments/tasks/setup_install.yml +++ b/roles/custom/matrix-cactus-comments/tasks/setup_install.yml @@ -26,6 +26,7 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" mode: 0640 + register: matrix_cactus_comments_config_env_result - name: Ensure matrix-cactus-comments appservice file created ansible.builtin.template: @@ -34,6 +35,7 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" mode: 0640 + register: matrix_cactus_comments_config_appservice_result - name: Ensure matrix-cactus-comments image is pulled community.docker.docker_image: @@ -42,10 +44,10 @@ force_source: "{{ matrix_cactus_comments_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_cactus_comments_docker_image_force_pull }}" when: "not matrix_cactus_comments_container_image_self_build | bool" - register: result + register: matrix_cactus_comments_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_cactus_comments_container_image_pull_result is not failed - name: Ensure matrix-cactus-comments repository is present on self-build ansible.builtin.git: @@ -75,3 +77,14 @@ src: "{{ role_path }}/templates/systemd/matrix-cactus-comments.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-cactus-comments.service" mode: 0644 + register: matrix_cactus_comments_systemd_service_result + +- name: Determine whether matrix-cactus-comments needs a restart + ansible.builtin.set_fact: + matrix_cactus_comments_restart_necessary: >- + {{ + matrix_cactus_comments_config_env_result.changed | default(false) + or matrix_cactus_comments_config_appservice_result.changed | default(false) + or matrix_cactus_comments_systemd_service_result.changed | default(false) + or matrix_cactus_comments_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-corporal/defaults/main.yml b/roles/custom/matrix-corporal/defaults/main.yml index 392c1b4c2..6449099e5 100644 --- a/roles/custom/matrix-corporal/defaults/main.yml +++ b/roles/custom/matrix-corporal/defaults/main.yml @@ -180,3 +180,13 @@ matrix_corporal_configuration: "{{ matrix_corporal_configuration_default | combi matrix_corporal_self_check_matrix_client_api_url_endpoint_public: "{{ matrix_corporal_matrix_homeserver_scheme }}://{{ matrix_corporal_matrix_homeserver_api_domain_name }}/_matrix/client/corporal" matrix_corporal_self_check_corporal_api_url_endpoint_public: "{{ matrix_corporal_matrix_homeserver_scheme }}://{{ matrix_corporal_matrix_homeserver_api_domain_name }}/_matrix/corporal/policy" + +# matrix_corporal_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). +# +# This value is automatically computed during installation based on whether +# 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_corporal_restart_necessary: false diff --git a/roles/custom/matrix-corporal/tasks/setup_install.yml b/roles/custom/matrix-corporal/tasks/setup_install.yml index e79fa4c00..f96d721fe 100644 --- a/roles/custom/matrix-corporal/tasks/setup_install.yml +++ b/roles/custom/matrix-corporal/tasks/setup_install.yml @@ -54,10 +54,10 @@ force_source: "{{ matrix_corporal_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_corporal_docker_image_force_pull }}" when: not matrix_corporal_container_image_self_build | bool - register: result + register: matrix_corporal_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_corporal_container_image_pull_result is not failed - name: Ensure Matrix Corporal config installed ansible.builtin.copy: @@ -66,6 +66,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_corporal_config_result - name: Ensure Matrix Corporal support files installed ansible.builtin.template: @@ -76,6 +77,7 @@ group: "{{ matrix_group_name }}" with_items: - labels + register: matrix_corporal_support_files_result - name: Ensure Matrix Corporal container network is created community.general.docker_network: @@ -90,3 +92,13 @@ dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-corporal.service" mode: 0644 register: matrix_corporal_systemd_service_result + +- name: Determine whether matrix-corporal needs a restart + ansible.builtin.set_fact: + matrix_corporal_restart_necessary: >- + {{ + matrix_corporal_config_result.changed | default(false) + or matrix_corporal_support_files_result.changed | default(false) + or matrix_corporal_systemd_service_result.changed | default(false) + or matrix_corporal_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-element-admin/defaults/main.yml b/roles/custom/matrix-element-admin/defaults/main.yml index 930b83a19..44a697dbf 100644 --- a/roles/custom/matrix-element-admin/defaults/main.yml +++ b/roles/custom/matrix-element-admin/defaults/main.yml @@ -95,3 +95,13 @@ matrix_element_admin_environment_variable_server_name: "{{ matrix_domain }}" # SOMETHING=1 # ANOTHER="here" matrix_element_admin_environment_variables_additional_variables: '' + +# matrix_element_admin_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). +# +# This value is automatically computed during installation based on whether +# 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_element_admin_restart_necessary: false diff --git a/roles/custom/matrix-element-admin/tasks/install.yml b/roles/custom/matrix-element-admin/tasks/install.yml index d26973111..01ce38db1 100644 --- a/roles/custom/matrix-element-admin/tasks/install.yml +++ b/roles/custom/matrix-element-admin/tasks/install.yml @@ -29,6 +29,7 @@ with_items: - labels - env + register: matrix_element_admin_support_files_result - name: Ensure Element Admin container image is pulled community.docker.docker_image: @@ -37,10 +38,10 @@ force_source: "{{ matrix_element_admin_container_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_element_admin_container_image_force_pull }}" when: "not matrix_element_admin_container_image_self_build | bool" - register: result + register: matrix_element_admin_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_element_admin_container_image_pull_result is not failed - when: matrix_element_admin_container_image_self_build | bool block: @@ -75,3 +76,13 @@ src: "{{ role_path }}/templates/systemd/matrix-element-admin.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-element-admin.service" mode: 0644 + register: matrix_element_admin_systemd_service_result + +- name: Determine whether Element Admin needs a restart + ansible.builtin.set_fact: + matrix_element_admin_restart_necessary: >- + {{ + matrix_element_admin_support_files_result.changed | default(false) + or matrix_element_admin_systemd_service_result.changed | default(false) + or matrix_element_admin_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-ldap-registration-proxy/defaults/main.yml b/roles/custom/matrix-ldap-registration-proxy/defaults/main.yml index 4ff410860..50cb28d60 100644 --- a/roles/custom/matrix-ldap-registration-proxy/defaults/main.yml +++ b/roles/custom/matrix-ldap-registration-proxy/defaults/main.yml @@ -100,3 +100,13 @@ matrix_ldap_registration_proxy_systemd_wanted_services_list_custom: [] # matrix_ldap_registration_proxy_env_variables_extension: | # KEY=value matrix_ldap_registration_proxy_env_variables_extension: '' + +# matrix_ldap_registration_proxy_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). +# +# This value is automatically computed during installation based on whether +# 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_ldap_registration_proxy_restart_necessary: false diff --git a/roles/custom/matrix-ldap-registration-proxy/tasks/setup_install.yml b/roles/custom/matrix-ldap-registration-proxy/tasks/setup_install.yml index fbafc5497..ad6fbdd46 100644 --- a/roles/custom/matrix-ldap-registration-proxy/tasks/setup_install.yml +++ b/roles/custom/matrix-ldap-registration-proxy/tasks/setup_install.yml @@ -48,6 +48,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_ldap_registration_proxy_config_result - name: Ensure matrix-ldap-registration-proxy support files installed ansible.builtin.template: @@ -58,6 +59,7 @@ group: "{{ matrix_group_name }}" with_items: - labels + register: matrix_ldap_registration_proxy_support_files_result - name: Ensure matrix-ldap-registration-proxy container network is created community.general.docker_network: @@ -71,3 +73,13 @@ src: "{{ role_path }}/templates/systemd/matrix-ldap-registration-proxy.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-ldap-registration-proxy.service" mode: 0644 + register: matrix_ldap_registration_proxy_systemd_service_result + +- name: Determine whether matrix-ldap-registration-proxy needs a restart + ansible.builtin.set_fact: + matrix_ldap_registration_proxy_restart_necessary: >- + {{ + matrix_ldap_registration_proxy_config_result.changed | default(false) + or matrix_ldap_registration_proxy_support_files_result.changed | default(false) + or matrix_ldap_registration_proxy_systemd_service_result.changed | default(false) + }} diff --git a/roles/custom/matrix-livekit-jwt-service/defaults/main.yml b/roles/custom/matrix-livekit-jwt-service/defaults/main.yml index 52eb7517c..6549653de 100644 --- a/roles/custom/matrix-livekit-jwt-service/defaults/main.yml +++ b/roles/custom/matrix-livekit-jwt-service/defaults/main.yml @@ -108,3 +108,13 @@ matrix_livekit_jwt_service_systemd_required_services_list: "{{ matrix_livekit_jw matrix_livekit_jwt_service_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}" matrix_livekit_jwt_service_systemd_required_services_list_auto: [] matrix_livekit_jwt_service_systemd_required_services_list_custom: [] + +# matrix_livekit_jwt_service_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). +# +# This value is automatically computed during installation based on whether +# 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_livekit_jwt_service_restart_necessary: false diff --git a/roles/custom/matrix-livekit-jwt-service/tasks/install.yml b/roles/custom/matrix-livekit-jwt-service/tasks/install.yml index 9736e2c55..406ca7c4a 100644 --- a/roles/custom/matrix-livekit-jwt-service/tasks/install.yml +++ b/roles/custom/matrix-livekit-jwt-service/tasks/install.yml @@ -26,6 +26,7 @@ with_items: - env - labels + register: matrix_livekit_jwt_service_support_files_result - name: Ensure LiveKit JWT Service container image is pulled community.docker.docker_image: @@ -34,10 +35,10 @@ force_source: "{{ matrix_livekit_jwt_service_container_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_livekit_jwt_service_container_image_force_pull }}" when: "not matrix_livekit_jwt_service_container_image_self_build | bool" - register: result + register: matrix_livekit_jwt_service_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_livekit_jwt_service_container_image_pull_result is not failed - when: "matrix_livekit_jwt_service_container_image_self_build | bool" block: @@ -74,3 +75,13 @@ src: "{{ role_path }}/templates/systemd/matrix-livekit-jwt-service.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-livekit-jwt-service.service" mode: 0644 + register: matrix_livekit_jwt_service_systemd_service_result + +- name: Determine whether LiveKit JWT Service needs a restart + ansible.builtin.set_fact: + matrix_livekit_jwt_service_restart_necessary: >- + {{ + matrix_livekit_jwt_service_support_files_result.changed | default(false) + or matrix_livekit_jwt_service_systemd_service_result.changed | default(false) + or matrix_livekit_jwt_service_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-matrixto/defaults/main.yml b/roles/custom/matrix-matrixto/defaults/main.yml index be9762482..838b5e929 100644 --- a/roles/custom/matrix-matrixto/defaults/main.yml +++ b/roles/custom/matrix-matrixto/defaults/main.yml @@ -170,3 +170,13 @@ matrix_matrixto_systemd_wanted_services_list_custom: [] # Additional environment variables. matrix_matrixto_environment_variables_additional_variables: "" + +# matrix_matrixto_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). +# +# This value is automatically computed during installation based on whether +# 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_matrixto_restart_necessary: false diff --git a/roles/custom/matrix-matrixto/tasks/install.yml b/roles/custom/matrix-matrixto/tasks/install.yml index e4cc0f4f5..29232440e 100644 --- a/roles/custom/matrix-matrixto/tasks/install.yml +++ b/roles/custom/matrix-matrixto/tasks/install.yml @@ -24,6 +24,7 @@ with_items: - env - labels + register: matrix_matrixto_support_files_result - name: Ensure Matrix.to repository is present on self-build ansible.builtin.git: @@ -70,3 +71,12 @@ src: "{{ role_path }}/templates/systemd/matrix-matrixto.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_matrixto_identifier }}.service" mode: "0644" + register: matrix_matrixto_systemd_service_result + +- name: Determine whether Matrix.to needs a restart + ansible.builtin.set_fact: + matrix_matrixto_restart_necessary: >- + {{ + matrix_matrixto_support_files_result.changed | default(false) + or matrix_matrixto_systemd_service_result.changed | default(false) + }} diff --git a/roles/custom/matrix-pantalaimon/defaults/main.yml b/roles/custom/matrix-pantalaimon/defaults/main.yml index 1302c60f7..697773e2a 100644 --- a/roles/custom/matrix-pantalaimon/defaults/main.yml +++ b/roles/custom/matrix-pantalaimon/defaults/main.yml @@ -62,3 +62,13 @@ matrix_pantalaimon_homeserver_url: "" # For a more advanced customization, you can # completely replace this variable with your own template. matrix_pantalaimon_configuration: "{{ lookup('template', 'templates/pantalaimon.conf.j2') }}" + +# matrix_pantalaimon_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). +# +# This value is automatically computed during installation based on whether +# 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_pantalaimon_restart_necessary: false diff --git a/roles/custom/matrix-pantalaimon/tasks/install.yml b/roles/custom/matrix-pantalaimon/tasks/install.yml index 610dce0b0..d2f1867bc 100644 --- a/roles/custom/matrix-pantalaimon/tasks/install.yml +++ b/roles/custom/matrix-pantalaimon/tasks/install.yml @@ -25,6 +25,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_pantalaimon_config_result - name: Ensure pantalaimon container image is pulled community.docker.docker_image: @@ -33,10 +34,10 @@ force_source: "{{ matrix_pantalaimon_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_pantalaimon_docker_image_force_pull }}" when: "not matrix_pantalaimon_container_image_self_build | bool" - register: result + register: matrix_pantalaimon_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_pantalaimon_container_image_pull_result is not failed - name: Ensure pantalaimon repository is present on self-build ansible.builtin.git: @@ -72,3 +73,13 @@ src: "{{ role_path }}/templates/systemd/matrix-pantalaimon.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-pantalaimon.service" mode: 0644 + register: matrix_pantalaimon_systemd_service_result + +- name: Determine whether Pantalaimon needs a restart + ansible.builtin.set_fact: + matrix_pantalaimon_restart_necessary: >- + {{ + matrix_pantalaimon_config_result.changed | default(false) + or matrix_pantalaimon_systemd_service_result.changed | default(false) + or matrix_pantalaimon_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-prometheus-nginxlog-exporter/defaults/main.yml b/roles/custom/matrix-prometheus-nginxlog-exporter/defaults/main.yml index 3cbed7a22..636516f60 100644 --- a/roles/custom/matrix-prometheus-nginxlog-exporter/defaults/main.yml +++ b/roles/custom/matrix-prometheus-nginxlog-exporter/defaults/main.yml @@ -102,3 +102,13 @@ matrix_prometheus_nginxlog_exporter_container_syslog_host_bind_port: '' matrix_prometheus_nginxlog_exporter_config_namespaces_matrix_source_tags: "{{ matrix_prometheus_nginxlog_exporter_config_namespaces_matrix_source_tags_auto + matrix_prometheus_nginxlog_exporter_config_namespaces_matrix_source_tags_custom }}" matrix_prometheus_nginxlog_exporter_config_namespaces_matrix_source_tags_auto: [] matrix_prometheus_nginxlog_exporter_config_namespaces_matrix_source_tags_custom: [] + +# matrix_prometheus_nginxlog_exporter_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). +# +# This value is automatically computed during installation based on whether +# 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_prometheus_nginxlog_exporter_restart_necessary: false diff --git a/roles/custom/matrix-prometheus-nginxlog-exporter/tasks/setup_install.yml b/roles/custom/matrix-prometheus-nginxlog-exporter/tasks/setup_install.yml index 42591b383..c4266f300 100644 --- a/roles/custom/matrix-prometheus-nginxlog-exporter/tasks/setup_install.yml +++ b/roles/custom/matrix-prometheus-nginxlog-exporter/tasks/setup_install.yml @@ -12,10 +12,10 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_prometheus_nginxlog_exporter_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_prometheus_nginxlog_exporter_docker_image_force_pull }}" - register: result + register: matrix_prometheus_nginxlog_exporter_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_prometheus_nginxlog_exporter_container_image_pull_result is not failed - name: Ensure prometheus-nginxlog-exporter paths exists ansible.builtin.file: @@ -35,6 +35,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_prometheus_nginxlog_exporter_config_result - name: Ensure prometheus-nginxlog-exporter support files installed ansible.builtin.template: @@ -45,6 +46,7 @@ group: "{{ matrix_group_name }}" with_items: - labels + register: matrix_prometheus_nginxlog_exporter_support_files_result - name: Ensure prometheus-nginxlog-exporter container network is created community.general.docker_network: @@ -58,3 +60,14 @@ src: "{{ role_path }}/templates/systemd/matrix-prometheus-nginxlog-exporter.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-prometheus-nginxlog-exporter.service" mode: 0644 + register: matrix_prometheus_nginxlog_exporter_systemd_service_result + +- name: Determine whether matrix-prometheus-nginxlog-exporter needs a restart + ansible.builtin.set_fact: + matrix_prometheus_nginxlog_exporter_restart_necessary: >- + {{ + matrix_prometheus_nginxlog_exporter_config_result.changed | default(false) + or matrix_prometheus_nginxlog_exporter_support_files_result.changed | default(false) + or matrix_prometheus_nginxlog_exporter_systemd_service_result.changed | default(false) + or matrix_prometheus_nginxlog_exporter_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-rageshake/defaults/main.yml b/roles/custom/matrix-rageshake/defaults/main.yml index 75a97fa24..308f4d875 100644 --- a/roles/custom/matrix-rageshake/defaults/main.yml +++ b/roles/custom/matrix-rageshake/defaults/main.yml @@ -122,3 +122,13 @@ matrix_rageshake_configuration_extension: "{{ matrix_rageshake_configuration_ext # Holds the final Synapse configuration (a combination of the default and its extension). # You most likely don't need to touch this variable. Instead, see `matrix_rageshake_configuration_yaml`. matrix_rageshake_configuration: "{{ matrix_rageshake_configuration_yaml | from_yaml | combine(matrix_rageshake_configuration_extension, recursive=True) }}" + +# matrix_rageshake_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). +# +# This value is automatically computed during installation based on whether +# 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_rageshake_restart_necessary: false diff --git a/roles/custom/matrix-rageshake/tasks/install.yml b/roles/custom/matrix-rageshake/tasks/install.yml index 0b64aa577..152c47504 100644 --- a/roles/custom/matrix-rageshake/tasks/install.yml +++ b/roles/custom/matrix-rageshake/tasks/install.yml @@ -30,6 +30,7 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" mode: 0640 + register: matrix_rageshake_config_result - name: Ensure rageshake labels installed ansible.builtin.template: @@ -38,6 +39,7 @@ mode: 0640 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_rageshake_support_files_result - name: Ensure rageshake image is pulled community.docker.docker_image: @@ -46,10 +48,10 @@ force_source: "{{ matrix_rageshake_container_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_rageshake_container_image_force_pull }}" when: "not matrix_rageshake_container_image_self_build | bool" - register: result + register: matrix_rageshake_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_rageshake_container_image_pull_result is not failed - name: Ensure rageshake repository is present on self-build ansible.builtin.git: @@ -84,3 +86,14 @@ src: "{{ role_path }}/templates/systemd/matrix-rageshake.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-rageshake.service" mode: 0644 + register: matrix_rageshake_systemd_service_result + +- name: Determine whether Rageshake needs a restart + ansible.builtin.set_fact: + matrix_rageshake_restart_necessary: >- + {{ + matrix_rageshake_config_result.changed | default(false) + or matrix_rageshake_support_files_result.changed | default(false) + or matrix_rageshake_systemd_service_result.changed | default(false) + or matrix_rageshake_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-registration/defaults/main.yml b/roles/custom/matrix-registration/defaults/main.yml index 40b840f84..143ce67f3 100644 --- a/roles/custom/matrix-registration/defaults/main.yml +++ b/roles/custom/matrix-registration/defaults/main.yml @@ -167,3 +167,13 @@ matrix_registration_configuration_extension: "{{ matrix_registration_configurati # Holds the final matrix-registration configuration (a combination of the default and its extension). # You most likely don't need to touch this variable. Instead, see `matrix_registration_configuration_yaml`. matrix_registration_configuration: "{{ matrix_registration_configuration_yaml | from_yaml | combine(matrix_registration_configuration_extension, recursive=True) }}" + +# matrix_registration_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). +# +# This value is automatically computed during installation based on whether +# 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_registration_restart_necessary: false diff --git a/roles/custom/matrix-registration/tasks/setup_install.yml b/roles/custom/matrix-registration/tasks/setup_install.yml index 3559c97ab..8965bee1f 100644 --- a/roles/custom/matrix-registration/tasks/setup_install.yml +++ b/roles/custom/matrix-registration/tasks/setup_install.yml @@ -63,10 +63,10 @@ force_source: "{{ matrix_registration_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_registration_docker_image_force_pull }}" when: "not matrix_registration_container_image_self_build | bool" - register: result + register: matrix_registration_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_registration_container_image_pull_result is not failed - name: Ensure matrix-registration repository is present when self-building ansible.builtin.git: @@ -106,6 +106,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_registration_config_result - name: Ensure matrix-registration support files installed ansible.builtin.template: @@ -116,6 +117,7 @@ group: "{{ matrix_group_name }}" with_items: - labels + register: matrix_registration_support_files_result - name: Ensure matrix-registration container network is created community.general.docker_network: @@ -129,6 +131,18 @@ src: "{{ role_path }}/templates/systemd/matrix-registration.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-registration.service" mode: 0644 + register: matrix_registration_systemd_service_result + +- name: Determine whether matrix-registration needs a restart + ansible.builtin.set_fact: + matrix_registration_restart_necessary: >- + {{ + matrix_registration_migration_requires_restart | default(false) + or matrix_registration_config_result.changed | default(false) + or matrix_registration_support_files_result.changed | default(false) + or matrix_registration_systemd_service_result.changed | default(false) + or matrix_registration_container_image_pull_result.changed | default(false) + }} - name: Ensure matrix-registration.service restarted, if necessary ansible.builtin.service: diff --git a/roles/custom/matrix-static-files/defaults/main.yml b/roles/custom/matrix-static-files/defaults/main.yml index a247294f6..5694609ed 100644 --- a/roles/custom/matrix-static-files/defaults/main.yml +++ b/roles/custom/matrix-static-files/defaults/main.yml @@ -404,3 +404,13 @@ matrix_static_files_self_check_hostname_identity: '' # As per the spec (https://matrix.org/docs/spec/client_server/r0.6.0#well-known-uri), it shouldn't be, # so we default to not following redirects as well. matrix_static_files_self_check_well_known_matrix_client_follow_redirects: none + +# matrix_static_files_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). +# +# This value is automatically computed during installation based on whether +# 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_static_files_restart_necessary: false diff --git a/roles/custom/matrix-static-files/tasks/install.yml b/roles/custom/matrix-static-files/tasks/install.yml index b60c45daf..c2c0b8b03 100644 --- a/roles/custom/matrix-static-files/tasks/install.yml +++ b/roles/custom/matrix-static-files/tasks/install.yml @@ -42,6 +42,7 @@ - src: "{{ role_path }}/templates/labels.j2" dest: "{{ matrix_static_files_base_path }}/labels" + register: matrix_static_files_config_result - name: Ensure matrix-static-files files are installed ansible.builtin.copy: @@ -69,6 +70,7 @@ - content: "{{ matrix_static_files_file_index_html_template }}" dest: "{{ matrix_static_files_public_path }}/index.html" when: "{{ matrix_static_files_file_index_html_enabled }}" + register: matrix_static_files_files_result - name: Ensure /.well-known/matrix/server file deleted if not enabled ansible.builtin.file: @@ -88,10 +90,10 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_static_files_container_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_static_files_container_image_force_pull }}" - register: result + register: matrix_static_files_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_static_files_container_image_pull_result is not failed - name: Ensure matrix-static-files container network is created community.general.docker_network: @@ -105,3 +107,14 @@ src: "{{ role_path }}/templates/systemd/matrix-static-files.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_static_files_identifier }}.service" mode: 0644 + register: matrix_static_files_systemd_service_result + +- name: Determine whether matrix-static-files needs a restart + ansible.builtin.set_fact: + matrix_static_files_restart_necessary: >- + {{ + matrix_static_files_config_result.changed | default(false) + or matrix_static_files_files_result.changed | default(false) + or matrix_static_files_systemd_service_result.changed | default(false) + or matrix_static_files_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-sygnal/defaults/main.yml b/roles/custom/matrix-sygnal/defaults/main.yml index 540dece4e..4422c23b3 100644 --- a/roles/custom/matrix-sygnal/defaults/main.yml +++ b/roles/custom/matrix-sygnal/defaults/main.yml @@ -135,3 +135,13 @@ matrix_sygnal_configuration_extension: "{{ matrix_sygnal_configuration_extension # Holds the final sygnal configuration (a combination of the default and its extension). # You most likely don't need to touch this variable. Instead, see `matrix_sygnal_configuration_yaml`. matrix_sygnal_configuration: "{{ matrix_sygnal_configuration_yaml | from_yaml | combine(matrix_sygnal_configuration_extension, recursive=True) }}" + +# matrix_sygnal_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). +# +# This value is automatically computed during installation based on whether +# 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_sygnal_restart_necessary: false diff --git a/roles/custom/matrix-sygnal/tasks/install.yml b/roles/custom/matrix-sygnal/tasks/install.yml index 30ea8da1e..94061f201 100644 --- a/roles/custom/matrix-sygnal/tasks/install.yml +++ b/roles/custom/matrix-sygnal/tasks/install.yml @@ -28,6 +28,7 @@ mode: 0640 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_sygnal_config_result - name: Ensure Sygnal labels installed ansible.builtin.template: @@ -36,6 +37,7 @@ mode: 0640 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_sygnal_support_files_result - name: Ensure Sygnal image is pulled community.docker.docker_image: @@ -43,10 +45,10 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_sygnal_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_sygnal_docker_image_force_pull }}" - register: result + register: matrix_sygnal_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_sygnal_container_image_pull_result is not failed - name: Ensure Sygnal container network is created community.general.docker_network: @@ -60,3 +62,14 @@ src: "{{ role_path }}/templates/systemd/matrix-sygnal.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-sygnal.service" mode: 0644 + register: matrix_sygnal_systemd_service_result + +- name: Determine whether Sygnal needs a restart + ansible.builtin.set_fact: + matrix_sygnal_restart_necessary: >- + {{ + matrix_sygnal_config_result.changed | default(false) + or matrix_sygnal_support_files_result.changed | default(false) + or matrix_sygnal_systemd_service_result.changed | default(false) + or matrix_sygnal_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-synapse-admin/defaults/main.yml b/roles/custom/matrix-synapse-admin/defaults/main.yml index e03fdf92a..418112ccb 100644 --- a/roles/custom/matrix-synapse-admin/defaults/main.yml +++ b/roles/custom/matrix-synapse-admin/defaults/main.yml @@ -248,3 +248,13 @@ matrix_synapse_admin_config_asManagedUsers_custom: [] # noqa var-naming # Example for mautrix-telegram: ["^@telegram_[a-zA-Z0-9]+:example\\.com$"] # WARNING: you want to use matrix_synapse_admin_config_asManagedUsers_custom instead of this variable. matrix_synapse_admin_config_asManagedUsers: "{{ matrix_synapse_admin_config_asManagedUsers_auto + matrix_synapse_admin_config_asManagedUsers_custom }}" # noqa var-naming + +# matrix_synapse_admin_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). +# +# This value is automatically computed during installation based on whether +# 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_synapse_admin_restart_necessary: false diff --git a/roles/custom/matrix-synapse-admin/tasks/setup_install.yml b/roles/custom/matrix-synapse-admin/tasks/setup_install.yml index baf76b29d..0a8675845 100644 --- a/roles/custom/matrix-synapse-admin/tasks/setup_install.yml +++ b/roles/custom/matrix-synapse-admin/tasks/setup_install.yml @@ -31,6 +31,7 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" mode: 0640 + register: matrix_synapse_admin_support_files_result - name: Ensure matrix-synapse-admin configuration installed ansible.builtin.copy: @@ -39,6 +40,7 @@ mode: 0644 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_synapse_admin_config_result - name: Ensure matrix-synapse-admin image is pulled community.docker.docker_image: @@ -47,10 +49,10 @@ force_source: "{{ matrix_synapse_admin_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_synapse_admin_docker_image_force_pull }}" when: not matrix_synapse_admin_container_image_self_build | bool - register: result + register: matrix_synapse_admin_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_synapse_admin_container_image_pull_result is not failed - name: Ensure matrix-synapse-admin repository is present when self-building ansible.builtin.git: @@ -87,3 +89,14 @@ src: "{{ role_path }}/templates/systemd/matrix-synapse-admin.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-admin.service" mode: 0644 + register: matrix_synapse_admin_systemd_service_result + +- name: Determine whether Synapse Admin needs a restart + ansible.builtin.set_fact: + matrix_synapse_admin_restart_necessary: >- + {{ + matrix_synapse_admin_support_files_result.changed | default(false) + or matrix_synapse_admin_config_result.changed | default(false) + or matrix_synapse_admin_systemd_service_result.changed | default(false) + or matrix_synapse_admin_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml b/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml index f49a3301e..bb24afd4b 100644 --- a/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml +++ b/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml @@ -87,3 +87,13 @@ matrix_synapse_auto_compressor_command: "synapse_auto_compressor -p $POSTGRES_LO # Controls the POSTGRES_LOCATION environment variable matrix_synapse_auto_compressor_environment_variable_postgres_location: "{{ matrix_synapse_auto_compressor_synapse_database }}" + +# matrix_synapse_auto_compressor_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). +# +# This value is automatically computed during installation based on whether +# 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_synapse_auto_compressor_restart_necessary: false diff --git a/roles/custom/matrix-synapse-auto-compressor/tasks/install.yml b/roles/custom/matrix-synapse-auto-compressor/tasks/install.yml index cad13533a..2dec39609 100644 --- a/roles/custom/matrix-synapse-auto-compressor/tasks/install.yml +++ b/roles/custom/matrix-synapse-auto-compressor/tasks/install.yml @@ -27,6 +27,7 @@ mode: 0640 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_synapse_auto_compressor_config_env_result - name: Ensure synapse-auto-compressor workaround script is installed ansible.builtin.template: @@ -35,6 +36,7 @@ mode: 0750 owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" + register: matrix_synapse_auto_compressor_config_script_result - name: Ensure synapse-auto-compressor image is pulled community.docker.docker_image: @@ -43,10 +45,10 @@ force_source: "{{ matrix_synapse_auto_compressor_container_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_synapse_auto_compressor_container_image_force_pull }}" when: "not matrix_synapse_auto_compressor_container_image_self_build | bool" - register: result + register: matrix_synapse_auto_compressor_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_synapse_auto_compressor_container_image_pull_result is not failed - when: "matrix_synapse_auto_compressor_container_image_self_build | bool" @@ -97,3 +99,14 @@ with_items: - service - timer + register: matrix_synapse_auto_compressor_systemd_service_result + +- name: Determine whether synapse-auto-compressor needs a restart + ansible.builtin.set_fact: + matrix_synapse_auto_compressor_restart_necessary: >- + {{ + matrix_synapse_auto_compressor_config_env_result.changed | default(false) + or matrix_synapse_auto_compressor_config_script_result.changed | default(false) + or matrix_synapse_auto_compressor_systemd_service_result.changed | default(false) + or matrix_synapse_auto_compressor_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-synapse-reverse-proxy-companion/defaults/main.yml b/roles/custom/matrix-synapse-reverse-proxy-companion/defaults/main.yml index decb536d2..fc20a5415 100644 --- a/roles/custom/matrix-synapse-reverse-proxy-companion/defaults/main.yml +++ b/roles/custom/matrix-synapse-reverse-proxy-companion/defaults/main.yml @@ -361,3 +361,13 @@ matrix_synapse_reverse_proxy_companion_whoami_sync_worker_router_debug_headers_e # /Whoami-based sync worker routing # # # ######################################################################################## + +# matrix_synapse_reverse_proxy_companion_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). +# +# This value is automatically computed during installation based on whether +# 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_synapse_reverse_proxy_companion_restart_necessary: false diff --git a/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/setup_install.yml b/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/setup_install.yml index c093691b3..a51e67832 100644 --- a/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/setup_install.yml +++ b/roles/custom/matrix-synapse-reverse-proxy-companion/tasks/setup_install.yml @@ -34,6 +34,7 @@ dest: "{{ matrix_synapse_reverse_proxy_companion_confd_path }}/matrix-synapse-reverse-proxy-companion.conf" - src: "{{ role_path }}/templates/labels.j2" dest: "{{ matrix_synapse_reverse_proxy_companion_base_path }}/labels" + register: matrix_synapse_reverse_proxy_companion_config_result - name: Ensure matrix-synapse-reverse-proxy-companion whoami sync worker router njs script is deployed ansible.builtin.template: @@ -56,10 +57,10 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_synapse_reverse_proxy_companion_container_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_synapse_reverse_proxy_companion_container_image_force_pull }}" - register: result + register: matrix_synapse_reverse_proxy_companion_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_synapse_reverse_proxy_companion_container_image_pull_result is not failed - name: Ensure matrix-synapse-reverse-proxy-companion container network is created community.general.docker_network: @@ -73,3 +74,13 @@ src: "{{ role_path }}/templates/systemd/matrix-synapse-reverse-proxy-companion.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-reverse-proxy-companion.service" mode: 0644 + register: matrix_synapse_reverse_proxy_companion_systemd_service_result + +- name: Determine whether Synapse reverse-proxy companion needs a restart + ansible.builtin.set_fact: + matrix_synapse_reverse_proxy_companion_restart_necessary: >- + {{ + matrix_synapse_reverse_proxy_companion_config_result.changed | default(false) + or matrix_synapse_reverse_proxy_companion_systemd_service_result.changed | default(false) + or matrix_synapse_reverse_proxy_companion_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-synapse-usage-exporter/defaults/main.yml b/roles/custom/matrix-synapse-usage-exporter/defaults/main.yml index b4256d3bc..464676afe 100644 --- a/roles/custom/matrix-synapse-usage-exporter/defaults/main.yml +++ b/roles/custom/matrix-synapse-usage-exporter/defaults/main.yml @@ -90,3 +90,13 @@ matrix_synapse_usage_exporter_container_labels_additional_labels: '' # If the Grafana role is enabled, these dashboards will be downloaded. matrix_synapse_usage_exporter_dashboard_urls: - https://raw.githubusercontent.com/spantaleev/matrix-docker-ansible-deploy/master/roles/custom/matrix-synapse-usage-exporter/templates/grafana/synapse-usage-exporter.json + +# matrix_synapse_usage_exporter_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). +# +# This value is automatically computed during installation based on whether +# 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_synapse_usage_exporter_restart_necessary: false diff --git a/roles/custom/matrix-synapse-usage-exporter/tasks/setup_install.yml b/roles/custom/matrix-synapse-usage-exporter/tasks/setup_install.yml index 993c6975b..cf8ae0939 100644 --- a/roles/custom/matrix-synapse-usage-exporter/tasks/setup_install.yml +++ b/roles/custom/matrix-synapse-usage-exporter/tasks/setup_install.yml @@ -29,6 +29,7 @@ with_items: - env - labels + register: matrix_synapse_usage_exporter_support_files_result - name: Ensure synapse-usage-exporter Docker image is pulled community.docker.docker_image: @@ -37,10 +38,10 @@ force_source: "{{ matrix_synapse_usage_exporter_container_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_synapse_usage_exporter_container_image_force_pull }}" when: "not matrix_synapse_usage_exporter_container_image_self_build | bool" - register: result + register: matrix_synapse_usage_exporter_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_synapse_usage_exporter_container_image_pull_result is not failed - when: "matrix_synapse_usage_exporter_container_image_self_build | bool" block: @@ -81,3 +82,13 @@ src: "{{ role_path }}/templates/systemd/matrix-synapse-usage-exporter.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_synapse_usage_exporter_identifier }}.service" mode: 0640 + register: matrix_synapse_usage_exporter_systemd_service_result + +- name: Determine whether synapse-usage-exporter needs a restart + ansible.builtin.set_fact: + matrix_synapse_usage_exporter_restart_necessary: >- + {{ + matrix_synapse_usage_exporter_support_files_result.changed | default(false) + or matrix_synapse_usage_exporter_systemd_service_result.changed | default(false) + or matrix_synapse_usage_exporter_container_image_pull_result.changed | default(false) + }} diff --git a/roles/custom/matrix-user-verification-service/defaults/main.yml b/roles/custom/matrix-user-verification-service/defaults/main.yml index 1bc8cf60f..a6c5829f1 100644 --- a/roles/custom/matrix-user-verification-service/defaults/main.yml +++ b/roles/custom/matrix-user-verification-service/defaults/main.yml @@ -85,3 +85,13 @@ matrix_user_verification_service_uvs_openid_verify_server_name: "{{ matrix_domai # Log level # See choices here: https://github.com/winstonjs/winston#logging-levels matrix_user_verification_service_uvs_log_level: info + +# matrix_user_verification_service_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). +# +# This value is automatically computed during installation based on whether +# 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_user_verification_service_restart_necessary: false diff --git a/roles/custom/matrix-user-verification-service/tasks/setup_install.yml b/roles/custom/matrix-user-verification-service/tasks/setup_install.yml index 634761484..d2a7b9e6f 100644 --- a/roles/custom/matrix-user-verification-service/tasks/setup_install.yml +++ b/roles/custom/matrix-user-verification-service/tasks/setup_install.yml @@ -24,10 +24,10 @@ source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" force_source: "{{ matrix_user_verification_service_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_user_verification_service_docker_image_force_pull }}" - register: result + register: matrix_user_verification_service_container_image_pull_result retries: "{{ devture_playbook_help_container_retries_count }}" delay: "{{ devture_playbook_help_container_retries_delay }}" - until: result is not failed + until: matrix_user_verification_service_container_image_pull_result is not failed when: "not matrix_user_verification_service_container_image_self_build | bool" - name: Ensure Matrix User Verification Service repository is present when self-building @@ -60,6 +60,7 @@ owner: "{{ matrix_user_name }}" group: "{{ matrix_group_name }}" mode: 0644 + register: matrix_user_verification_service_config_result - name: Ensure matrix-user-verification-service container network is created community.general.docker_network: @@ -73,3 +74,13 @@ src: "{{ role_path }}/templates/systemd/matrix-user-verification-service.service.j2" dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_user_verification_service_systemd_service_name }}" mode: 0644 + register: matrix_user_verification_service_systemd_service_result + +- name: Determine whether Matrix User Verification Service needs a restart + ansible.builtin.set_fact: + matrix_user_verification_service_restart_necessary: >- + {{ + matrix_user_verification_service_config_result.changed | default(false) + or matrix_user_verification_service_systemd_service_result.changed | default(false) + or matrix_user_verification_service_container_image_pull_result.changed | default(false) + }}