Matrix Docker Ansible eploy
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

86 lines
3.6 KiB

  1. # SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev
  2. # SPDX-FileCopyrightText: 2024 David Mehren
  3. #
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. ---
  6. - name: Ensure matrix-pantalaimon paths exist
  7. ansible.builtin.file:
  8. path: "{{ item.path }}"
  9. state: directory
  10. mode: '0750'
  11. owner: "{{ matrix_user_name }}"
  12. group: "{{ matrix_group_name }}"
  13. with_items:
  14. - {path: "{{ matrix_pantalaimon_base_path }}", when: true}
  15. - {path: "{{ matrix_pantalaimon_data_path }}", when: true}
  16. - {path: "{{ matrix_pantalaimon_container_src_files_path }}", when: "{{ matrix_pantalaimon_container_image_self_build }}"}
  17. when: "item.when | bool"
  18. - name: Ensure matrix-pantalaimon config installed
  19. ansible.builtin.copy:
  20. content: "{{ matrix_pantalaimon_configuration }}"
  21. dest: "{{ matrix_pantalaimon_data_path }}/pantalaimon.conf"
  22. mode: '0644'
  23. owner: "{{ matrix_user_name }}"
  24. group: "{{ matrix_group_name }}"
  25. register: matrix_pantalaimon_config_result
  26. - name: Ensure pantalaimon container image is pulled
  27. community.docker.docker_image:
  28. name: "{{ matrix_pantalaimon_docker_image }}"
  29. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  30. force_source: "{{ matrix_pantalaimon_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  31. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_pantalaimon_docker_image_force_pull }}"
  32. when: "not matrix_pantalaimon_container_image_self_build | bool"
  33. register: matrix_pantalaimon_container_image_pull_result
  34. retries: "{{ devture_playbook_help_container_retries_count }}"
  35. delay: "{{ devture_playbook_help_container_retries_delay }}"
  36. until: matrix_pantalaimon_container_image_pull_result is not failed
  37. - name: Ensure pantalaimon repository is present on self-build
  38. ansible.builtin.git:
  39. repo: "{{ matrix_pantalaimon_container_image_self_build_repo }}"
  40. version: "{{ matrix_pantalaimon_container_image_self_build_repo_version }}"
  41. dest: "{{ matrix_pantalaimon_container_src_files_path }}"
  42. force: "yes"
  43. become: true
  44. become_user: "{{ matrix_user_name }}"
  45. register: matrix_pantalaimon_git_pull_results
  46. when: "matrix_pantalaimon_container_image_self_build | bool"
  47. - name: Ensure pantalaimon container image is built
  48. community.docker.docker_image:
  49. name: "{{ matrix_pantalaimon_docker_image }}"
  50. source: build
  51. force_source: "{{ matrix_pantalaimon_git_pull_results.changed }}"
  52. build:
  53. dockerfile: Dockerfile
  54. path: "{{ matrix_pantalaimon_container_src_files_path }}"
  55. pull: true
  56. when: "matrix_pantalaimon_container_image_self_build | bool"
  57. - name: Ensure pantalaimon container network is created
  58. community.general.docker_network:
  59. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  60. name: "{{ matrix_pantalaimon_container_network }}"
  61. driver: bridge
  62. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  63. - name: Ensure matrix-pantalaimon.service installed
  64. ansible.builtin.template:
  65. src: "{{ role_path }}/templates/systemd/matrix-pantalaimon.service.j2"
  66. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-pantalaimon.service"
  67. mode: '0644'
  68. register: matrix_pantalaimon_systemd_service_result
  69. - name: Determine whether Pantalaimon needs a restart
  70. ansible.builtin.set_fact:
  71. matrix_pantalaimon_restart_necessary: >-
  72. {{
  73. matrix_pantalaimon_config_result.changed | default(false)
  74. or matrix_pantalaimon_systemd_service_result.changed | default(false)
  75. or matrix_pantalaimon_container_image_pull_result.changed | default(false)
  76. }}