Matrix Docker Ansible eploy
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

134 行
5.6 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Ensure matrix-bot-meowlnir paths exist
  6. ansible.builtin.file:
  7. path: "{{ item.path }}"
  8. state: directory
  9. mode: '0750'
  10. owner: "{{ matrix_user_name }}"
  11. group: "{{ matrix_group_name }}"
  12. with_items:
  13. - {path: "{{ matrix_bot_meowlnir_base_path }}", when: true}
  14. - {path: "{{ matrix_bot_meowlnir_config_path }}", when: true}
  15. - {path: "{{ matrix_bot_meowlnir_data_path }}", when: true}
  16. - {path: "{{ matrix_bot_meowlnir_bin_path }}", when: true}
  17. - {path: "{{ matrix_bot_meowlnir_container_src_files_path }}", when: "{{ matrix_bot_meowlnir_container_image_self_build }}"}
  18. when: "item.when | bool"
  19. - name: Ensure Meowlnir Docker image is pulled
  20. community.docker.docker_image_pull:
  21. name: "{{ matrix_bot_meowlnir_container_image }}"
  22. pull: always
  23. when: "not matrix_bot_meowlnir_container_image_self_build | bool"
  24. register: matrix_bot_meowlnir_container_image_pull_result
  25. retries: "{{ devture_playbook_help_container_retries_count }}"
  26. delay: "{{ devture_playbook_help_container_retries_delay }}"
  27. until: matrix_bot_meowlnir_container_image_pull_result is not failed
  28. # 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.
  29. - name: Ensure Meowlnir repository ownership is correct on self-build
  30. ansible.builtin.file:
  31. path: "{{ matrix_bot_meowlnir_container_src_files_path }}"
  32. state: directory
  33. owner: "{{ matrix_user_name }}"
  34. group: "{{ matrix_group_name }}"
  35. recurse: true
  36. when: "matrix_bot_meowlnir_container_image_self_build | bool"
  37. - name: Ensure Meowlnir repository is present on self-build
  38. ansible.builtin.git:
  39. repo: "{{ matrix_bot_meowlnir_container_image_self_build_repo }}"
  40. dest: "{{ matrix_bot_meowlnir_container_src_files_path }}"
  41. version: "{{ matrix_bot_meowlnir_container_image.split(':')[1] }}"
  42. force: "yes"
  43. become: true
  44. become_user: "{{ matrix_user_name }}"
  45. # Keep this even though the task above normalizes ownership. Git may still see an ownership mismatch when Ansible becomes an unprivileged user (see #5065).
  46. environment:
  47. GIT_CONFIG_COUNT: "1"
  48. GIT_CONFIG_KEY_0: safe.directory
  49. GIT_CONFIG_VALUE_0: "{{ matrix_bot_meowlnir_container_src_files_path }}"
  50. register: matrix_bot_meowlnir_git_pull_results
  51. when: "matrix_bot_meowlnir_container_image_self_build | bool"
  52. - name: Ensure Meowlnir Docker image is built
  53. community.docker.docker_image_build:
  54. name: "{{ matrix_bot_meowlnir_container_image }}"
  55. dockerfile: Dockerfile.ci
  56. path: "{{ matrix_bot_meowlnir_container_src_files_path }}"
  57. pull: true
  58. rebuild: "{{ 'always' if matrix_bot_meowlnir_git_pull_results.changed | bool else 'never' }}"
  59. when: "matrix_bot_meowlnir_container_image_self_build | bool"
  60. register: matrix_bot_meowlnir_container_image_build_result
  61. - name: Ensure matrix-bot-meowlnir config installed
  62. ansible.builtin.copy:
  63. content: "{{ matrix_bot_meowlnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
  64. dest: "{{ matrix_bot_meowlnir_config_path }}/config.yaml"
  65. mode: '0640'
  66. owner: "{{ matrix_user_name }}"
  67. group: "{{ matrix_group_name }}"
  68. register: matrix_bot_meowlnir_config_result
  69. - name: Ensure matrix-bot-meowlnir registration.yaml installed
  70. ansible.builtin.copy:
  71. content: "{{ matrix_bot_meowlnir_registration | to_nice_yaml(indent=2, width=999999) }}"
  72. dest: "{{ matrix_bot_meowlnir_config_path }}/registration.yaml"
  73. mode: '0640'
  74. owner: "{{ matrix_user_name }}"
  75. group: "{{ matrix_group_name }}"
  76. register: matrix_bot_meowlnir_registration_result
  77. - name: Ensure matrix-bot-meowlnir scripts installed
  78. ansible.builtin.template:
  79. src: "{{ role_path }}/templates/bin/{{ item }}.j2"
  80. dest: "{{ matrix_bot_meowlnir_bin_path }}/{{ item }}"
  81. mode: '0750'
  82. owner: "{{ matrix_user_name }}"
  83. group: "{{ matrix_group_name }}"
  84. with_items:
  85. - meowlnir-api
  86. - meowlnir-bots
  87. - meowlnir-create-management-room
  88. - meowlnir-whoami
  89. - name: Ensure matrix-bot-meowlnir container network is created
  90. when: matrix_bot_meowlnir_container_network != 'host'
  91. community.general.docker_network:
  92. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  93. name: "{{ matrix_bot_meowlnir_container_network }}"
  94. driver: bridge
  95. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  96. - name: Ensure matrix-bot-meowlnir container labels installed
  97. ansible.builtin.template:
  98. src: "{{ role_path }}/templates/labels.j2"
  99. dest: "{{ matrix_bot_meowlnir_base_path }}/labels"
  100. mode: '0640'
  101. owner: "{{ matrix_user_name }}"
  102. group: "{{ matrix_group_name }}"
  103. register: matrix_bot_meowlnir_labels_result
  104. - name: Ensure matrix-bot-meowlnir.service installed
  105. ansible.builtin.template:
  106. src: "{{ role_path }}/templates/systemd/matrix-bot-meowlnir.service.j2"
  107. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-meowlnir.service"
  108. mode: '0644'
  109. register: matrix_bot_meowlnir_systemd_service_result
  110. - name: Determine whether Meowlnir needs a restart
  111. ansible.builtin.set_fact:
  112. matrix_bot_meowlnir_restart_necessary: >-
  113. {{
  114. matrix_bot_meowlnir_config_result.changed | default(false)
  115. or matrix_bot_meowlnir_registration_result.changed | default(false)
  116. or matrix_bot_meowlnir_labels_result.changed | default(false)
  117. or matrix_bot_meowlnir_systemd_service_result.changed | default(false)
  118. or matrix_bot_meowlnir_container_image_pull_result.changed | default(false)
  119. or matrix_bot_meowlnir_container_image_build_result.changed | default(false)
  120. }}