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.
 
 

116 lignes
4.8 KiB

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