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

85 строки
3.9 KiB

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