Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

93 rivejä
3.6 KiB

  1. ---
  2. - name: Ensure Dendrite paths exist
  3. ansible.builtin.file:
  4. path: "{{ item }}"
  5. state: directory
  6. mode: 0750
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_groupname }}"
  9. with_items:
  10. - "{{ matrix_dendrite_config_dir_path }}"
  11. - "{{ matrix_dendrite_bin_path }}"
  12. - "{{ matrix_dendrite_ext_path }}"
  13. - "{{ matrix_dendrite_nats_storage_path }}"
  14. # This will throw a Permission Denied error if already mounted using fuse
  15. - name: Check Dendrite media store path
  16. ansible.builtin.stat:
  17. path: "{{ matrix_dendrite_media_store_path }}"
  18. register: local_path_media_store_stat
  19. ignore_errors: true
  20. # This is separate and conditional, to ensure we don't execute it
  21. # if the path already exists or we failed to check, because it's mounted using fuse.
  22. - name: Ensure Dendrite media store path exists
  23. ansible.builtin.file:
  24. path: "{{ matrix_dendrite_media_store_path }}"
  25. state: directory
  26. mode: 0750
  27. owner: "{{ matrix_user_username }}"
  28. group: "{{ matrix_user_groupname }}"
  29. when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"
  30. - name: Ensure Dendrite Docker image is pulled
  31. community.docker.docker_image:
  32. name: "{{ matrix_dendrite_docker_image }}"
  33. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  34. force_source: "{{ matrix_dendrite_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  35. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_dendrite_docker_image_force_pull }}"
  36. register: result
  37. retries: "{{ devture_playbook_help_container_retries_count }}"
  38. delay: "{{ devture_playbook_help_container_retries_delay }}"
  39. until: result is not failed
  40. # We do this so that the signing key would get generated.
  41. # We don't use the `docker_container` module, because using it with `cap_drop` requires
  42. # a very recent version, which is not available for a lot of people yet.
  43. - name: Generate Dendrite signing key
  44. ansible.builtin.command:
  45. cmd: |
  46. docker run
  47. --rm
  48. --name=matrix-dendrite-config
  49. --entrypoint=generate-keys
  50. --mount type=bind,src={{ matrix_dendrite_config_dir_path }},dst=/data
  51. {{ matrix_dendrite_docker_image }} --private-key=/data/{{ matrix_server_fqn_matrix }}.signing.pem
  52. generate
  53. creates: "{{ matrix_dendrite_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.pem"
  54. - name: Ensure Dendrite server key exists
  55. ansible.builtin.file:
  56. path: "{{ matrix_dendrite_config_dir_path }}/{{ matrix_server_fqn_matrix }}.signing.pem"
  57. mode: 0644
  58. owner: "{{ matrix_user_username }}"
  59. group: "{{ matrix_user_groupname }}"
  60. - name: Ensure Dendrite configuration installed
  61. ansible.builtin.copy:
  62. content: "{{ matrix_dendrite_configuration | to_nice_yaml(indent=2, width=999999) }}"
  63. dest: "{{ matrix_dendrite_config_dir_path }}/dendrite.yaml"
  64. mode: 0644
  65. owner: "{{ matrix_user_username }}"
  66. group: "{{ matrix_user_groupname }}"
  67. - name: Ensure Dendrite container network is created
  68. community.general.docker_network:
  69. name: "{{ matrix_dendrite_container_network }}"
  70. driver: bridge
  71. - name: Ensure matrix-dendrite.service installed
  72. ansible.builtin.template:
  73. src: "{{ role_path }}/templates/dendrite/systemd/matrix-dendrite.service.j2"
  74. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-dendrite.service"
  75. mode: 0644
  76. - name: Ensure Dendrite scripts created
  77. ansible.builtin.template:
  78. src: "{{ role_path }}/templates/dendrite/bin/{{ item }}.j2"
  79. dest: "{{ matrix_dendrite_bin_path }}/{{ item }}"
  80. mode: 0750
  81. with_items:
  82. - create-account