Skip to content

Commit b21d3dd

Browse files
committed
Documentation for Zero Touch Deployment
1 parent 5650265 commit b21d3dd

4 files changed

Lines changed: 84 additions & 21 deletions

File tree

docs/configuring-playbook-appservice-draupnir-for-all.md

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!--
2+
SPDX-FileCopyRightText: 2024,2026 Catalan Lover <catalanlover@protonmail.com>
23
SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
34
SPDX-FileCopyrightText: 2024 MDAD project contributors
45
@@ -13,33 +14,55 @@ Appservice mode can be used together with the regular [Draupnir bot](configuring
1314

1415
## Draupnir Appservice mode compared to Draupnir bot mode
1516

16-
The administrative functions for managing the appservice are alpha quality and very limited. However, the experience of using an appservice-provisioned Draupnir is on par with the experience of using Draupnir from bot mode except in the case of avatar customisation as described later on in this document.
17+
The administrative functions for managing the appservice are alpha quality and very limited. However, the experience of using an appservice-provisioned Draupnir is on par with the experience of using Draupnir from bot mode.
1718

18-
Draupnir for all is the way to go if you need more than 1 Draupnir instance, but you don't need access to Synapse Admin features as they are not accessible through Draupnir for All (Even though the commands do show up in help).
19+
Draupnir for all is the way to go if you need more than 1 Draupnir instance, but you don't need access to Synapse Admin features as they are not accessible through Draupnir for All.
1920

2021
Draupnir for all in the playbook is rate-limit-exempt automatically as its appservice configuration file does not specify any rate limits.
2122

22-
Normal Draupnir does come with the benefit of access to Synapse Admin features. You are also able to more easily customise your normal Draupnir than D4A as D4A even on the branch with the Avatar command (To be Upstreamed to Mainline Draupnir) that command is clunky as it requires the use of things like Element Web devtools. In normal Draupnir this is a quick operation where you login to Draupnir with a normal client and set Avatar and Display name normally.
23+
Normal Draupnir does come with the benefit of access to Synapse Admin features. You are also able to more easily customise your normal Draupnir than D4A as the avatar command is clunky as it requires the use of things like Element Web devtools. In normal Draupnir this can be done while logged in to the Draupnir account with a normal client and set Avatar and Display name normally.
2324

24-
Draupnir for all does not support external tooling like [MRU](https://mru.rory.gay) as it can't access Draupnir's user account.
25+
Draupnir for all only has limited support for external tooling like [MRU](https://mru.rory.gay) as it can't access Draupnir's user account.
2526

2627
## Prerequisites
2728

28-
### Create a main management room
29+
### Prerequisites for Zero Touch Deployment (Recomended)
2930

30-
The playbook does not create a management room for your Main Draupnir. You **need to create the room manually** before setting up the bot.
31+
Zero Touch Deployment of Draupnir Appservice Mode (Draupnir for all) requires as of Draupnir 3.1.0 that you supply Draupnir the following:
32+
33+
- MXID of the the first person who gets invited to the admin room the bot creates for you.
34+
35+
That is all. The appservice manages everything on its own after you provide it a MXID to invite.
36+
37+
If proceeding with Zero Touch Deployment proceed to [Adjusting the playbook configuration](#adjusting-the-playbook-configuration)
38+
39+
### Create a admin room (Optional)
40+
41+
The playbook does not create a admin room for your Admin Draupnir but the appservice it self can do this. You **can create room manually** before setting up the bot.
3142

3243
Note that the room must be unencrypted.
3344

34-
The management room has to be given an alias, and your bot has to be invited to the room.
45+
The admin room has to be given an alias, and your bot has to be invited to the room.
3546

36-
This management room is used to control who has access to your D4A deployment. The room stores this data inside of the control room state so your bot must have sufficient powerlevel to send custom state events. This is default 50 or moderator as Element clients call this powerlevel.
47+
This admin room is used to control who has access to your D4A deployment. The room stores this data inside of the control room state so your bot must have sufficient powerlevel to send custom state events. This is default 50 or moderator as Element clients call this powerlevel.
3748

3849
> [!WARNING]
3950
> Anyone in this room can control the bot so it is important that you only invite trusted users to this room.
4051
4152
## Adjusting the playbook configuration
4253

54+
Add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file. Make sure to replace `INITIAL_MANAGER_MXID_HERE`.
55+
56+
```yaml
57+
matrix_appservice_draupnir_for_all_enabled: true
58+
59+
matrxi_appservice_draupnir_for_all_zero_touch_deployment: true
60+
61+
matrix_appservice_draupnir_for_all_config_initialManager: "INITIAL_MANAGER_MXID_HERE"
62+
```
63+
64+
If opting out of Zero Touch deployment use the following configuration block instead.
65+
4366
Add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file. Make sure to replace `MANAGEMENT_ROOM_ALIAS_HERE`.
4467

4568
```yaml
@@ -105,18 +128,26 @@ ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start
105128

106129
If you made it through all the steps above and your main control room was joined by a user called `@draupnir-main:example.com` you have successfully installed Draupnir for All and can now start using it.
107130

108-
The installation of Draupnir for all in this playbook is very much Alpha quality. Usage-wise, Draupnir for all is almost identical to Draupnir bot mode.
131+
If using Zero Touch Deployment the flow will be reversed and the success signal is the initial manager account being invited to the admin room.
132+
133+
The installation of Draupnir for all in Usage-wise, Draupnir for all is almost identical to Draupnir bot mode.
134+
135+
Draupnir for all installation via this playbook is very much Alpha quality. Usage-wise, Draupnir for all is almost identical to Draupnir bot mode, except that protections requiring homeserver admin access are not available, and the config file is shared between all bots so legacy protections like wordlist share a single global config.
109136

110137
### Granting Users the ability to use D4A
111138

112139
Draupnir for all includes several security measures like that it only allows users that are on its allow list to ask for a bot. To add a user to this list we have 2 primary options. Using the chat to tell Draupnir to do this for us or if you want to automatically do it by sending `m.policy.rule.user` events that target the subject you want to allow provisioning for with the `org.matrix.mjolnir.allow` recommendation. Using the chat is recommended.
113140

114-
The bot requires a powerlevel of 50 in the management room to control who is allowed to use the bot. The bot does currently not say anything if this is true or false. (This is considered a bug and is documented in issue [#297](https://github.com/the-draupnir-project/Draupnir/issues/297))
141+
The bot requires a powerlevel of 50 in the management room to control who is allowed to use the bot. The bot does currently not say anything if this is true or false. (This is considered a bug and is documented in issue [#297](https://github.com/the-draupnir-project/Draupnir/issues/297)) This issue is mittigated in large part by Zero Touch Deployment workflows that got introduced in Draupnir 3.1.0
115142

116-
To allow users or whole homeservers you type /plain !admin allow `target` and target can be either a MXID or a wildcard like `@*:example.com` to allow all users on example.com to register. We use /plain to force the client to not attempt to mess with this command as it can break Wildcard commands especially.
143+
To allow users or whole homeservers you type /plain !admin allow `target` and target can be either a MXID or a wildcard like `@*:example.com` to allow all users on example.com to provision a bot. We use /plain to force the client to not attempt to mess with this command as it can break Wildcard commands especially.
117144

118145
### How to provision a D4A once you are allowed to
119146

120-
To provision a D4A, you need to start a chat with `@draupnir-main:example.com`. The bot will reject this invite and you will shortly get invited to the Draupnir control room for your newly provisioned Draupnir. From here its just a normal Draupnir experience.
147+
Once someone is allowed to provision a bot. Simply provision them one with `!admin provision MXID`.
148+
Self Service Provisioning is disabled as a security feature due to it being bugged. Force Provisioning bypasses this disabled status.
149+
150+
Please note that the reason you should always make sure there is an allow entry matching whoever is provisioned is that when
151+
self service gets fixed the bot of anyone who is not allowed to provision a bot will refuse to start.
121152

122153
Congratulations if you made it all the way here because you now have a fully working Draupnir for all deployment.

docs/configuring-playbook-bot-draupnir.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!--
2+
SPDX-FileCopyRightText: 2023 - 2026 Catalan Lover <catalanlover@protonmail.com>
23
SPDX-FileCopyrightText: 2023 - 2025 MDAD project contributors
34
SPDX-FileCopyrightText: 2023 Kim Brose
45
SPDX-FileCopyrightText: 2024 - 2025 Slavi Pantaleev
@@ -19,7 +20,17 @@ If your migrating from [Mjolnir](configuring-playbook-bot-mjolnir.md), skip to [
1920

2021
## Prerequisites
2122

22-
### Create a management room
23+
### Prerequisites for Zero Touch Deployment (Recomended)
24+
25+
Zero Touch Deployment of Draupnir bot mode requires as of Draupnir 3.1.0 that you supply Draupnir the following:
26+
27+
- MXID of the the first person who gets invited to the management room the bot creates for you.
28+
- Permanent access token for authentication. Instructions for obtaining one can be found at [obtain an access token via curl](obtaining-access-tokens.md#obtain-an-access-token-via-curl)
29+
- User account for Draupnir
30+
31+
Zero Touch Deployment is the officially preferred installation method for new deployments of Draupnir as of 3.1.0
32+
33+
### Create a management room (optional)
2334

2435
Using your own account, create a new invite only room that you will use to manage the bot. This is the room where you will see the status of the bot and where you will send commands to the bot, such as the command to ban a user from another room.
2536

@@ -28,6 +39,8 @@ Using your own account, create a new invite only room that you will use to manag
2839
2940
It is possible to make the management room encrypted (E2EE). If doing so, then you need to enable the native E2EE support (see [below](#native-e2ee-support)).
3041

42+
E2EE Support for the management room is mutually exclusive with Zero Touch Deployment of Draupnir.
43+
3144
Once you have created the room you need to copy the room ID so you can specify it on your `inventory/host_vars/matrix.example.com/vars.yml` file. In Element Web you can check the ID by going to the room's settings and clicking "Advanced". The room ID will look something like `!qporfwt:example.com`.
3245

3346
## End-to-End Encryption support
@@ -63,7 +76,23 @@ matrix_bot_draupnir_config_accessToken: "CLEAN_ACCESS_TOKEN_HERE"
6376
6477
## Adjusting the playbook configuration
6578
66-
To enable the bot, add the following configuration to your `vars.yml` file. Make sure to replace `MANAGEMENT_ROOM_ID_HERE` with the one of the room which you have created earlier.
79+
To enable the bot, add the following configuration to your `vars.yml` file. Make sure to replace `INITIAL_MANAGER_MXID_HERE` with the MXID for whoever is to be invited to the management room first.
80+
81+
82+
```yaml
83+
# Enable Draupnir
84+
matrix_bot_draupnir_enabled: true
85+
86+
matrix_bot_draupnir_zero_touch_deploy: true
87+
88+
matrix_bot_draupnir_config_initialManager: "INITIAL_MANAGER_MXID_HERE"
89+
90+
# Access token which the bot will use for logging in.
91+
# Comment out `matrix_bot_draupnir_login_native` when using this option.
92+
matrix_bot_draupnir_config_accessToken: "CLEAN_ACCESS_TOKEN_HERE"
93+
```
94+
95+
If wanting to have the bot manage its own login at the cost of having to create a management room you can use login native and the config block below.
6796
6897
```yaml
6998
# Enable Draupnir
@@ -90,7 +119,7 @@ This is due to the conditional restart logic not being able to reliably tell whe
90119

91120
Conditional restarts work correctly for all tags when running only one of these two operating modes.
92121

93-
### Create and invite the bot to the management room
122+
### Create and invite the bot to the management room (if using login native and not using Zero Touch Deployment)
94123

95124
Before proceeding to the next step, run the playbook with the following command to create the bot user.
96125

@@ -102,6 +131,12 @@ ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,ensure-matrix-use
102131

103132
Then, invite the bot (`@bot.draupnir:example.com`) to its management room which you have created earlier.
104133

134+
### Creating user account for the bot
135+
136+
Since Zero Touch Deployment is not validated with login native we will create the user account manually.
137+
138+
Refer to [registering users](registering-users.md) for documentation on how to configure the user account.
139+
105140
### Make sure the account is free from rate limiting (optional, recommended)
106141

107142
If your homeserver's implementation is Synapse, you will need to prevent it from rate limiting the bot's account. **This is a highly recommended step. If you do not configure it, Draupnir performance will be degraded.**
@@ -115,6 +150,7 @@ The APIs can also be accessed via [Ketesa](https://github.com/etkecc/ketesa), a
115150
#### Add the configuration
116151

117152
To expose the APIs publicly, add the following configuration to your `vars.yml` file:
153+
This is automatically done if Ketesa is enabled.
118154

119155
```yaml
120156
matrix_synapse_container_labels_public_client_synapse_admin_api_enabled: true
@@ -167,11 +203,7 @@ matrix_bot_draupnir_admin_api_enabled: true
167203

168204
These protections need to be manually activated and consulting the [enabling protections](#enabling-built-in-protections) guide can be helpful or consulting upstream documentation.
169205

170-
<!--
171-
NOTE: this is unsupported by the playbook due to the admin API being inaccessible from containers currently.
172-
173206
The other method polls an Synapse Admin API endpoint, hence it is available only if using Synapse and if the Draupnir user is an admin (see [above](#register-the-bot-account)). To enable it, set `pollReports: true` on `vars.yml` file as below.
174-
-->
175207

176208
### Extending the configuration
177209

roles/custom/matrix-appservice-draupnir-for-all/tasks/setup_install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-FileCopyrightText: 2024 David Mehren
22
# SPDX-FileCopyrightText: 2024 MDAD project contributors
3-
# SPDX-FileCopyrightText: 2024 Catalan Lover <catalanlover@protonmail.com>
3+
# SPDX-FileCopyrightText: 2024, 2026 Catalan Lover <catalanlover@protonmail.com>
44
# SPDX-FileCopyrightText: 2024 Slavi Pantaleev
55
# SPDX-FileCopyrightText: 2024 Suguru Hirahara
66
#

roles/custom/matrix-appservice-draupnir-for-all/tasks/validate_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-FileCopyrightText: 2024 MDAD project contributors
2-
# SPDX-FileCopyrightText: 2024 Catalan Lover <catalanlover@protonmail.com>
2+
# SPDX-FileCopyrightText: 2024, 2026 Catalan Lover <catalanlover@protonmail.com>
33
# SPDX-FileCopyrightText: 2024 Slavi Pantaleev
44
# SPDX-FileCopyrightText: 2025 Suguru Hirahara
55
#

0 commit comments

Comments
 (0)