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

98 строки
4.4 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Ensure synapse-auto-compressor paths exist
  6. ansible.builtin.file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. when: item.when | bool
  13. with_items:
  14. - path: "{{ matrix_synapse_auto_compressor_base_path }}"
  15. when: true
  16. - path: "{{ matrix_synapse_auto_compressor_container_src_files_path }}"
  17. when: "{{ matrix_synapse_auto_compressor_container_image_self_build }}"
  18. - name: Ensure synapse-auto-compressor env file is installed
  19. ansible.builtin.template:
  20. src: "{{ role_path }}/templates/env.j2"
  21. dest: "{{ matrix_synapse_auto_compressor_base_path }}/env"
  22. mode: 0640
  23. owner: "{{ matrix_user_username }}"
  24. group: "{{ matrix_user_groupname }}"
  25. - name: Ensure synapse-auto-compressor workaround script is installed
  26. ansible.builtin.template:
  27. src: "{{ role_path }}/templates/matrix-synapse-auto-compressor-fix.sh.j2"
  28. dest: "{{ matrix_synapse_auto_compressor_base_path }}/matrix-synapse-auto-compressor-fix.sh"
  29. mode: 0750
  30. owner: "{{ matrix_user_username }}"
  31. group: "{{ matrix_user_groupname }}"
  32. - name: Ensure synapse-auto-compressor image is pulled
  33. community.docker.docker_image:
  34. name: "{{ matrix_synapse_auto_compressor_container_image }}"
  35. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  36. force_source: "{{ matrix_synapse_auto_compressor_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  37. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_synapse_auto_compressor_container_image_force_pull }}"
  38. when: "not matrix_synapse_auto_compressor_container_image_self_build | bool"
  39. register: result
  40. retries: "{{ devture_playbook_help_container_retries_count }}"
  41. delay: "{{ devture_playbook_help_container_retries_delay }}"
  42. until: result is not failed
  43. - when: "matrix_synapse_auto_compressor_container_image_self_build | bool"
  44. block:
  45. - name: Ensure synapse-auto-compressor repository is present on self-build
  46. ansible.builtin.git:
  47. repo: "{{ matrix_synapse_auto_compressor_container_image_self_build_repo }}"
  48. version: "{{ matrix_synapse_auto_compressor_container_image_self_build_version }}"
  49. dest: "{{ matrix_synapse_auto_compressor_container_src_files_path }}"
  50. force: "yes"
  51. become: true
  52. become_user: "{{ matrix_user_username }}"
  53. register: matrix_synapse_auto_compressor_git_pull_results
  54. - name: Check if synapse-auto-compressor image exists
  55. ansible.builtin.command: "{{ devture_systemd_docker_base_host_command_docker }} images --quiet --filter 'reference={{ matrix_synapse_auto_compressor_container_image }}'"
  56. register: matrix_synapse_auto_compressor_container_image_check_result
  57. changed_when: false
  58. # Invoking the `docker build` command here, instead of calling the `docker_image` Ansible module,
  59. # because the latter does not support BuildKit.
  60. # See: https://github.com/ansible-collections/community.general/issues/514
  61. - name: Ensure synapse-auto-compressor image is built
  62. ansible.builtin.shell:
  63. chdir: "{{ matrix_synapse_auto_compressor_container_src_files_path }}"
  64. cmd: |
  65. {{ devture_systemd_docker_base_host_command_docker }} build \
  66. -t "{{ matrix_synapse_auto_compressor_container_image }}" \
  67. -f Dockerfile \
  68. .
  69. environment:
  70. DOCKER_BUILDKIT: 1
  71. changed_when: true
  72. when: "matrix_synapse_auto_compressor_git_pull_results.changed | bool or matrix_synapse_auto_compressor_container_image_check_result.stdout == ''"
  73. - name: Ensure matrix-synapse-auto-compressor container network is created
  74. community.general.docker_network:
  75. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  76. name: "{{ matrix_synapse_auto_compressor_container_network }}"
  77. driver: bridge
  78. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  79. - name: Ensure matrix-synapse-auto-compressor systemd service and timer are installed
  80. ansible.builtin.template:
  81. src: "{{ role_path }}/templates/matrix-synapse-auto-compressor.{{ item }}.j2"
  82. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-auto-compressor.{{ item }}"
  83. mode: 0644
  84. with_items:
  85. - service
  86. - timer