Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

100 行
4.5 KiB

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