mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-03-26 06:27:23 +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:
@@ -154,3 +154,13 @@ matrix_conduit_turn_uris: []
|
||||
matrix_conduit_turn_secret: ''
|
||||
matrix_conduit_turn_username: ''
|
||||
matrix_conduit_turn_password: ''
|
||||
|
||||
# matrix_conduit_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_conduit_restart_necessary: false
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
mode: '0644'
|
||||
owner: "{{ matrix_user_name }}"
|
||||
group: "{{ matrix_group_name }}"
|
||||
register: matrix_conduit_config_result
|
||||
|
||||
- name: Ensure Conduit support files installed
|
||||
ansible.builtin.template:
|
||||
@@ -41,6 +42,7 @@
|
||||
group: "{{ matrix_group_name }}"
|
||||
with_items:
|
||||
- labels
|
||||
register: matrix_conduit_support_files_result
|
||||
|
||||
- name: Ensure Conduit container network is created
|
||||
community.general.docker_network:
|
||||
@@ -55,13 +57,24 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_conduit_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_conduit_container_image_force_pull }}"
|
||||
register: result
|
||||
register: matrix_conduit_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_conduit_container_image_pull_result is not failed
|
||||
|
||||
- name: Ensure matrix-conduit.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-conduit.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-conduit.service"
|
||||
mode: '0644'
|
||||
register: matrix_conduit_systemd_service_result
|
||||
|
||||
- name: Determine whether Conduit needs a restart
|
||||
ansible.builtin.set_fact:
|
||||
matrix_conduit_restart_necessary: >-
|
||||
{{
|
||||
matrix_conduit_config_result.changed | default(false)
|
||||
or matrix_conduit_support_files_result.changed | default(false)
|
||||
or matrix_conduit_systemd_service_result.changed | default(false)
|
||||
or matrix_conduit_container_image_pull_result.changed | default(false)
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user