Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.6 KiB

  1. # SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2022 MDAD project contributors
  3. # SPDX-FileCopyrightText: 2022 Marko Weltzer
  4. # SPDX-FileCopyrightText: 2022 Nikita Chernyi
  5. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  6. # SPDX-FileCopyrightText: 2024 David Mehren
  7. #
  8. # SPDX-License-Identifier: AGPL-3.0-or-later
  9. ---
  10. - name: Ensure Cinny paths exists
  11. ansible.builtin.file:
  12. path: "{{ item.path }}"
  13. state: directory
  14. mode: 0750
  15. owner: "{{ matrix_user_name }}"
  16. group: "{{ matrix_group_name }}"
  17. with_items:
  18. - {path: "{{ matrix_client_cinny_data_path }}", when: true}
  19. - {path: "{{ matrix_client_cinny_docker_src_files_path }}", when: "{{ matrix_client_cinny_container_image_self_build }}"}
  20. when: "item.when | bool"
  21. - name: Ensure Cinny Docker image is pulled
  22. community.docker.docker_image:
  23. name: "{{ matrix_client_cinny_docker_image }}"
  24. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  25. force_source: "{{ matrix_client_cinny_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  26. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_client_cinny_docker_image_force_pull }}"
  27. when: "not matrix_client_cinny_container_image_self_build | bool"
  28. register: result
  29. retries: "{{ devture_playbook_help_container_retries_count }}"
  30. delay: "{{ devture_playbook_help_container_retries_delay }}"
  31. until: result is not failed
  32. - name: Ensure Cinny repository is present on self-build
  33. ansible.builtin.git:
  34. repo: "{{ matrix_client_cinny_container_image_self_build_repo }}"
  35. dest: "{{ matrix_client_cinny_docker_src_files_path }}"
  36. version: "{{ matrix_client_cinny_docker_image.split(':')[1] }}"
  37. force: "yes"
  38. become: true
  39. become_user: "{{ matrix_user_name }}"
  40. register: matrix_client_cinny_git_pull_results
  41. when: "matrix_client_cinny_container_image_self_build | bool"
  42. - name: Ensure Cinny configuration installed
  43. ansible.builtin.copy:
  44. content: "{{ matrix_client_cinny_configuration | to_nice_json }}"
  45. dest: "{{ matrix_client_cinny_data_path }}/config.json"
  46. mode: 0644
  47. owner: "{{ matrix_user_name }}"
  48. group: "{{ matrix_group_name }}"
  49. - name: Ensure Cinny additional config files installed
  50. ansible.builtin.template:
  51. src: "{{ item.src }}"
  52. dest: "{{ matrix_client_cinny_data_path }}/{{ item.name }}"
  53. mode: 0644
  54. owner: "{{ matrix_user_name }}"
  55. group: "{{ matrix_group_name }}"
  56. with_items:
  57. - {src: "{{ role_path }}/templates/nginx.conf.j2", name: "nginx.conf"}
  58. - {src: "{{ role_path }}/templates/labels.j2", name: "labels"}
  59. - name: Ensure Cinny Docker image is built
  60. community.docker.docker_image:
  61. name: "{{ matrix_client_cinny_docker_image }}"
  62. source: build
  63. force_source: "{{ matrix_client_cinny_git_pull_results.changed }}"
  64. build:
  65. dockerfile: Dockerfile
  66. path: "{{ matrix_client_cinny_docker_src_files_path }}"
  67. pull: true
  68. when: "matrix_client_cinny_container_image_self_build | bool"
  69. - name: Ensure Cinny container network is created
  70. community.general.docker_network:
  71. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  72. name: "{{ matrix_client_cinny_container_network }}"
  73. driver: bridge
  74. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  75. - name: Ensure matrix-client-cinny.service installed
  76. ansible.builtin.template:
  77. src: "{{ role_path }}/templates/systemd/matrix-client-cinny.service.j2"
  78. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-client-cinny.service"
  79. mode: 0644