Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

144 lines
6.2 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. - name: Ensure Beeper LINE repository is present on self-build
  53. ansible.builtin.git:
  54. repo: "{{ matrix_bridge_beeper_line_container_image_self_build_repo }}"
  55. dest: "{{ matrix_bridge_beeper_line_container_src_files_path }}"
  56. version: "{{ matrix_bridge_beeper_line_container_image_self_build_branch }}"
  57. force: "yes"
  58. become: true
  59. become_user: "{{ matrix_user_name }}"
  60. register: matrix_bridge_beeper_line_git_pull_results
  61. when: "matrix_bridge_beeper_line_container_image_self_build | bool"
  62. - name: Ensure Beeper LINE Docker image is built
  63. community.docker.docker_image_build:
  64. name: "{{ matrix_bridge_beeper_line_container_image }}"
  65. dockerfile: Dockerfile
  66. path: "{{ matrix_bridge_beeper_line_container_src_files_path }}"
  67. pull: true
  68. rebuild: "{{ 'always' if matrix_bridge_beeper_line_git_pull_results.changed | bool else 'never' }}"
  69. when: "matrix_bridge_beeper_line_container_image_self_build | bool"
  70. register: matrix_bridge_beeper_line_container_image_build_result
  71. - name: Ensure beeper-line config.yaml installed
  72. ansible.builtin.copy:
  73. content: "{{ matrix_bridge_beeper_line_configuration | to_nice_yaml(indent=2, width=999999) }}"
  74. dest: "{{ matrix_bridge_beeper_line_config_path }}/config.yaml"
  75. mode: '0644'
  76. owner: "{{ matrix_user_name }}"
  77. group: "{{ matrix_group_name }}"
  78. register: matrix_bridge_beeper_line_config_result
  79. - name: Ensure beeper-line registration.yaml installed
  80. ansible.builtin.copy:
  81. content: "{{ matrix_bridge_beeper_line_registration | to_nice_yaml(indent=2, width=999999) }}"
  82. dest: "{{ matrix_bridge_beeper_line_config_path }}/registration.yaml"
  83. mode: '0644'
  84. owner: "{{ matrix_user_name }}"
  85. group: "{{ matrix_group_name }}"
  86. register: matrix_bridge_beeper_line_registration_result
  87. - name: Ensure matrix-beeper-line.service installed
  88. ansible.builtin.template:
  89. src: "{{ role_path }}/templates/systemd/matrix-beeper-line.service.j2"
  90. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-beeper-line.service"
  91. mode: '0644'
  92. register: matrix_bridge_beeper_line_systemd_service_result
  93. - name: Ensure beeper-line support files installed
  94. ansible.builtin.template:
  95. src: "{{ role_path }}/templates/{{ item }}.j2"
  96. dest: "{{ matrix_bridge_beeper_line_base_path }}/{{ item }}"
  97. mode: '0640'
  98. owner: "{{ matrix_user_name }}"
  99. group: "{{ matrix_group_name }}"
  100. with_items:
  101. - labels
  102. register: matrix_bridge_beeper_line_support_files_result
  103. - name: Ensure matrix-beeper-line container network is created
  104. when: matrix_bridge_beeper_line_container_network != 'host'
  105. community.general.docker_network:
  106. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  107. name: "{{ matrix_bridge_beeper_line_container_network }}"
  108. driver: bridge
  109. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  110. - name: Determine whether matrix-beeper-line needs a restart
  111. ansible.builtin.set_fact:
  112. matrix_bridge_beeper_line_restart_necessary: >-
  113. {{
  114. matrix_bridge_beeper_line_migration_requires_restart | default(false)
  115. or matrix_bridge_beeper_line_config_result.changed | default(false)
  116. or matrix_bridge_beeper_line_registration_result.changed | default(false)
  117. or matrix_bridge_beeper_line_support_files_result.changed | default(false)
  118. or matrix_bridge_beeper_line_systemd_service_result.changed | default(false)
  119. or matrix_bridge_beeper_line_container_image_pull_result.changed | default(false)
  120. or matrix_bridge_beeper_line_container_image_build_result.changed | default(false)
  121. }}
  122. - name: Ensure matrix-beeper-line.service restarted, if necessary
  123. ansible.builtin.service:
  124. name: "matrix-beeper-line.service"
  125. state: restarted
  126. daemon_reload: true
  127. when: "matrix_bridge_beeper_line_migration_requires_restart | bool"