Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

107 líneas
4.1 KiB

  1. ---
  2. # This will throw a Permission Denied error if already mounted using fuse
  3. - name: Check 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 Synapse 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 Synapse repository is present on self-build
  19. git:
  20. repo: https://github.com/matrix-org/synapse.git
  21. dest: "{{ matrix_synapse_docker_src_files_path }}"
  22. version: "{{ matrix_synapse_docker_image.split(':')[1] }}"
  23. force: "yes"
  24. when: "matrix_synapse_container_image_self_build"
  25. - name: Ensure Synapse Docker image is built
  26. docker_image:
  27. name: "{{ matrix_synapse_docker_image }}"
  28. source: build
  29. build:
  30. dockerfile: docker/Dockerfile
  31. path: "{{ matrix_synapse_docker_src_files_path }}"
  32. pull: yes
  33. when: "matrix_synapse_container_image_self_build"
  34. - name: Ensure Synapse Docker image is pulled
  35. docker_image:
  36. name: "{{ matrix_synapse_docker_image }}"
  37. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  38. force_source: "{{ matrix_synapse_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  39. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_synapse_docker_image_force_pull }}"
  40. when: "not matrix_synapse_container_image_self_build"
  41. - name: Check if a Synapse signing key exists
  42. stat:
  43. path: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.key"
  44. register: matrix_synapse_signing_key_stat
  45. # We do this so that the signing key would get generated.
  46. #
  47. # This will also generate a default homeserver.yaml configuration file and a log configuration file.
  48. # We don't care about those configuraiton files, as we replace them with our own anyway (see below).
  49. #
  50. # We don't use the `docker_container` module, because using it with `cap_drop` requires
  51. # a very recent version, which is not available for a lot of people yet.
  52. - name: Generate initial Synapse config and signing key
  53. command: |
  54. docker run
  55. --rm
  56. --name=matrix-config
  57. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  58. --cap-drop=ALL
  59. -v {{ matrix_synapse_config_dir_path }}:/data
  60. -e UID={{ matrix_user_uid }}
  61. -e GID={{ matrix_user_gid }}
  62. -e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
  63. -e SYNAPSE_SERVER_NAME={{ matrix_server_fqn_matrix }}
  64. -e SYNAPSE_REPORT_STATS=no
  65. {{ matrix_synapse_docker_image }}
  66. generate
  67. when: "not matrix_synapse_signing_key_stat.stat.exists"
  68. - name: Ensure Synapse homeserver config installed
  69. copy:
  70. content: "{{ matrix_synapse_configuration|to_nice_yaml }}"
  71. dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml"
  72. mode: 0644
  73. owner: "{{ matrix_user_username }}"
  74. group: "{{ matrix_user_username }}"
  75. - name: Ensure Synapse log config installed
  76. template:
  77. src: "{{ matrix_synapse_template_synapse_log }}"
  78. dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.log.config"
  79. mode: 0644
  80. - name: Ensure matrix-synapse.service installed
  81. template:
  82. src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2"
  83. dest: "/etc/systemd/system/matrix-synapse.service"
  84. mode: 0644
  85. register: matrix_synapse_systemd_service_result
  86. - name: Ensure systemd reloaded after matrix-synapse.service installation
  87. service:
  88. daemon_reload: yes
  89. when: "matrix_synapse_systemd_service_result.changed"
  90. - name: Ensure matrix-synapse-register-user script created
  91. template:
  92. src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-register-user.j2"
  93. dest: "/usr/local/bin/matrix-synapse-register-user"
  94. mode: 0750