Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

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