Matrix Docker Ansible eploy
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

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