Matrix Docker Ansible eploy
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

58 lines
2.8 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. # Only reached for bots with `management_room_auto_create` which do not have a management room yet.
  6. # Meowlnir's own record of the bot's rooms is what makes this idempotent, so no state is kept on the Ansible side.
  7. # Recomputed here, because validation runs its own loop over all bots and would leave this holding the last one's value.
  8. - name: Determine the effective initial managers for a Meowlnir bot - {{ bot.username | quote }}
  9. ansible.builtin.set_fact:
  10. matrix_bot_meowlnir_bot_initial_managers: "{{ bot.initial_managers | default(matrix_bot_meowlnir_initial_managers) }}"
  11. - name: Create a Meowlnir management room - {{ bot.username | quote }}
  12. ansible.builtin.command:
  13. cmd: >-
  14. {{ matrix_bot_meowlnir_bin_path }}/meowlnir-create-management-room
  15. {{ bot.username | quote }}
  16. {{ matrix_bot_meowlnir_bot_initial_managers | map('quote') | join(' ') }}
  17. register: matrix_bot_meowlnir_room_creation_result
  18. # The script prints the new room's ID on success, so that is what tells us a room was actually created, not merely attempted.
  19. changed_when: >-
  20. matrix_bot_meowlnir_room_creation_result.rc == 0
  21. and (matrix_bot_meowlnir_room_creation_result.stdout | default('') | trim).startswith('!')
  22. failed_when: false
  23. - name: Fail if the Meowlnir management room could not be created - {{ bot.username | quote }}
  24. ansible.builtin.fail:
  25. msg: >-
  26. Creating a management room for the Meowlnir bot `{{ bot.username }}` failed.
  27. {{ matrix_bot_meowlnir_room_creation_result.stdout | default('') | trim }}
  28. {{ matrix_bot_meowlnir_room_creation_result.stderr | default('') | trim }}
  29. when: >-
  30. matrix_bot_meowlnir_room_creation_result.rc != 0
  31. or not (matrix_bot_meowlnir_room_creation_result.stdout | default('') | trim).startswith('!')
  32. - name: Register the created Meowlnir management room - {{ bot.username | quote }}
  33. ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/ensure_management_room_registered.yml"
  34. vars:
  35. management_room:
  36. id: "{{ matrix_bot_meowlnir_room_creation_result.stdout | trim }}"
  37. encrypted: "{{ matrix_bot_meowlnir_config_encryption_enable }}"
  38. - name: Report the created Meowlnir management room - {{ bot.username | quote }}
  39. ansible.builtin.set_fact:
  40. devture_playbook_runtime_messages_list: >-
  41. {{
  42. devture_playbook_runtime_messages_list | default([])
  43. +
  44. [
  45. "Note: created a management room (" ~ (matrix_bot_meowlnir_room_creation_result.stdout | trim) ~
  46. ") for the Meowlnir bot " ~ bot.username ~ " and invited " ~
  47. (matrix_bot_meowlnir_bot_initial_managers | join(", ")) ~
  48. " to it. Accept the invitation to start commanding the bot."
  49. ]
  50. }}