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.
 
 

84 lines
4.9 KiB

  1. # SPDX-FileCopyrightText: 2026 Slavi Pantaleev
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. ---
  5. - name: Fail if required matrix-bot-meowlnir variables are undefined
  6. ansible.builtin.fail:
  7. msg: "The `{{ item.name }}` variable must be defined and have a non-null value."
  8. with_items:
  9. - {'name': 'matrix_bot_meowlnir_container_network', when: true}
  10. - {'name': 'matrix_bot_meowlnir_config_homeserver_address', when: true}
  11. - {'name': 'matrix_bot_meowlnir_config_homeserver_domain', when: true}
  12. - {'name': 'matrix_bot_meowlnir_appservice_token', when: true}
  13. - {'name': 'matrix_bot_meowlnir_homeserver_token', when: true}
  14. - {'name': 'matrix_bot_meowlnir_config_meowlnir_management_secret', when: true}
  15. - {'name': 'matrix_bot_meowlnir_config_meowlnir_data_secret', when: true}
  16. - {'name': 'matrix_bot_meowlnir_config_antispam_secret', when: true}
  17. - {'name': 'matrix_bot_meowlnir_config_encryption_pickle_key', when: true}
  18. - {'name': 'matrix_bot_meowlnir_database_hostname', when: true}
  19. - {'name': 'matrix_bot_meowlnir_database_password', when: true}
  20. - {'name': 'matrix_bot_meowlnir_config_policy_server_signing_key', when: "{{ matrix_bot_meowlnir_policy_server_enabled }}"}
  21. - {'name': 'matrix_bot_meowlnir_synapse_http_antispam_management_room_id', when: "{{ matrix_bot_meowlnir_synapse_http_antispam_enabled }}"}
  22. when: "item.when | bool and (lookup('vars', item.name, default='') == '' or lookup('vars', item.name, default='') is none)"
  23. # Meowlnir re-runs its configuration upgrader in memory on every start, and `generate` is resolved to a fresh random value each time.
  24. # A `generate` placeholder would therefore rotate the secret on every restart, invalidating the appservice registration or the encryption store.
  25. - name: Fail if matrix-bot-meowlnir secrets are set to the literal "generate"
  26. ansible.builtin.fail:
  27. msg: >-
  28. The `{{ item }}` variable is set to `generate`. Meowlnir would then mint a new
  29. secret on every restart, because the playbook runs it with `--no-update` and its
  30. configuration file is managed by Ansible. Set an explicit, stable value instead.
  31. when: "lookup('vars', item, default='') == 'generate'"
  32. with_items:
  33. - matrix_bot_meowlnir_appservice_token
  34. - matrix_bot_meowlnir_homeserver_token
  35. - matrix_bot_meowlnir_config_meowlnir_management_secret
  36. - matrix_bot_meowlnir_config_meowlnir_data_secret
  37. - matrix_bot_meowlnir_config_antispam_secret
  38. - matrix_bot_meowlnir_config_encryption_pickle_key
  39. - matrix_bot_meowlnir_config_policy_server_signing_key
  40. # Bots exist only in Meowlnir's database and are created through its management API, so the whole roster and pruning path depends on that API being reachable.
  41. # Disabling it is only coherent for an installation whose bots were created some other way, which means an empty roster and pruning turned off.
  42. - name: Fail if the Meowlnir management API is disabled while the playbook manages bots
  43. ansible.builtin.fail:
  44. msg: >-
  45. `matrix_bot_meowlnir_config_meowlnir_management_secret` is set to `disable`, which
  46. turns Meowlnir's management API off. The playbook creates, updates and removes bots
  47. through that API, so it cannot manage them while it is disabled.
  48. Either give the secret a real value, or - if you manage Meowlnir's bots yourself -
  49. leave `matrix_bot_meowlnir_bots_custom` empty and set
  50. `matrix_bot_meowlnir_bots_pruning_enabled` to `false`.
  51. when: >-
  52. matrix_bot_meowlnir_config_meowlnir_management_secret == 'disable'
  53. and (matrix_bot_meowlnir_bots | length > 0 or matrix_bot_meowlnir_bots_pruning_enabled | bool)
  54. - name: Fail if the bot user prefix and the localpart template disagree
  55. ansible.builtin.fail:
  56. msg: >-
  57. `matrix_bot_meowlnir_config_meowlnir4all_localpart_template` must start with
  58. `matrix_bot_meowlnir_user_prefix` ({{ matrix_bot_meowlnir_user_prefix }}), or the bots
  59. Meowlnir creates will fall outside the user namespace declared in its appservice
  60. registration file, and the homeserver will refuse to let it operate them.
  61. when: "not matrix_bot_meowlnir_config_meowlnir4all_localpart_template.startswith(matrix_bot_meowlnir_user_prefix)"
  62. - name: Validate Meowlnir bot definitions
  63. ansible.builtin.include_tasks: "{{ role_path }}/tasks/util/validate_bot.yml"
  64. with_items: "{{ matrix_bot_meowlnir_bots }}"
  65. loop_control:
  66. loop_var: bot
  67. - name: Fail if Meowlnir and Draupnir both claim the synapse-http-antispam module
  68. ansible.builtin.fail:
  69. msg: >-
  70. Both `matrix_bot_meowlnir_synapse_http_antispam_enabled` and
  71. `matrix_bot_draupnir_config_web_synapseHTTPAntispam_enabled` are enabled.
  72. The playbook wires the synapse-http-antispam module up to a single consumer,
  73. so you need to pick one of the two.
  74. when:
  75. - matrix_bot_meowlnir_synapse_http_antispam_enabled | bool
  76. - matrix_bot_draupnir_config_web_synapseHTTPAntispam_enabled | default(false) | bool