Matrix Docker Ansible eploy
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

113 Zeilen
5.3 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. register: matrix_synapse_auto_compressor_config_env_result
  28. - name: Ensure synapse-auto-compressor workaround script is installed
  29. ansible.builtin.template:
  30. src: "{{ role_path }}/templates/matrix-synapse-auto-compressor-fix.sh.j2"
  31. dest: "{{ matrix_synapse_auto_compressor_base_path }}/matrix-synapse-auto-compressor-fix.sh"
  32. mode: 0750
  33. owner: "{{ matrix_user_name }}"
  34. group: "{{ matrix_group_name }}"
  35. register: matrix_synapse_auto_compressor_config_script_result
  36. - name: Ensure synapse-auto-compressor image is pulled
  37. community.docker.docker_image:
  38. name: "{{ matrix_synapse_auto_compressor_container_image }}"
  39. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  40. force_source: "{{ matrix_synapse_auto_compressor_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  41. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_synapse_auto_compressor_container_image_force_pull }}"
  42. when: "not matrix_synapse_auto_compressor_container_image_self_build | bool"
  43. register: matrix_synapse_auto_compressor_container_image_pull_result
  44. retries: "{{ devture_playbook_help_container_retries_count }}"
  45. delay: "{{ devture_playbook_help_container_retries_delay }}"
  46. until: matrix_synapse_auto_compressor_container_image_pull_result is not failed
  47. - when: "matrix_synapse_auto_compressor_container_image_self_build | bool"
  48. block:
  49. - name: Ensure synapse-auto-compressor repository is present on self-build
  50. ansible.builtin.git:
  51. repo: "{{ matrix_synapse_auto_compressor_container_image_self_build_repo }}"
  52. version: "{{ matrix_synapse_auto_compressor_container_image_self_build_version }}"
  53. dest: "{{ matrix_synapse_auto_compressor_container_src_files_path }}"
  54. force: "yes"
  55. become: true
  56. become_user: "{{ matrix_user_name }}"
  57. register: matrix_synapse_auto_compressor_git_pull_results
  58. - name: Check if synapse-auto-compressor image exists
  59. ansible.builtin.command: "{{ devture_systemd_docker_base_host_command_docker }} images --quiet --filter 'reference={{ matrix_synapse_auto_compressor_container_image }}'"
  60. register: matrix_synapse_auto_compressor_container_image_check_result
  61. changed_when: false
  62. # Invoking the `docker build` command here, instead of calling the `docker_image` Ansible module,
  63. # because the latter does not support BuildKit.
  64. # See: https://github.com/ansible-collections/community.general/issues/514
  65. - name: Ensure synapse-auto-compressor image is built
  66. ansible.builtin.shell:
  67. chdir: "{{ matrix_synapse_auto_compressor_container_src_files_path }}"
  68. cmd: |
  69. {{ devture_systemd_docker_base_host_command_docker }} build \
  70. -t "{{ matrix_synapse_auto_compressor_container_image }}" \
  71. -f Dockerfile \
  72. .
  73. environment:
  74. DOCKER_BUILDKIT: 1
  75. changed_when: true
  76. when: "matrix_synapse_auto_compressor_git_pull_results.changed | bool or matrix_synapse_auto_compressor_container_image_check_result.stdout == ''"
  77. - name: Ensure matrix-synapse-auto-compressor container network is created
  78. community.general.docker_network:
  79. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  80. name: "{{ matrix_synapse_auto_compressor_container_network }}"
  81. driver: bridge
  82. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  83. - name: Ensure matrix-synapse-auto-compressor systemd service and timer are installed
  84. ansible.builtin.template:
  85. src: "{{ role_path }}/templates/matrix-synapse-auto-compressor.{{ item }}.j2"
  86. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-synapse-auto-compressor.{{ item }}"
  87. mode: 0644
  88. with_items:
  89. - service
  90. - timer
  91. register: matrix_synapse_auto_compressor_systemd_service_result
  92. - name: Determine whether synapse-auto-compressor needs a restart
  93. ansible.builtin.set_fact:
  94. matrix_synapse_auto_compressor_restart_necessary: >-
  95. {{
  96. matrix_synapse_auto_compressor_config_env_result.changed | default(false)
  97. or matrix_synapse_auto_compressor_config_script_result.changed | default(false)
  98. or matrix_synapse_auto_compressor_systemd_service_result.changed | default(false)
  99. or matrix_synapse_auto_compressor_container_image_pull_result.changed | default(false)
  100. }}