Просмотр исходного кода

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>
migration-validation-system
Slavi Pantaleev 1 день назад
Родитель
Сommit
d3241588e3
15 измененных файлов: 204 добавлений и 28 удалений
  1. +12
    -7
      group_vars/matrix_servers
  2. +10
    -0
      roles/custom/matrix-bridge-appservice-kakaotalk/defaults/main.yml
  3. +21
    -4
      roles/custom/matrix-bridge-appservice-kakaotalk/tasks/setup_install.yml
  4. +10
    -0
      roles/custom/matrix-bridge-wechat/defaults/main.yml
  5. +20
    -4
      roles/custom/matrix-bridge-wechat/tasks/install.yml
  6. +10
    -0
      roles/custom/matrix-conduit/defaults/main.yml
  7. +15
    -2
      roles/custom/matrix-conduit/tasks/setup_install.yml
  8. +10
    -0
      roles/custom/matrix-continuwuity/defaults/main.yml
  9. +15
    -2
      roles/custom/matrix-continuwuity/tasks/install.yml
  10. +10
    -0
      roles/custom/matrix-dendrite/defaults/main.yml
  11. +21
    -5
      roles/custom/matrix-dendrite/tasks/setup_install.yml
  12. +10
    -0
      roles/custom/matrix-element-call/defaults/main.yml
  13. +15
    -2
      roles/custom/matrix-element-call/tasks/install.yml
  14. +10
    -0
      roles/custom/matrix-media-repo/defaults/main.yml
  15. +15
    -2
      roles/custom/matrix-media-repo/tasks/setup_install.yml

+ 12
- 7
group_vars/matrix_servers Просмотреть файл

@@ -383,14 +383,14 @@ devture_systemd_service_manager_services_list_auto: |
([{
'name': 'matrix-appservice-kakaotalk.service',
'priority': 2000,
'restart_necessary': true,
'restart_necessary': (matrix_appservice_kakaotalk_restart_necessary | bool),
'groups': ['matrix', 'bridges', 'appservice-kakaotalk'],
}] if matrix_appservice_kakaotalk_enabled else [])
+
([{
'name': 'matrix-appservice-kakaotalk-node.service',
'priority': 1900,
'restart_necessary': true,
'restart_necessary': (matrix_appservice_kakaotalk_restart_necessary | bool),
'groups': ['matrix', 'bridges', 'appservice-kakaotalk', 'appservice-kakaotalk-node'],
}] if matrix_appservice_kakaotalk_enabled else [])
+
@@ -404,14 +404,14 @@ devture_systemd_service_manager_services_list_auto: |
([{
'name': 'matrix-wechat.service',
'priority': 2000,
'restart_necessary': true,
'restart_necessary': (matrix_wechat_restart_necessary | bool),
'groups': ['matrix', 'bridges', 'wechat'],
}] if matrix_wechat_enabled else [])
+
([{
'name': 'matrix-wechat-agent.service',
'priority': 2000,
'restart_necessary': true,
'restart_necessary': (matrix_wechat_restart_necessary | bool),
'groups': ['matrix', 'bridges', 'wechat'],
}] if matrix_wechat_enabled else [])
+
@@ -621,7 +621,12 @@ devture_systemd_service_manager_services_list_auto: |
([{
'name': ('matrix-' + matrix_homeserver_implementation + '.service'),
'priority': matrix_homeserver_systemd_service_manager_priority,
'restart_necessary': true,
'restart_necessary': (
(matrix_conduit_restart_necessary | bool) if matrix_homeserver_implementation == 'conduit'
else (matrix_continuwuity_restart_necessary | bool) if matrix_homeserver_implementation == 'continuwuity'
else (matrix_dendrite_restart_necessary | bool) if matrix_homeserver_implementation == 'dendrite'
else true
),
'groups': ['matrix', 'homeservers', matrix_homeserver_implementation],
}] if matrix_homeserver_enabled else [])
+
@@ -719,7 +724,7 @@ devture_systemd_service_manager_services_list_auto: |
([{
'name': (matrix_media_repo_identifier + '.service'),
'priority': 4000,
'restart_necessary': true,
'restart_necessary': (matrix_media_repo_restart_necessary | bool),
'groups': ['matrix', 'matrix-media-repo'],
}] if matrix_media_repo_enabled else [])
+
@@ -803,7 +808,7 @@ devture_systemd_service_manager_services_list_auto: |
([{
'name': 'matrix-element-call.service',
'priority': 4000,
'restart_necessary': true,
'restart_necessary': (matrix_element_call_restart_necessary | bool),
'groups': ['matrix', 'element-call'],
}] if matrix_element_call_enabled else [])
+


