mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-04-06 20:59:45 +00:00
Add conditional restart support to 7 roles that previously always restarted
Replace hardcoded restart_necessary: true with computed values for: conduit, continuwuity, dendrite, element-call, media-repo, appservice-kakaotalk, and wechat. Each role now registers results from config, support files, systemd service, and docker image pull tasks, then computes a restart_necessary variable from their combined .changed state. group_vars/matrix_servers is updated to reference these variables instead of hardcoding true. For dendrite, the systemd service template was also separated out of the combined support-files with_items loop so it can be independently tracked. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -361,3 +361,13 @@ matrix_dendrite_media_api_max_thumbnail_generators: 10
|
||||
|
||||
# Controls whether the full-text search engine is enabled
|
||||
matrix_dendrite_sync_api_search_enabled: false
|
||||
|
||||
# matrix_dendrite_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_dendrite_restart_necessary: false
|
||||
|
||||
@@ -55,10 +55,10 @@
|
||||
force_source: "{{ matrix_dendrite_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_dendrite_container_image_force_pull }}"
|
||||
when: "not matrix_dendrite_container_image_self_build | bool"
|
||||
register: result
|
||||
register: matrix_dendrite_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_dendrite_container_image_pull_result is not failed
|
||||
|
||||
# We do this so that the signing key would get generated.
|
||||
# We don't use the `docker_container` module, because using it with `cap_drop` requires
|
||||
@@ -89,6 +89,7 @@
|
||||
mode: '0644'
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
register: matrix_dendrite_config_result
|
||||
|
||||
- when: "matrix_dendrite_container_image_self_build | bool"
|
||||
block:
|
||||
@@ -139,6 +140,21 @@
|
||||
- src: bin/create-account.j2
|
||||
dest: "{{ matrix_dendrite_bin_path }}/create-account"
|
||||
mode: "0750"
|
||||
- src: systemd/matrix-dendrite.service.j2
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-dendrite.service"
|
||||
mode: "0644"
|
||||
register: matrix_dendrite_support_files_result
|
||||
|
||||
- name: Ensure matrix-dendrite.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-dendrite.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-dendrite.service"
|
||||
mode: '0644'
|
||||
register: matrix_dendrite_systemd_service_result
|
||||
|
||||
- name: Determine whether Dendrite needs a restart
|
||||
ansible.builtin.set_fact:
|
||||
matrix_dendrite_restart_necessary: >-
|
||||
{{
|
||||
matrix_dendrite_config_result.changed | default(false)
|
||||
or matrix_dendrite_support_files_result.changed | default(false)
|
||||
or matrix_dendrite_systemd_service_result.changed | default(false)
|
||||
or matrix_dendrite_container_image_pull_result.changed | default(false)
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user