Kaynağa Gözat

matrix-base: only re-share the Synology volume mount when needed

The make-shared task previously ran on every play with changed_when: false,
which always reported "ok" even when it had just mutated mount propagation.
Check /proc/self/mountinfo for the shared tag first and run mount --make-shared
only when the volume is not already shared, reporting changed accurately.

Detection is fail-safe: grep exits non-zero on no-match or any error, so the
mount is skipped only when shared propagation is positively confirmed. Every
other case falls through to running the (idempotent) command, so behavior
cannot regress relative to running it unconditionally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pull/5315/head
Slavi Pantaleev 3 hafta önce
ebeveyn
işleme
cca1b7dc70
1 değiştirilmiş dosya ile 15 ekleme ve 1 silme
  1. +15
    -1
      roles/custom/matrix-base/tasks/setup_synology_prerequisites.yml

+ 15
- 1
roles/custom/matrix-base/tasks/setup_synology_prerequisites.yml Dosyayı Görüntüle

@@ -9,12 +9,26 @@
name: "{{ matrix_base_synology_requests_version_constraint }}" name: "{{ matrix_base_synology_requests_version_constraint }}"
state: present state: present


# Determine whether the volume is already a shared mount, so that the
# make-shared command below only runs (and only reports `changed`) when it
# actually needs to. We read /proc/self/mountinfo (always present on Linux)
# and look for the ` shared:` optional tag on the volume's mount point line.
# grep exits non-zero on no-match or any error, so the make-shared command is
# skipped only when shared propagation is positively confirmed; every other
# case falls through to running it (which is idempotent).
- name: Determine current mount propagation of the Synology volume
ansible.builtin.command: grep -E ' {{ matrix_base_synology_volume_path }} .* shared:' /proc/self/mountinfo
register: matrix_base_synology_volume_propagation
changed_when: false
failed_when: false

# Run immediately during setup so matrix services can start without a manual # Run immediately during setup so matrix services can start without a manual
# step. The boot-fix service handles this on every subsequent reboot. # step. The boot-fix service handles this on every subsequent reboot.
# noqa command-instead-of-module: ansible.builtin.mount does not support # noqa command-instead-of-module: ansible.builtin.mount does not support
# changing mount propagation (--make-shared); command is the only option here. # changing mount propagation (--make-shared); command is the only option here.
- name: Ensure the Synology volume has shared mount propagation - name: Ensure the Synology volume has shared mount propagation
ansible.builtin.command: mount --make-shared {{ matrix_base_synology_volume_path }} # noqa command-instead-of-module ansible.builtin.command: mount --make-shared {{ matrix_base_synology_volume_path }} # noqa command-instead-of-module
changed_when: false
when: matrix_base_synology_volume_propagation.rc != 0
changed_when: true


- ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_synology_boot_fix.yml" - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_synology_boot_fix.yml"

Yükleniyor…
İptal
Kaydet