Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

83 行
2.8 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. #
  28. # We don't use the `docker_container` module, because using it with `cap_drop` requires
  29. # a very recent version, which is not available for a lot of people yet.
  30. - name: Generate initial Matrix config
  31. command: |
  32. docker run
  33. --rm
  34. --name=matrix-config
  35. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  36. --cap-drop=ALL
  37. -v {{ matrix_synapse_config_dir_path }}:/data
  38. -e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
  39. -e SYNAPSE_SERVER_NAME={{ matrix_server_fqn_matrix }}
  40. -e SYNAPSE_REPORT_STATS=no
  41. {{ matrix_synapse_docker_image }}
  42. generate
  43. when: "not matrix_synapse_config_stat.stat.exists"
  44. - name: Ensure Matrix homeserver config installed
  45. template:
  46. src: "{{ matrix_synapse_template_synapse_homeserver }}"
  47. dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml"
  48. mode: 0644
  49. - name: Ensure Matrix log config installed
  50. template:
  51. src: "{{ matrix_synapse_template_synapse_log }}"
  52. dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.log.config"
  53. mode: 0644
  54. - name: Ensure matrix-synapse.service installed
  55. template:
  56. src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2"
  57. dest: "/etc/systemd/system/matrix-synapse.service"
  58. mode: 0644
  59. - name: Ensure matrix-synapse-register-user script created
  60. template:
  61. src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-register-user.j2"
  62. dest: "/usr/local/bin/matrix-synapse-register-user"
  63. mode: 0750
  64. - name: Allow access to Matrix ports in firewalld
  65. firewalld:
  66. port: "{{ item }}"
  67. state: enabled
  68. immediate: yes
  69. permanent: yes
  70. with_items:
  71. - '8448/tcp' # Matrix federation
  72. when: ansible_os_family == 'RedHat'