Matrix Docker Ansible eploy
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

98 řádky
4.2 KiB

  1. # SPDX-FileCopyrightText: 2022 - 2023 Julian-Samuel Gebühr
  2. # SPDX-FileCopyrightText: 2022 - 2024 Slavi Pantaleev
  3. # SPDX-FileCopyrightText: 2022 Sebastian Gumprich
  4. #
  5. # SPDX-License-Identifier: AGPL-3.0-or-later
  6. ---
  7. - name: Ensure matrix-cactus-comments 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. with_items:
  15. - {path: "{{ matrix_cactus_comments_base_path }}", when: true}
  16. - {path: "{{ matrix_cactus_comments_container_tmp_path }}", when: true}
  17. - {path: "{{ matrix_cactus_comments_container_src_files_path }}", when: "{{ matrix_cactus_comments_container_image_self_build }}"}
  18. when: "item.when | bool"
  19. - name: Ensure matrix-cactus-comments environment file created
  20. ansible.builtin.template:
  21. src: "{{ role_path }}/templates/env.j2"
  22. dest: "{{ matrix_cactus_comments_app_service_env_file }}"
  23. owner: "{{ matrix_user_name }}"
  24. group: "{{ matrix_group_name }}"
  25. mode: '0640'
  26. register: matrix_cactus_comments_config_env_result
  27. - name: Ensure matrix-cactus-comments appservice file created
  28. ansible.builtin.template:
  29. src: "{{ role_path }}/templates/cactus_appservice.yaml.j2"
  30. dest: "{{ matrix_cactus_comments_app_service_config_file }}"
  31. owner: "{{ matrix_user_name }}"
  32. group: "{{ matrix_group_name }}"
  33. mode: '0640'
  34. register: matrix_cactus_comments_config_appservice_result
  35. - name: Ensure matrix-cactus-comments image is pulled
  36. community.docker.docker_image_pull:
  37. name: "{{ matrix_cactus_comments_container_image }}"
  38. pull: always
  39. when: "not matrix_cactus_comments_container_image_self_build | bool"
  40. register: matrix_cactus_comments_container_image_pull_result
  41. retries: "{{ devture_playbook_help_container_retries_count }}"
  42. delay: "{{ devture_playbook_help_container_retries_delay }}"
  43. until: matrix_cactus_comments_container_image_pull_result is not failed
  44. # A checkout owned by a different user (a uid change, an earlier clone by another user, etc.) would make the git task below fail on ownership or permissions.
  45. - name: Ensure matrix-cactus-comments repository ownership is correct on self-build
  46. ansible.builtin.file:
  47. path: "{{ matrix_cactus_comments_container_src_files_path }}"
  48. state: directory
  49. owner: "{{ matrix_user_name }}"
  50. group: "{{ matrix_group_name }}"
  51. recurse: true
  52. when: "matrix_cactus_comments_container_image_self_build | bool"
  53. - name: Ensure matrix-cactus-comments repository is present on self-build
  54. ansible.builtin.git:
  55. repo: "{{ matrix_cactus_comments_container_repo }}"
  56. version: "{{ matrix_cactus_comments_container_repo_version }}"
  57. dest: "{{ matrix_cactus_comments_container_src_files_path }}"
  58. force: "yes"
  59. become: true
  60. become_user: "{{ matrix_user_name }}"
  61. register: matrix_cactus_comments_git_pull_results
  62. when: "matrix_cactus_comments_container_image_self_build | bool"
  63. - name: Ensure matrix-cactus-comments image is built
  64. community.docker.docker_image_build:
  65. name: "{{ matrix_cactus_comments_container_image }}"
  66. dockerfile: Dockerfile
  67. path: "{{ matrix_cactus_comments_container_src_files_path }}"
  68. pull: true
  69. rebuild: "{{ 'always' if matrix_cactus_comments_git_pull_results.changed | bool else 'never' }}"
  70. when: "matrix_cactus_comments_container_image_self_build | bool"
  71. register: matrix_cactus_comments_container_image_build_result
  72. - name: Ensure matrix-cactus-comments.service installed
  73. ansible.builtin.template:
  74. src: "{{ role_path }}/templates/systemd/matrix-cactus-comments.service.j2"
  75. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-cactus-comments.service"
  76. mode: '0644'
  77. register: matrix_cactus_comments_systemd_service_result
  78. - name: Determine whether matrix-cactus-comments needs a restart
  79. ansible.builtin.set_fact:
  80. matrix_cactus_comments_restart_necessary: >-
  81. {{
  82. matrix_cactus_comments_config_env_result.changed | default(false)
  83. or matrix_cactus_comments_config_appservice_result.changed | default(false)
  84. or matrix_cactus_comments_systemd_service_result.changed | default(false)
  85. or matrix_cactus_comments_container_image_pull_result.changed | default(false)
  86. or matrix_cactus_comments_container_image_build_result.changed | default(false)
  87. }}