Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

92 lignes
3.0 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_synapse_docker_image }}"
  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_synapse_docker_image }}"
  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 Synapse environment variables file created
  56. template:
  57. src: "{{ role_path }}/templates/env/env-synapse.j2"
  58. dest: "{{ matrix_environment_variables_data_path }}/synapse"
  59. owner: root
  60. mode: 0600
  61. - name: Ensure matrix-synapse.service installed
  62. template:
  63. src: "{{ role_path }}/templates/systemd/matrix-synapse.service.j2"
  64. dest: "/etc/systemd/system/matrix-synapse.service"
  65. mode: 0644
  66. - name: Ensure matrix-synapse-register-user script created
  67. template:
  68. src: "{{ role_path }}/templates/usr-local-bin/matrix-synapse-register-user.j2"
  69. dest: "/usr/local/bin/matrix-synapse-register-user"
  70. mode: 0750
  71. - name: Allow access to Matrix ports in firewalld
  72. firewalld:
  73. port: "{{ item }}"
  74. state: enabled
  75. immediate: yes
  76. permanent: yes
  77. with_items:
  78. - '8448/tcp' # Matrix federation
  79. when: ansible_os_family == 'RedHat'