Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

113 строки
4.6 KiB

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