Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
2.2 KiB

  1. # SPDX-FileCopyrightText: 2017 - 2025 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2018 - 2022 MDAD project contributors
  3. # SPDX-FileCopyrightText: 2019 Stuart Mumford
  4. # SPDX-FileCopyrightText: 2020 Béla Becker
  5. # SPDX-FileCopyrightText: 2020 Chris van Dijk
  6. # SPDX-FileCopyrightText: 2020 Horvath Gergely
  7. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  8. # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
  9. # SPDX-FileCopyrightText: 2024 László Várady
  10. # SPDX-FileCopyrightText: 2026 Chiu Ki Sit
  11. #
  12. # SPDX-License-Identifier: AGPL-3.0-or-later
  13. ---
  14. # Snapshot ownership before any changes so we can decide whether a recursive
  15. # chown is needed (only when uid/gid actually differs from expected).
  16. - name: Check current ownership of Matrix base path (Synology)
  17. ansible.builtin.stat:
  18. path: "{{ matrix_base_data_path }}"
  19. register: matrix_base_data_path_stat
  20. when: matrix_base_host_is_synology
  21. - name: Ensure Matrix base paths exists
  22. ansible.builtin.file:
  23. path: "{{ item }}"
  24. state: directory
  25. mode: "{{ matrix_base_data_path_mode }}"
  26. owner: "{{ matrix_user_name }}"
  27. group: "{{ matrix_group_name }}"
  28. with_items:
  29. - "{{ matrix_base_data_path }}"
  30. - "{{ matrix_bin_path }}"
  31. - name: Ensure remove-all script created
  32. ansible.builtin.template:
  33. src: "{{ role_path }}/templates/bin/remove-all.j2"
  34. dest: "{{ matrix_bin_path }}/remove-all"
  35. mode: '0750'
  36. # On Synology, name-based chown works for directly-touched paths but leaves
  37. # existing sub-paths with stale numeric ownership when uid/gid changes between
  38. # runs. We recurse only when the pre-task uid/gid didn't match, so normal runs
  39. # skip the expensive tree walk entirely. chown -R is used instead of the file
  40. # module's recurse option to avoid Ansible iterating every entry in Python.
  41. - name: Ensure Matrix base path ownership is correct using numeric UID/GID (Synology)
  42. ansible.builtin.command: chown -R {{ matrix_user_uid }}:{{ matrix_user_gid }} {{ matrix_base_data_path }}
  43. changed_when: true
  44. when: >-
  45. matrix_base_host_is_synology and (
  46. not matrix_base_data_path_stat.stat.exists or
  47. matrix_base_data_path_stat.stat.uid | int != matrix_user_uid | int or
  48. matrix_base_data_path_stat.stat.gid | int != matrix_user_gid | int
  49. )