Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

105 lignes
4.9 KiB

  1. # SPDX-FileCopyrightText: 2024 David Mehren
  2. # SPDX-FileCopyrightText: 2024 MDAD project contributors
  3. # SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  4. # SPDX-FileCopyrightText: 2024 Suguru Hirahara
  5. #
  6. # SPDX-License-Identifier: AGPL-3.0-or-later
  7. ---
  8. - ansible.builtin.set_fact:
  9. matrix_appservice_draupnir_for_all_requires_restart: false
  10. - name: Ensure matrix-appservice-draupnir-for-all paths exist
  11. ansible.builtin.file:
  12. path: "{{ item.path }}"
  13. state: directory
  14. mode: 0750
  15. owner: "{{ matrix_user_username }}"
  16. group: "{{ matrix_user_groupname }}"
  17. with_items:
  18. - {path: "{{ matrix_appservice_draupnir_for_all_base_path }}", when: true}
  19. - {path: "{{ matrix_appservice_draupnir_for_all_config_path }}", when: true}
  20. - {path: "{{ matrix_appservice_draupnir_for_all_data_path }}", when: true}
  21. - {path: "{{ matrix_appservice_draupnir_for_all_docker_src_files_path }}", when: "{{ matrix_appservice_draupnir_for_all_container_image_self_build }}"}
  22. when: "item.when | bool"
  23. - name: Ensure Draupnir Docker image is pulled
  24. community.docker.docker_image:
  25. name: "{{ matrix_appservice_draupnir_for_all_docker_image }}"
  26. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  27. force_source: "{{ matrix_appservice_draupnir_for_all_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  28. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_draupnir_for_all_docker_image_force_pull }}"
  29. when: "not matrix_appservice_draupnir_for_all_container_image_self_build | bool"
  30. register: result
  31. retries: "{{ devture_playbook_help_container_retries_count }}"
  32. delay: "{{ devture_playbook_help_container_retries_delay }}"
  33. until: result is not failed
  34. - name: Ensure Draupnir repository is present on self-build
  35. ansible.builtin.git:
  36. repo: "{{ matrix_appservice_draupnir_for_all_container_image_self_build_repo }}"
  37. dest: "{{ matrix_appservice_draupnir_for_all_docker_src_files_path }}"
  38. version: "{{ matrix_appservice_draupnir_for_all_docker_image.split(':')[1] }}"
  39. force: "yes"
  40. become: true
  41. become_user: "{{ matrix_user_username }}"
  42. register: matrix_appservice_draupnir_for_all_git_pull_results
  43. when: "matrix_appservice_draupnir_for_all_container_image_self_build | bool"
  44. - name: Ensure Draupnir Docker image is built
  45. community.docker.docker_image:
  46. name: "{{ matrix_appservice_draupnir_for_all_docker_image }}"
  47. source: build
  48. force_source: "{{ matrix_appservice_draupnir_for_all_git_pull_results.changed }}"
  49. build:
  50. dockerfile: Dockerfile
  51. path: "{{ matrix_appservice_draupnir_for_all_docker_src_files_path }}"
  52. pull: true
  53. when: "matrix_appservice_draupnir_for_all_container_image_self_build | bool"
  54. - name: Ensure matrix-appservice-draupnir-for-all appservice config installed
  55. ansible.builtin.copy:
  56. content: "{{ matrix_appservice_draupnir_for_all_configuration_appservice | to_nice_yaml(indent=2, width=999999) }}"
  57. dest: "{{ matrix_appservice_draupnir_for_all_config_path }}/production-appservice.yaml"
  58. mode: 0644
  59. owner: "{{ matrix_user_username }}"
  60. group: "{{ matrix_user_groupname }}"
  61. - name: Ensure matrix-appservice-draupnir-for-all bot config installed
  62. ansible.builtin.copy:
  63. content: "{{ matrix_appservice_draupnir_for_all_configuration | to_nice_yaml(indent=2, width=999999) }}"
  64. dest: "{{ matrix_appservice_draupnir_for_all_config_path }}/production-bots.yaml"
  65. mode: 0644
  66. owner: "{{ matrix_user_username }}"
  67. group: "{{ matrix_user_groupname }}"
  68. - name: Ensure matrix-appservice-draupnir-for-all registration.yaml installed
  69. ansible.builtin.copy:
  70. content: "{{ matrix_appservice_draupnir_for_all_registration | to_nice_yaml(indent=2, width=999999) }}"
  71. dest: "{{ matrix_appservice_draupnir_for_all_config_path }}/draupnir-for-all-registration.yaml"
  72. mode: 0644
  73. owner: "{{ matrix_user_username }}"
  74. group: "{{ matrix_user_groupname }}"
  75. - name: Ensure matrix-appservice-draupnir-for-all container network is created
  76. community.general.docker_network:
  77. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  78. name: "{{ matrix_appservice_draupnir_for_all_container_network }}"
  79. driver: bridge
  80. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  81. - name: Ensure matrix-appservice-draupnir-for-all.service installed
  82. ansible.builtin.template:
  83. src: "{{ role_path }}/templates/systemd/matrix-appservice-draupnir-for-all.service.j2"
  84. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-appservice-draupnir-for-all.service"
  85. mode: 0644
  86. register: matrix_appservice_draupnir_for_all_systemd_service_result
  87. - name: Ensure matrix-appservice-draupnir-for-all.service restarted, if necessary
  88. ansible.builtin.service:
  89. name: "matrix-appservice-draupnir-for-all.service"
  90. state: restarted
  91. daemon_reload: true
  92. when: "matrix_appservice_draupnir_for_all_requires_restart | bool"