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.
 
 

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