From cca1b7dc70edb8f04afa03a294a732e88bd0e7e1 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 29 Jun 2026 19:40:09 +0300 Subject: [PATCH] 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) --- .../tasks/setup_synology_prerequisites.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-base/tasks/setup_synology_prerequisites.yml b/roles/custom/matrix-base/tasks/setup_synology_prerequisites.yml index c95757214..5985e8dd4 100644 --- a/roles/custom/matrix-base/tasks/setup_synology_prerequisites.yml +++ b/roles/custom/matrix-base/tasks/setup_synology_prerequisites.yml @@ -9,12 +9,26 @@ name: "{{ matrix_base_synology_requests_version_constraint }}" 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 # step. The boot-fix service handles this on every subsequent reboot. # noqa command-instead-of-module: ansible.builtin.mount does not support # changing mount propagation (--make-shared); command is the only option here. - 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 - 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"