+ 10
- 0
roles/custom/matrix-bridge-appservice-kakaotalk/defaults/main.yml Просмотреть файл

@@ -225,3 +225,13 @@ matrix_appservice_kakaotalk_registration_yaml: |
rate_limited: false

matrix_appservice_kakaotalk_registration: "{{ matrix_appservice_kakaotalk_registration_yaml | from_yaml }}"

# matrix_appservice_kakaotalk_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_kakaotalk_restart_necessary: false

+ 21
- 4
roles/custom/matrix-bridge-appservice-kakaotalk/tasks/setup_install.yml Просмотреть файл

@@ -13,10 +13,10 @@
force_source: "{{ matrix_appservice_kakaotalk_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_appservice_kakaotalk_container_image_force_pull }}"
when: not matrix_appservice_kakaotalk_container_image_self_build
register: result
register: matrix_appservice_kakaotalk_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_kakaotalk_container_image_pull_result is not failed

- name: Ensure matrix-appservice-kakaotalk-node image is pulled
community.docker.docker_image:
@@ -25,10 +25,10 @@
force_source: "{{ matrix_appservice_kakaotalk_node_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_appservice_kakaotalk_node_container_image_force_pull }}"
when: not matrix_appservice_kakaotalk_container_image_self_build
register: result
register: matrix_appservice_kakaotalk_node_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_kakaotalk_node_container_image_pull_result is not failed

- name: Ensure matrix-appservice-kakaotalk paths exist
ansible.builtin.file:
@@ -86,6 +86,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_appservice_kakaotalk_node_config_result

- name: Ensure matrix-appservice-kakaotalk config.yaml installed
ansible.builtin.copy:
@@ -94,6 +95,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_appservice_kakaotalk_config_result

- name: Ensure matrix-appservice-kakaotalk registration.yaml installed
ansible.builtin.copy:
@@ -102,6 +104,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_appservice_kakaotalk_registration_result

- name: Ensure matrix-appservice-kakaotalk container network is created
community.general.docker_network:
@@ -122,3 +125,17 @@
src: "{{ role_path }}/templates/systemd/matrix-appservice-kakaotalk.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-appservice-kakaotalk.service"
mode: '0644'
register: matrix_appservice_kakaotalk_systemd_service_result

- name: Determine whether matrix-appservice-kakaotalk needs a restart
ansible.builtin.set_fact:
matrix_appservice_kakaotalk_restart_necessary: >-
{{
matrix_appservice_kakaotalk_node_config_result.changed | default(false)
or matrix_appservice_kakaotalk_config_result.changed | default(false)
or matrix_appservice_kakaotalk_registration_result.changed | default(false)
or matrix_appservice_kakaotalk_node_systemd_service_result.changed | default(false)
or matrix_appservice_kakaotalk_systemd_service_result.changed | default(false)
or matrix_appservice_kakaotalk_container_image_pull_result.changed | default(false)
or matrix_appservice_kakaotalk_node_container_image_pull_result.changed | default(false)
}}

+ 10
- 0
roles/custom/matrix-bridge-wechat/defaults/main.yml Просмотреть файл

@@ -163,3 +163,13 @@ matrix_wechat_agent_service_secret: "{{ matrix_wechat_bridge_listen_secret }}"
matrix_wechat_agent_configuration_yaml: "{{ lookup('template', 'templates/agent-config.yaml.j2') }}"

