Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

119 satır
4.9 KiB

  1. # SPDX-FileCopyrightText: 2022 - 2024 Nikita Chernyi
  2. # SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev
  3. # SPDX-FileCopyrightText: 2022 MDAD project contributors
  4. # SPDX-FileCopyrightText: 2022 Marko Weltzer
  5. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  6. # SPDX-FileCopyrightText: 2024 David Mehren
  7. # SPDX-FileCopyrightText: 2024 Suguru Hirahara
  8. #
  9. # SPDX-License-Identifier: AGPL-3.0-or-later
  10. ---
  11. - ansible.builtin.set_fact:
  12. matrix_bot_honoroit_requires_restart: false
  13. - when: "matrix_bot_honoroit_database_engine == 'postgres'"
  14. block:
  15. - name: Check if an SQLite database already exists
  16. ansible.builtin.stat:
  17. path: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
  18. register: matrix_bot_honoroit_sqlite_database_path_local_stat_result
  19. - when: "matrix_bot_honoroit_sqlite_database_path_local_stat_result.stat.exists | bool"
  20. block:
  21. - ansible.builtin.include_role:
  22. name: galaxy/postgres
  23. tasks_from: migrate_db_to_postgres
  24. vars:
  25. postgres_db_migration_request:
  26. src: "{{ matrix_bot_honoroit_sqlite_database_path_local }}"
  27. dst: "{{ matrix_bot_honoroit_database_connection_string }}"
  28. caller: "{{ role_path | basename }}"
  29. engine_variable_name: 'matrix_bot_honoroit_database_engine'
  30. engine_old: 'sqlite'
  31. systemd_services_to_stop: ['matrix-bot-honoroit.service']
  32. - ansible.builtin.set_fact:
  33. matrix_bot_honoroit_requires_restart: true
  34. - name: Ensure Honoroit paths exist
  35. ansible.builtin.file:
  36. path: "{{ item.path }}"
  37. state: directory
  38. mode: 0750
  39. owner: "{{ matrix_user_username }}"
  40. group: "{{ matrix_user_groupname }}"
  41. with_items:
  42. - {path: "{{ matrix_bot_honoroit_config_path }}", when: true}
  43. - {path: "{{ matrix_bot_honoroit_data_path }}", when: true}
  44. - {path: "{{ matrix_bot_honoroit_data_store_path }}", when: true}
  45. - {path: "{{ matrix_bot_honoroit_docker_src_files_path }}", when: true}
  46. when: "item.when | bool"
  47. - name: Ensure Honoroit support files installed
  48. ansible.builtin.template:
  49. src: "{{ role_path }}/templates/{{ item }}.j2"
  50. dest: "{{ matrix_bot_honoroit_config_path }}/{{ item }}"
  51. owner: "{{ matrix_user_username }}"
  52. group: "{{ matrix_user_groupname }}"
  53. mode: 0640
  54. with_items:
  55. - env
  56. - labels
  57. - name: Ensure Honoroit image is pulled
  58. community.docker.docker_image:
  59. name: "{{ matrix_bot_honoroit_docker_image }}"
  60. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  61. force_source: "{{ matrix_bot_honoroit_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  62. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_honoroit_docker_image_force_pull }}"
  63. when: "not matrix_bot_honoroit_container_image_self_build | bool"
  64. register: result
  65. retries: "{{ devture_playbook_help_container_retries_count }}"
  66. delay: "{{ devture_playbook_help_container_retries_delay }}"
  67. until: result is not failed
  68. - name: Ensure Honoroit repository is present on self-build
  69. ansible.builtin.git:
  70. repo: "{{ matrix_bot_honoroit_docker_repo }}"
  71. version: "{{ matrix_bot_honoroit_docker_repo_version }}"
  72. dest: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  73. force: "yes"
  74. become: true
  75. become_user: "{{ matrix_user_username }}"
  76. register: matrix_bot_honoroit_git_pull_results
  77. when: "matrix_bot_honoroit_container_image_self_build | bool"
  78. - name: Ensure Honoroit image is built
  79. community.docker.docker_image:
  80. name: "{{ matrix_bot_honoroit_docker_image }}"
  81. source: build
  82. force_source: "{{ matrix_bot_honoroit_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  83. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_honoroit_container_image_self_build.changed }}"
  84. build:
  85. dockerfile: Dockerfile
  86. path: "{{ matrix_bot_honoroit_docker_src_files_path }}"
  87. pull: true
  88. when: "matrix_bot_honoroit_container_image_self_build | bool"
  89. - name: Ensure Honoroit container network is created
  90. community.general.docker_network:
  91. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  92. name: "{{ matrix_bot_honoroit_container_network }}"
  93. driver: bridge
  94. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  95. - name: Ensure matrix-bot-honoroit.service installed
  96. ansible.builtin.template:
  97. src: "{{ role_path }}/templates/systemd/matrix-bot-honoroit.service.j2"
  98. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-honoroit.service"
  99. mode: 0644
  100. register: matrix_bot_honoroit_systemd_service_result
  101. - name: Ensure matrix-bot-honoroit.service restarted, if necessary
  102. ansible.builtin.service:
  103. name: "matrix-bot-honoroit.service"
  104. state: restarted
  105. daemon_reload: true
  106. when: "matrix_bot_honoroit_requires_restart | bool"