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.
 
 

130 lines
5.9 KiB

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