matrix_wechat_agent_configuration: "{{ matrix_wechat_agent_configuration_yaml | from_yaml }}"

# matrix_wechat_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_wechat_restart_necessary: false

+ 20
- 4
roles/custom/matrix-bridge-wechat/tasks/install.yml Просмотреть файл

@@ -27,10 +27,10 @@
force_source: "{{ matrix_wechat_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_wechat_container_image_force_pull }}"
when: not matrix_wechat_container_image_self_build
register: result
register: matrix_wechat_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_wechat_container_image_pull_result is not failed

- when: matrix_wechat_container_image_self_build | bool
block:
@@ -62,10 +62,10 @@
force_source: "{{ matrix_wechat_agent_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_wechat_agent_container_image_force_pull }}"
when: not matrix_wechat_agent_container_image_self_build
register: result
register: matrix_wechat_agent_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_wechat_agent_container_image_pull_result is not failed

- when: matrix_wechat_agent_container_image_self_build | bool
block:
@@ -97,6 +97,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_wechat_config_result

- name: Ensure WeChat registration.yaml installed
ansible.builtin.copy:
@@ -105,6 +106,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_wechat_registration_result

- name: Ensure Wechat Agent configuration installed
ansible.builtin.copy:
@@ -113,6 +115,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_wechat_agent_config_result

- name: Ensure matrix-wechat container network is created
community.general.docker_network:
@@ -134,3 +137,16 @@
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-wechat-agent.service"
mode: '0644'
register: matrix_wechat_agent_systemd_service_result

- name: Determine whether WeChat Bridge needs a restart
ansible.builtin.set_fact:
matrix_wechat_restart_necessary: >-
{{
matrix_wechat_config_result.changed | default(false)
or matrix_wechat_registration_result.changed | default(false)
or matrix_wechat_agent_config_result.changed | default(false)
or matrix_wechat_systemd_service_result.changed | default(false)
or matrix_wechat_agent_systemd_service_result.changed | default(false)
or matrix_wechat_container_image_pull_result.changed | default(false)
or matrix_wechat_agent_container_image_pull_result.changed | default(false)
}}

+ 10
- 0
roles/custom/matrix-conduit/defaults/main.yml Просмотреть файл

@@ -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

+ 15
- 2
roles/custom/matrix-conduit/tasks/setup_install.yml Просмотреть файл

@@ -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)
}}

+ 10
- 0
roles/custom/matrix-continuwuity/defaults/main.yml Просмотреть файл

@@ -208,3 +208,13 @@ matrix_continuwuity_config_url_preview_domain_contains_allowlist: []
# CONTINUWUITY_MAX_REQUEST_SIZE=50000000
# CONTINUWUITY_REQUEST_TIMEOUT=60
matrix_continuwuity_environment_variables_extension: ''

# matrix_continuwuity_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_continuwuity_restart_necessary: false

+ 15
- 2
roles/custom/matrix-continuwuity/tasks/install.yml Просмотреть файл

@@ -27,6 +27,7 @@
mode: '0644'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_continuwuity_config_result

- name: Ensure continuwuity support files installed
ansible.builtin.template:
@@ -38,6 +39,7 @@
with_items:
- labels
- env
register: matrix_continuwuity_support_files_result

- name: Ensure continuwuity container network is created
community.general.docker_network:
@@ -52,13 +54,24 @@
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_continuwuity_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_continuwuity_container_image_force_pull }}"
register: result
register: matrix_continuwuity_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_continuwuity_container_image_pull_result is not failed

- name: Ensure matrix-continuwuity.service installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-continuwuity.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-continuwuity.service"
mode: '0644'
register: matrix_continuwuity_systemd_service_result

- name: Determine whether continuwuity needs a restart
ansible.builtin.set_fact:
matrix_continuwuity_restart_necessary: >-
{{
matrix_continuwuity_config_result.changed | default(false)
or matrix_continuwuity_support_files_result.changed | default(false)
or matrix_continuwuity_systemd_service_result.changed | default(false)
or matrix_continuwuity_container_image_pull_result.changed | default(false)
}}

