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.
 
 

70 lines
2.5 KiB

  1. # SPDX-FileCopyrightText: 2026 Chiu Ki Sit
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Fail if matrix_synology_user_password is not set
  6. ansible.builtin.fail:
  7. msg: >-
  8. You must set `matrix_synology_user_password` to a non-empty value in your vars.yml.
  9. This password secures the Matrix service account on Synology DSM.
  10. The account is created as expired so the password cannot be used to log in.
  11. when: matrix_synology_user_password == '' or matrix_synology_user_password is none
  12. - name: Check if Matrix user exists (Synology)
  13. ansible.builtin.command: id {{ matrix_user_name }}
  14. register: matrix_user_check
  15. changed_when: false
  16. failed_when: false
  17. # Created with expired=1 (cannot log in)
  18. # as this is a service account. If you pre-create the user, you are responsible
  19. # for securing it; the playbook will not modify an existing account's settings.
  20. - name: Ensure Matrix user is created (Synology)
  21. ansible.builtin.command: >
  22. /usr/syno/sbin/synouser --add {{ matrix_user_name }}
  23. "{{ matrix_synology_user_password }}" "{{ matrix_user_name }}" 1 "" 0
  24. when: matrix_user_check.rc != 0
  25. changed_when: true
  26. no_log: true
  27. - name: Ensure Matrix user password is up to date (Synology)
  28. ansible.builtin.command: /usr/syno/sbin/synouser --setpw {{ matrix_user_name }} "{{ matrix_synology_user_password }}"
  29. when: matrix_user_check.rc == 0
  30. changed_when: false
  31. no_log: true
  32. - name: Check if Matrix group exists (Synology)
  33. ansible.builtin.command: /usr/syno/sbin/synogroup --get {{ matrix_group_name }}
  34. register: matrix_group_check
  35. changed_when: false
  36. failed_when: false
  37. - name: Ensure Matrix group is created (Synology)
  38. ansible.builtin.command: /usr/syno/sbin/synogroup --add {{ matrix_group_name }} {{ matrix_user_name }}
  39. when: matrix_group_check.rc != 0
  40. changed_when: true
  41. - name: Get Matrix user UID (Synology)
  42. ansible.builtin.command: id -u {{ matrix_user_name }}
  43. register: matrix_user_uid_result
  44. changed_when: false
  45. - name: Get Matrix group info (Synology)
  46. ansible.builtin.command: /usr/syno/sbin/synogroup --get {{ matrix_group_name }}
  47. register: matrix_synogroup_result
  48. changed_when: false
  49. - name: Initialize matrix_user_uid and matrix_user_gid
  50. ansible.builtin.set_fact:
  51. matrix_user_uid: "{{ matrix_user_uid_result.stdout }}"
  52. matrix_user_gid: >-
  53. {{
  54. matrix_synogroup_result.stdout_lines
  55. | select('match', '^Group ID:')
  56. | first
  57. | regex_search('\[(\d+)\]', '\1')
  58. | first
  59. }}