Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

128 satır
5.3 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. register: matrix_bot_meowlnir_git_pull_results
  46. when: "matrix_bot_meowlnir_container_image_self_build | bool"
  47. - name: Ensure Meowlnir Docker image is built
  48. community.docker.docker_image_build:
  49. name: "{{ matrix_bot_meowlnir_container_image }}"
  50. dockerfile: Dockerfile.ci
  51. path: "{{ matrix_bot_meowlnir_container_src_files_path }}"
  52. pull: true
  53. rebuild: "{{ 'always' if matrix_bot_meowlnir_git_pull_results.changed | bool else 'never' }}"
  54. when: "matrix_bot_meowlnir_container_image_self_build | bool"
  55. register: matrix_bot_meowlnir_container_image_build_result
  56. - name: Ensure matrix-bot-meowlnir config installed
  57. ansible.builtin.copy:
  58. content: "{{ matrix_bot_meowlnir_configuration | to_nice_yaml(indent=2, width=999999) }}"
  59. dest: "{{ matrix_bot_meowlnir_config_path }}/config.yaml"
  60. mode: '0640'
  61. owner: "{{ matrix_user_name }}"
  62. group: "{{ matrix_group_name }}"
  63. register: matrix_bot_meowlnir_config_result
  64. - name: Ensure matrix-bot-meowlnir registration.yaml installed
  65. ansible.builtin.copy:
  66. content: "{{ matrix_bot_meowlnir_registration | to_nice_yaml(indent=2, width=999999) }}"
  67. dest: "{{ matrix_bot_meowlnir_config_path }}/registration.yaml"
  68. mode: '0640'
  69. owner: "{{ matrix_user_name }}"
  70. group: "{{ matrix_group_name }}"
  71. register: matrix_bot_meowlnir_registration_result
  72. - name: Ensure matrix-bot-meowlnir scripts installed
  73. ansible.builtin.template:
  74. src: "{{ role_path }}/templates/bin/{{ item }}.j2"
  75. dest: "{{ matrix_bot_meowlnir_bin_path }}/{{ item }}"
  76. mode: '0750'
  77. owner: "{{ matrix_user_name }}"
  78. group: "{{ matrix_group_name }}"
  79. with_items:
  80. - meowlnir-api
  81. - meowlnir-bots
  82. - meowlnir-create-management-room
  83. - name: Ensure matrix-bot-meowlnir container network is created
  84. when: matrix_bot_meowlnir_container_network != 'host'
  85. community.general.docker_network:
  86. enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
  87. name: "{{ matrix_bot_meowlnir_container_network }}"
  88. driver: bridge
  89. driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
  90. - name: Ensure matrix-bot-meowlnir container labels installed
  91. ansible.builtin.template:
  92. src: "{{ role_path }}/templates/labels.j2"
  93. dest: "{{ matrix_bot_meowlnir_base_path }}/labels"
  94. mode: '0640'
  95. owner: "{{ matrix_user_name }}"
  96. group: "{{ matrix_group_name }}"
  97. register: matrix_bot_meowlnir_labels_result
  98. - name: Ensure matrix-bot-meowlnir.service installed
  99. ansible.builtin.template:
  100. src: "{{ role_path }}/templates/systemd/matrix-bot-meowlnir.service.j2"
  101. dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-meowlnir.service"
  102. mode: '0644'
  103. register: matrix_bot_meowlnir_systemd_service_result
  104. - name: Determine whether Meowlnir needs a restart
  105. ansible.builtin.set_fact:
  106. matrix_bot_meowlnir_restart_necessary: >-
  107. {{
  108. matrix_bot_meowlnir_config_result.changed | default(false)
  109. or matrix_bot_meowlnir_registration_result.changed | default(false)
  110. or matrix_bot_meowlnir_labels_result.changed | default(false)
  111. or matrix_bot_meowlnir_systemd_service_result.changed | default(false)
  112. or matrix_bot_meowlnir_container_image_pull_result.changed | default(false)
  113. or matrix_bot_meowlnir_container_image_build_result.changed | default(false)
  114. }}