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.
 
 

82 líneas
3.4 KiB

  1. ---
  2. # This will throw a Permission Denied error if already mounted using fuse
  3. - name: Check Dendrite media store path
  4. ansible.builtin.stat:
  5. path: "{{ matrix_dendrite_media_store_path }}"
  6. register: local_path_media_store_stat
  7. ignore_errors: true
  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 Dendrite media store path exists
  11. ansible.builtin.file:
  12. path: "{{ matrix_dendrite_media_store_path }}"
  13. state: directory
  14. mode: 0750
  15. owner: "{{ matrix_user_username }}"
  16. group: "{{ matrix_user_groupname }}"
  17. when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"
  18. - name: Ensure Dendrite Docker image is pulled
  19. docker_image:
  20. name: "{{ matrix_dendrite_docker_image }}"
  21. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  22. force_source: "{{ matrix_dendrite_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  23. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_dendrite_docker_image_force_pull }}"
  24. register: result
  25. retries: "{{ matrix_container_retries_count }}"
  26. delay: "{{ matrix_container_retries_delay }}"
  27. until: result is not failed
  28. - name: Check if a Dendrite signing key exists
  29. ansible.builtin.stat:
  30. path: "{{ matrix_dendrite_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.pem"
  31. register: matrix_dendrite_signing_key_stat
  32. # We do this so that the signing key would get generated.
  33. # We don't use the `docker_container` module, because using it with `cap_drop` requires
  34. # a very recent version, which is not available for a lot of people yet.
  35. - name: Generate Dendrite signing key
  36. ansible.builtin.command: |
  37. docker run
  38. --rm
  39. --name=matrix-dendrite-config
  40. --entrypoint=generate-keys
  41. --mount type=bind,src={{ matrix_dendrite_config_dir_path }},dst=/data
  42. {{ matrix_dendrite_docker_image }} --private-key=/data/{{ matrix_server_fqn_matrix }}.signing.pem
  43. generate
  44. when: "not matrix_dendrite_signing_key_stat.stat.exists"
  45. - name: Ensure Dendrite server key exists
  46. ansible.builtin.file:
  47. path: "{{ matrix_dendrite_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.pem"
  48. mode: 0644
  49. owner: "{{ matrix_user_username }}"
  50. group: "{{ matrix_user_groupname }}"
  51. - name: Ensure Dendrite configuration installed
  52. ansible.builtin.copy:
  53. content: "{{ matrix_dendrite_configuration | to_nice_yaml(indent=2, width=999999) }}"
  54. dest: "{{ matrix_dendrite_config_dir_path }}/dendrite.yaml"
  55. mode: 0644
  56. owner: "{{ matrix_user_username }}"
  57. group: "{{ matrix_user_groupname }}"
  58. - name: Ensure matrix-dendrite.service installed
  59. ansible.builtin.template:
  60. src: "{{ role_path }}/templates/dendrite/systemd/matrix-dendrite.service.j2"
  61. dest: "{{ matrix_systemd_path }}/matrix-dendrite.service"
  62. mode: 0644
  63. register: matrix_dendrite_systemd_service_result
  64. - name: Ensure systemd reloaded after matrix-dendrite.service installation
  65. ansible.builtin.service:
  66. daemon_reload: true
  67. when: "matrix_dendrite_systemd_service_result.changed | bool"
  68. - name: Ensure matrix-dendrite-create-account script created
  69. ansible.builtin.template:
  70. src: "{{ role_path }}/templates/dendrite/usr-local-bin/matrix-dendrite-create-account.j2"
  71. dest: "{{ matrix_local_bin_path }}/matrix-dendrite-create-account"
  72. mode: 0750