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

154 строки
6.7 KiB

  1. # SPDX-FileCopyrightText: 2026 MDAD project contributors
  2. # SPDX-FileCopyrightText: 2026 Nikita Chernyi
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - ansible.builtin.set_fact:
  7. matrix_bridge_beeper_line_migration_requires_restart: false
  8. - when: "matrix_bridge_beeper_line_database_engine == 'postgres'"
  9. block:
  10. - name: Check if an SQLite database already exists
  11. ansible.builtin.stat:
  12. path: "{{ matrix_bridge_beeper_line_sqlite_database_path_local }}"
  13. register: matrix_bridge_beeper_line_sqlite_database_path_local_stat_result
  14. - when: "matrix_bridge_beeper_line_sqlite_database_path_local_stat_result.stat.exists | bool"
  15. block:
  16. - ansible.builtin.include_role:
  17. name: galaxy/postgres
  18. tasks_from: migrate_db_to_postgres
  19. vars:
  20. postgres_db_migration_request:
  21. src: "{{ matrix_bridge_beeper_line_sqlite_database_path_local }}"
  22. dst: "{{ matrix_bridge_beeper_line_database_connection_string }}"
  23. caller: "{{ role_path | basename }}"
  24. engine_variable_name: 'matrix_bridge_beeper_line_database_engine'
  25. engine_old: 'sqlite'
  26. systemd_services_to_stop: ['matrix-beeper-line.service']
  27. pgloader_options: ['--with "quote identifiers"']
  28. - ansible.builtin.set_fact:
  29. matrix_bridge_beeper_line_migration_requires_restart: true
  30. - name: Ensure Beeper LINE paths exist
  31. ansible.builtin.file:
  32. path: "{{ item.path }}"
  33. state: directory
  34. mode: '0750'
  35. owner: "{{ matrix_user_name }}"
  36. group: "{{ matrix_group_name }}"
  37. with_items:
  38. - {path: "{{ matrix_bridge_beeper_line_base_path }}", when: true}
  39. - {path: "{{ matrix_bridge_beeper_line_config_path }}", when: true}
  40. - {path: "{{ matrix_bridge_beeper_line_data_path }}", when: true}
  41. - {path: "{{ matrix_bridge_beeper_line_container_src_files_path }}", when: "{{ matrix_bridge_beeper_line_container_image_self_build }}"}
  42. when: item.when | bool
  43. - name: Ensure Beeper LINE image is pulled
  44. community.docker.docker_image_pull:
  45. name: "{{ matrix_bridge_beeper_line_container_image }}"
  46. pull: always
  47. when: not matrix_bridge_beeper_line_container_image_self_build
  48. register: matrix_bridge_beeper_line_container_image_pull_result
  49. retries: "{{ devture_playbook_help_container_retries_count }}"
  50. delay: "{{ devture_playbook_help_container_retries_delay }}"
  51. until: matrix_bridge_beeper_line_container_image_pull_result is not failed
  52. # A checkout owned by a different user (a uid change, an earlier clone by another user, etc.) would make the git task below fail on ownership or permissions.
  53. - name: Ensure Beeper LINE repository ownership is correct on self-build
  54. ansible.builtin.file:
  55. path: "{{ matrix_bridge_beeper_line_container_src_files_path }}"
  56. state: directory
  57. owner: "{{ matrix_user_name }}"
  58. group: "{{ matrix_group_name }}"
  59. recurse: true
  60. when: "matrix_bridge_beeper_line_container_image_self_build | bool"
  61. - name: Ensure Beeper LINE repository is present on self-build
  62. ansible.builtin.git:
  63. repo: "{{ matrix_bridge_beeper_line_container_image_self_build_repo }}"
  64. dest: "{{ matrix_bridge_beeper_line_container_src_files_path }}"
  65. version: "{{ matrix_bridge_beeper_line_container_image_self_build_branch }}"
  66. force: "yes"
  67. become: true
  68. become_user: "{{ matrix_user_name }}"
  69. register: matrix_bridge_beeper_line_git_pull_results
  70. when: "matrix_bridge_beeper_line_container_image_self_build | bool"
  71. - name: Ensure Beeper LINE Docker image is built
  72. community.docker.docker_image_build:
  73. name: "{{ matrix_bridge_beeper_line_container_image }}"
  74. dockerfile: Dockerfile
  75. path: "{{ matrix_bridge_beeper_line_container_src_files_path }}"
  76. pull: true
  77. rebuild: "{{ 'always' if matrix_bridge_beeper_line_git_pull_results.changed | bool else 'never' }}"
  78. when: "matrix_bridge_beeper_line_container_image_self_build | bool"
  79. register: matrix_bridge_beeper_line_container_image_build_result
  80. - name: Ensure beeper-line config.yaml installed
  81. ansible.builtin.copy:
  82. content: "{{ matrix_bridge_beeper_line_configuration | to_nice_yaml(indent=2, width=999999) }}"
  83. dest: "{{ matrix_bridge_beeper_line_config_path }}/config.yaml"
  84. mode: '0644'
  85. owner: "{{ matrix_user_name }}"
  86. group: "{{ matrix_group_name }}"
  87. register: matrix_bridge_beeper_line_config_result
  88. - name: Ensure beeper-line registration.yaml installed
  89. ansible.builtin.copy:
  90. content: "{{ matrix_bridge_beeper_line_registration | to_nice_yaml(indent=2, width=999999) }}"
  91. dest: "{{ matrix_bridge_beeper_line_config_path }}/registration.yaml"
  92. mode: '0644'
  93. owner: "{{ matrix_user_name }}"
  94. group: "{{ matrix_group_name }}"
  95. register: matrix_bridge_beeper_line_registration_result
  96. - name: Ensure matrix-beeper-line.service installed
  97. ansible.builtin.template:
  98. src: "{{ role_path }}/templates/systemd/matrix-beeper-line.service.j2"
  99. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-beeper-line.service"
  100. mode: '0644'
  101. register: matrix_bridge_beeper_line_systemd_service_result
  102. - name: Ensure beeper-line support files installed
  103. ansible.builtin.template:
  104. src: "{{ role_path }}/templates/{{ item }}.j2"
  105. dest: "{{ matrix_bridge_beeper_line_base_path }}/{{ item }}"
  106. mode: '0640'
  107. owner: "{{ matrix_user_name }}"
  108. group: "{{ matrix_group_name }}"
  109. with_items:
  110. - labels
  111. register: matrix_bridge_beeper_line_support_files_result
  112. - name: Ensure matrix-beeper-line container network is created
  113. when: matrix_bridge_beeper_line_container_network != 'host'
  114. community.general.docker_network:
  115. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  116. name: "{{ matrix_bridge_beeper_line_container_network }}"
  117. driver: bridge
  118. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  119. - name: Determine whether matrix-beeper-line needs a restart
  120. ansible.builtin.set_fact:
  121. matrix_bridge_beeper_line_restart_necessary: >-
  122. {{
  123. matrix_bridge_beeper_line_migration_requires_restart | default(false)
  124. or matrix_bridge_beeper_line_config_result.changed | default(false)
  125. or matrix_bridge_beeper_line_registration_result.changed | default(false)
  126. or matrix_bridge_beeper_line_support_files_result.changed | default(false)
  127. or matrix_bridge_beeper_line_systemd_service_result.changed | default(false)
  128. or matrix_bridge_beeper_line_container_image_pull_result.changed | default(false)
  129. or matrix_bridge_beeper_line_container_image_build_result.changed | default(false)
  130. }}
  131. - name: Ensure matrix-beeper-line.service restarted, if necessary
  132. ansible.builtin.service:
  133. name: "matrix-beeper-line.service"
  134. state: restarted
  135. daemon_reload: true
  136. when: "matrix_bridge_beeper_line_migration_requires_restart | bool"