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.
 
 

88 righe
3.2 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 Docker image is pulled
  19. docker_image:
  20. name: "{{ matrix_synapse_docker_image }}"
  21. - name: Check if a Synapse signing key exists
  22. stat:
  23. path: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.key"
  24. register: matrix_synapse_signing_key_stat
  25. # We do this so that the signing key would get generated.
  26. #
  27. # This will also generate a default homeserver.yaml configuration file and a log configuration file.
  28. # We don't care about those configuraiton files, as we replace them with our own anyway (see below).
  29. #
  30. # We don't use the `docker_container` module, because using it with `cap_drop` requires
  31. # a very recent version, which is not available for a lot of people yet.
  32. - name: Generate initial Synapse config and signing key
  33. command: |
  34. docker run
  35. --rm
  36. --name=matrix-config
  37. --user={{ matrix_user_uid }}:{{ matrix_user_gid }}
  38. --cap-drop=ALL
  39. -v {{ matrix_synapse_config_dir_path }}:/data
  40. -e SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
  41. -e SYNAPSE_SERVER_NAME={{ matrix_server_fqn_matrix }}
  42. -e SYNAPSE_REPORT_STATS=no
  43. {{ matrix_synapse_docker_image }}
  44. generate
  45. when: "not matrix_synapse_signing_key_stat.stat.exists"
  46. - name: Ensure Synapse homeserver config installed
  47. template:
  48. src: "{{ matrix_synapse_template_synapse_homeserver }}"
  49. dest: "{{ matrix_synapse_config_dir_path }}/homeserver.yaml"
  50. mode: 0644
  51. - name: Ensure Synapse log config installed
  52. template:
  53. src: "{{ matrix_synapse_template_synapse_log }}"
  54. dest: "{{ matrix_synapse_config_dir_path }}/{{ matrix_server_fqn_matrix }}.log.config"
  55. mode: 0644
  56. - name: Ensure matrix-synapse.service installed
  57. template:
  58. src: "{{ role_path }}/templates/synapse/systemd/matrix-synapse.service.j2"
  59. dest: "/etc/systemd/system/matrix-synapse.service"
  60. mode: 0644
  61. register: matrix_synapse_systemd_service_result
  62. - name: Ensure systemd reloaded after matrix-synapse.service installation
  63. service:
  64. daemon_reload: yes
  65. when: matrix_synapse_systemd_service_result.changed
  66. - name: Ensure matrix-synapse-register-user script created
  67. template:
  68. src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-register-user.j2"
  69. dest: "/usr/local/bin/matrix-synapse-register-user"
  70. mode: 0750
  71. - name: Ensure matrix-synapse-generate-password-hash script created
  72. template:
  73. src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-generate-password-hash.j2"
  74. dest: "/usr/local/bin/matrix-synapse-generate-password-hash"
  75. mode: 0750