Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

135 lignes
6.1 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Ensure WeChat Bridge paths exists
  6. ansible.builtin.file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: 0750
  10. owner: "{{ matrix_user_username }}"
  11. group: "{{ matrix_user_groupname }}"
  12. with_items:
  13. - {path: "{{ matrix_wechat_base_path }}", when: true}
  14. - {path: "{{ matrix_wechat_config_path }}", when: true}
  15. - {path: "{{ matrix_wechat_data_path }}", when: true}
  16. - {path: "{{ matrix_wechat_container_src_files_path }}", when: "{{ matrix_wechat_container_image_self_build }}"}
  17. - {path: "{{ matrix_wechat_agent_container_src_files_path }}", when: "{{ matrix_wechat_agent_container_image_self_build }}"}
  18. when: item.when | bool
  19. - name: Ensure WeChat Bridge image is pulled
  20. community.docker.docker_image:
  21. name: "{{ matrix_wechat_container_image }}"
  22. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  23. force_source: "{{ matrix_wechat_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  24. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_wechat_container_image_force_pull }}"
  25. when: not matrix_wechat_container_image_self_build
  26. register: result
  27. retries: "{{ devture_playbook_help_container_retries_count }}"
  28. delay: "{{ devture_playbook_help_container_retries_delay }}"
  29. until: result is not failed
  30. - when: matrix_wechat_container_image_self_build | bool
  31. block:
  32. - name: Ensure WeChat Bridge repository is present on self-build
  33. ansible.builtin.git:
  34. repo: "{{ matrix_wechat_container_image_self_build_repo }}"
  35. dest: "{{ matrix_wechat_container_src_files_path }}"
  36. version: "{{ matrix_wechat_container_image_self_build_branch }}"
  37. force: "yes"
  38. become: true
  39. become_user: "{{ matrix_user_username }}"
  40. register: matrix_wechat_git_pull_results
  41. - name: Ensure WeChat Bridge container image is built
  42. community.docker.docker_image:
  43. name: "{{ matrix_wechat_container_image }}"
  44. source: build
  45. force_source: "{{ matrix_wechat_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  46. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_wechat_git_pull_results.changed }}"
  47. build:
  48. dockerfile: Dockerfile
  49. path: "{{ matrix_wechat_container_src_files_path }}"
  50. pull: true
  51. - name: Ensure WeChat Agent image is pulled
  52. community.docker.docker_image:
  53. name: "{{ matrix_wechat_agent_container_image }}"
  54. source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
  55. force_source: "{{ matrix_wechat_agent_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  56. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_wechat_agent_container_image_force_pull }}"
  57. when: not matrix_wechat_agent_container_image_self_build
  58. register: result
  59. retries: "{{ devture_playbook_help_container_retries_count }}"
  60. delay: "{{ devture_playbook_help_container_retries_delay }}"
  61. until: result is not failed
  62. - when: matrix_wechat_agent_container_image_self_build | bool
  63. block:
  64. - name: Ensure WeChat Agent repository is present on self-build
  65. ansible.builtin.git:
  66. repo: "{{ matrix_wechat_agent_container_image_self_build_repo }}"
  67. dest: "{{ matrix_wechat_agent_container_src_files_path }}"
  68. version: "{{ matrix_wechat_agent_container_image_self_build_branch }}"
  69. force: "yes"
  70. become: true
  71. become_user: "{{ matrix_user_username }}"
  72. register: matrix_wechat_agent_git_pull_results
  73. - name: Ensure WeChat Agent container image is built
  74. community.docker.docker_image:
  75. name: "{{ matrix_wechat_agent_container_image }}"
  76. source: build
  77. force_source: "{{ matrix_wechat_agent_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
  78. force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_wechat_agent_git_pull_results.changed }}"
  79. build:
  80. dockerfile: Dockerfile
  81. path: "{{ matrix_wechat_agent_container_src_files_path }}"
  82. pull: true
  83. - name: Ensure WeChat configuration installed
  84. ansible.builtin.copy:
  85. content: "{{ matrix_wechat_configuration | to_nice_yaml(indent=2, width=999999) }}"
  86. dest: "{{ matrix_wechat_config_path }}/config.yaml"
  87. mode: 0644
  88. owner: "{{ matrix_user_username }}"
  89. group: "{{ matrix_user_groupname }}"
  90. - name: Ensure WeChat registration.yaml installed
  91. ansible.builtin.copy:
  92. content: "{{ matrix_wechat_registration | to_nice_yaml(indent=2, width=999999) }}"
  93. dest: "{{ matrix_wechat_config_path }}/registration.yaml"
  94. mode: 0644
  95. owner: "{{ matrix_user_username }}"
  96. group: "{{ matrix_user_groupname }}"
  97. - name: Ensure Wechat Agent configuration installed
  98. ansible.builtin.copy:
  99. content: "{{ matrix_wechat_agent_configuration | to_nice_yaml(indent=2, width=999999) }}"
  100. dest: "{{ matrix_wechat_config_path }}/agent-config.yaml"
  101. mode: 0644
  102. owner: "{{ matrix_user_username }}"
  103. group: "{{ matrix_user_groupname }}"
  104. - name: Ensure matrix-wechat container network is created
  105. community.general.docker_network:
  106. name: "{{ matrix_wechat_container_network }}"
  107. driver: bridge
  108. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  109. - name: Ensure matrix-wechat.service installed
  110. ansible.builtin.template:
  111. src: "{{ role_path }}/templates/systemd/matrix-wechat.service.j2"
  112. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-wechat.service"
  113. mode: 0644
  114. register: matrix_wechat_systemd_service_result
  115. - name: Ensure matrix-wechat-agent.service installed
  116. ansible.builtin.template:
  117. src: "{{ role_path }}/templates/systemd/matrix-wechat-agent.service.j2"
  118. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-wechat-agent.service"
  119. mode: 0644
  120. register: matrix_wechat_agent_systemd_service_result