Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

112 wiersze
4.3 KiB

  1. ---
  2. - name: Ensure maubot paths exist
  3. file:
  4. path: "{{ item.path }}"
  5. state: directory
  6. mode: 0755
  7. owner: "{{ matrix_user_username }}"
  8. group: "{{ matrix_user_groupname }}"
  9. with_items:
  10. - {path: "{{ matrix_bot_maubot_base_path }}", when: true}
  11. - {path: "{{ matrix_bot_maubot_data_path }}", when: true}
  12. - {path: "{{ matrix_bot_maubot_docker_src_files_path }}", when: true}
  13. when: "item.when|bool"
  14. - name: Ensure maubot configuration file created
  15. template:
  16. src: "{{ role_path }}/templates/config/config.yaml.j2"
  17. dest: "{{ matrix_bot_maubot_data_path }}/config.yaml"
  18. owner: "{{ matrix_user_username }}"
  19. group: "{{ matrix_user_groupname }}"
  20. mode: "u=rwx"
  21. - name: Generate Maubot proxying configuration for matrix-nginx-proxy
  22. set_fact:
  23. matrix_bot_maubot_matrix_nginx_proxy_configuration: |
  24. location ~ ^/(_matrix/maubot/.*) {
  25. {% if matrix_nginx_proxy_enabled|default(False) %}
  26. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  27. resolver 127.0.0.11 valid=5s;
  28. set $backend "matrix-maubot:{{ matrix_bot_maubot_port }}/$1";
  29. proxy_pass http://$backend;
  30. proxy_set_header Upgrade $http_upgrade;
  31. proxy_set_header Connection "upgrade";
  32. {% else %}
  33. {# Generic configuration for use outside of our container setup #}
  34. proxy_pass http://127.0.0.1:{{ matrix_bot_maubot_port }}/$1;
  35. proxy_set_header Upgrade $http_upgrade;
  36. proxy_set_header Connection "upgrade";
  37. {% endif %}
  38. }
  39. - name: Register Maubot's proxying configuration with matrix-nginx-proxy
  40. set_fact:
  41. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  42. {{
  43. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  44. +
  45. [matrix_bot_maubot_matrix_nginx_proxy_configuration]
  46. }}
  47. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  48. debug:
  49. msg: >-
  50. NOTE: You've enabled Maubot but are not using the matrix-nginx-proxy
  51. reverse proxy.
  52. Please make sure that you're proxying the `/_matrix/maubot`
  53. URL endpoint to the matrix-maubot container.
  54. when: "matrix_bot_maubot_enabled|bool and matrix_nginx_proxy_enabled is not defined"
  55. - name: Ensure maubot image is pulled
  56. docker_image:
  57. name: "{{ matrix_bot_maubot_docker_image }}"
  58. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  59. force_source: "{{ matrix_bot_maubot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  60. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_maubot_docker_image_force_pull }}"
  61. when: "not matrix_bot_maubot_container_image_self_build|bool"
  62. register: result
  63. retries: "{{ matrix_container_retries_count }}"
  64. delay: "{{ matrix_container_retries_delay }}"
  65. until: result is not failed
  66. - name: Ensure maubot repository is present on self-build
  67. git:
  68. repo: "{{ matrix_bot_maubot_docker_repo }}"
  69. dest: "{{ matrix_bot_maubot_docker_src_files_path }}"
  70. force: "yes"
  71. become: true
  72. become_user: "{{ matrix_user_username }}"
  73. register: matrix_bot_maubot_git_pull_results
  74. when: "matrix_bot_maubot_container_image_self_build|bool"
  75. - name: Ensure maubot image is built
  76. docker_image:
  77. name: "{{ matrix_bot_maubot_docker_image }}"
  78. source: build
  79. force_source: "{{ matrix_bot_maubot_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  80. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_mailer_git_pull_results.changed }}"
  81. build:
  82. dockerfile: Dockerfile
  83. path: "{{ matrix_bot_maubot_docker_src_files_path }}"
  84. pull: true
  85. when: "matrix_bot_maubot_container_image_self_build|bool"
  86. - name: Ensure matrix-maubot.service installed
  87. template:
  88. src: "{{ role_path }}/templates/systemd/matrix-maubot.service.j2"
  89. dest: "{{ matrix_systemd_path }}/matrix-maubot.service"
  90. mode: 0644
  91. register: matrix_bot_maubot_systemd_service_result
  92. - name: Ensure systemd reloaded after matrix-maubot.service installation
  93. service:
  94. daemon_reload: true
  95. when: "matrix_bot_maubot_systemd_service_result.changed|bool"
  96. - name: Ensure matrix-maubot.service restarted, if necessary
  97. service:
  98. name: "matrix-maubot.service"
  99. state: restarted