Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

82 строки
2.7 KiB

  1. ---
  2. # This will throw a Permission Denied error if already mounted using fuse
  3. - name: Check Matrix Synapse media store path
  4. stat:
  5. path: "{{ matrix_synapse_media_store_path }}"
  6. register: local_path_media_store_stat
  7. ignore_errors: yes
  8. # This is separate and conditional, to ensure we don't execute it
  9. # if the path already exists or we failed to check, because it's mounted using fuse.
  10. - name: Ensure Matrix media store path exists
  11. file:
  12. path: "{{ matrix_synapse_media_store_path }}"
  13. state: directory
  14. mode: 0750
  15. owner: "{{ matrix_user_username }}"
  16. group: "{{ matrix_user_username }}"
  17. when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"
  18. - name: Ensure Matrix Docker image is pulled
  19. docker_image:
  20. name: "{{ matrix_synapse_docker_image }}"
  21. - name: Check if a Matrix Synapse configuration exists
  22. stat:
  23. path: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml"
  24. register: matrix_synapse_config_stat
  25. # We do this mostly so that the keys would get generated.
  26. # We'll replace the rest of the configuration with our own templates below.
  27. - name: Generate initial Matrix config
  28. docker_container:
  29. name: matrix-config
  30. image: "{{ matrix_synapse_docker_image }}"
  31. detach: no
  32. cleanup: yes
  33. command: generate
  34. env:
  35. SYNAPSE_CONFIG_PATH: "/data/homeserver.yaml"
  36. SYNAPSE_SERVER_NAME: "{{ hostname_matrix }}"
  37. SYNAPSE_REPORT_STATS: "no"
  38. user: "{{ matrix_user_uid }}:{{ matrix_user_gid }}"
  39. cap_drop: ['all']
  40. volumes:
  41. - "{{ matrix_synapse_config_dir_path }}:/data"
  42. when: "not matrix_synapse_config_stat.stat.exists"
  43. - name: Ensure Matrix homeserver config installed
  44. template:
  45. src: "{{ matrix_synapse_template_synapse_homeserver }}"
  46. dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml"
  47. mode: 0644
  48. - name: Ensure Matrix log config installed
  49. template:
  50. src: "{{ matrix_synapse_template_synapse_log }}"
  51. dest: "{{ matrix_synapse_config_dir_path }}/{{ hostname_matrix }}.log.config"
  52. mode: 0644
  53. - name: Ensure matrix-synapse.service installed
  54. template:
  55. src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2"
  56. dest: "/etc/systemd/system/matrix-synapse.service"
  57. mode: 0644
  58. - name: Ensure matrix-synapse-register-user script created
  59. template:
  60. src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-register-user.j2"
  61. dest: "/usr/local/bin/matrix-synapse-register-user"
  62. mode: 0750
  63. - name: Allow access to Matrix ports in firewalld
  64. firewalld:
  65. port: "{{ item }}"
  66. state: enabled
  67. immediate: yes
  68. permanent: yes
  69. with_items:
  70. - '8448/tcp' # Matrix federation
  71. when: ansible_os_family == 'RedHat'