Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

100 wiersze
3.3 KiB

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