Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

137 líneas
6.2 KiB

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