+ 10
- 0
roles/custom/matrix-dendrite/defaults/main.yml Просмотреть файл

@@ -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

+ 21
- 5
roles/custom/matrix-dendrite/tasks/setup_install.yml Просмотреть файл

@@ -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)
}}

+ 10
- 0
roles/custom/matrix-element-call/defaults/main.yml Просмотреть файл

@@ -153,3 +153,13 @@ matrix_element_call_config_default_server_config_m_homeserver_server_name: "{{ m

# Controls the livekit/livekit_service_url property in the config.json file.
matrix_element_call_config_livekit_livekit_service_url: ""

# matrix_element_call_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_call_restart_necessary: false

+ 15
- 2
roles/custom/matrix-element-call/tasks/install.yml Просмотреть файл

@@ -23,6 +23,7 @@
mode: '0640'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_element_call_config_result

- name: Ensure Element Call container labels file is in place
ansible.builtin.template:
@@ -31,16 +32,17 @@
mode: '0640'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_element_call_support_files_result

- name: Ensure Element Call container image is pulled
community.docker.docker_image:
name: "{{ matrix_element_call_container_image }}"
source: pull
force_source: "{{ matrix_element_call_container_image_force_pull }}"
register: element_call_image_result
register: matrix_element_call_container_image_pull_result
retries: "{{ devture_playbook_help_container_retries_count }}"
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: element_call_image_result is not failed
until: matrix_element_call_container_image_pull_result is not failed

- name: Ensure Element Call container network is created
community.general.docker_network:
@@ -54,3 +56,14 @@
src: "{{ role_path }}/templates/systemd/matrix-element-call.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-element-call.service"
mode: '0644'
register: matrix_element_call_systemd_service_result

- name: Determine whether Element Call needs a restart
ansible.builtin.set_fact:
matrix_element_call_restart_necessary: >-
{{
matrix_element_call_config_result.changed | default(false)
or matrix_element_call_support_files_result.changed | default(false)
or matrix_element_call_systemd_service_result.changed | default(false)
or matrix_element_call_container_image_pull_result.changed | default(false)
}}

+ 10
- 0
roles/custom/matrix-media-repo/defaults/main.yml Просмотреть файл

@@ -939,3 +939,13 @@ matrix_media_repo_pgo_submit_key: "INSERT_VALUE_HERE"

# Specifies whether the homeserver supports federation
matrix_media_repo_homeserver_federation_enabled: true

# matrix_media_repo_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_media_repo_restart_necessary: false

+ 15
- 2
roles/custom/matrix-media-repo/tasks/setup_install.yml Просмотреть файл

@@ -35,6 +35,7 @@
with_items:
- env
- labels
register: matrix_media_repo_support_files_result

- name: Ensure media-repo configuration installed
ansible.builtin.template:
@@ -43,6 +44,7 @@
mode: '0640'
owner: "{{ matrix_user_name }}"
group: "{{ matrix_group_name }}"
register: matrix_media_repo_config_result

- name: Ensure media-repo Docker image is pulled
community.docker.docker_image:
@@ -51,10 +53,10 @@
force_source: "{{ matrix_media_repo_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_media_repo_container_image_force_pull }}"
when: "not matrix_media_repo_container_image_self_build | bool"
register: result
register: matrix_media_repo_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_media_repo_container_image_pull_result is not failed

- when: "matrix_media_repo_container_image_self_build | bool"
block:
@@ -153,3 +155,14 @@
src: "{{ role_path }}/templates/media-repo/systemd/matrix-media-repo.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ matrix_media_repo_identifier }}.service"
mode: '0640'
register: matrix_media_repo_systemd_service_result

- name: Determine whether media-repo needs a restart
ansible.builtin.set_fact:
matrix_media_repo_restart_necessary: >-
{{
matrix_media_repo_config_result.changed | default(false)
or matrix_media_repo_support_files_result.changed | default(false)
or matrix_media_repo_systemd_service_result.changed | default(false)
or matrix_media_repo_container_image_pull_result.changed | default(false)
}}

Загрузка…
Отмена
Сохранить