Skip to content

Commit 963a5a0

Browse files
author
Suguru Hirahara
committed
Update developer-documentation.md: tidy up
- Add description about a git forge - Update file trees - Update contents of <details> tags Signed-off-by: Suguru Hirahara <[email protected]>
1 parent 4151160 commit 963a5a0

File tree

1 file changed

+100
-49
lines changed

1 file changed

+100
-49
lines changed

docs/developer-documentation.md

+100-49
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!--
22
SPDX-FileCopyrightText: 2024 Bergrübe
33
SPDX-FileCopyrightText: 2024 Slavi Pantaleev
4+
SPDX-FileCopyrightText: 2025 Suguru Hirahara
45
56
SPDX-License-Identifier: AGPL-3.0-or-later
67
-->
@@ -9,59 +10,83 @@ SPDX-License-Identifier: AGPL-3.0-or-later
910

1011
## Support a new service | Create your own role
1112

12-
### 1. Check if
13+
Are you interested in adding a new service which is not yet [available on this playbook](supported-services.md)? Great! By following the guide below, you can easily implement one to the playbook.
1314

14-
- the role doesn't exist already in [`supported-services.md`](supported-services.md) and no one else is already [working on it](https://github.com/mother-of-all-self-hosting/mash-playbook/pulls)
15+
### 1. Get started
1516

16-
- the service you wish to add can run in a Docker container
17-
18-
- a container image already exists
17+
Before working on implementation, check if:
1918

20-
### 2. Create the Ansible role in a public git repository.
21-
You can follow the structure of existing roles, like the [`ansible-role-gitea`](https://github.com/mother-of-all-self-hosting/ansible-role-gitea) or the [`ansible-role-gotosocial`](https://github.com/mother-of-all-self-hosting/ansible-role-gotosocial).
19+
- the role does not exist already in [`supported-services.md`](supported-services.md) and no one else is already [working on it](https://github.com/mother-of-all-self-hosting/mash-playbook/pulls)
2220

23-
Some advice:
24-
- Your file structure will probably look something like this:
21+
- the service you wish to add can run in a Docker container
2522

26-
```
27-
.
28-
├── defaults/
29-
│ └── main.yml
30-
├── meta/
31-
│ └── main.yml
32-
├── tasks/
33-
│ ├── main.yml
34-
│ ├── install.yml
35-
│ ├── uninstall.yml
36-
│ └── validate_config.yml
37-
├── templates/
38-
│ ├── env.j2
39-
│ ├── labels.j2
40-
│ └── NEW-SERVICE.service.j2
41-
├── .gitignore
42-
├── LICENSE
43-
└── README.md
44-
```
45-
- You will need to decide on a licence, without it, ansible-galaxy won't work. We recommend AGPLv3, like all of MASH.
23+
- a container image already exists
4624

47-
### 3. Update the MASH-Playbook to support your created Ansible role
25+
### 2. Create an Ansible role in a public git repository
26+
27+
To support a new service, at first you need to create an Ansible role for it in its public git repository. It does not have to be maintained on a specific forge like GitHub; you can use GitLab, Codeberg, or anywhere you choose. Note that the instance should be stable and globally available as the roles are to be fetched anytime.
28+
29+
When it comes to the structure of roles, you can follow existing roles such as [`ansible-role-postgres`](https://github.com/mother-of-all-self-hosting/ansible-role-postgres), [`ansible-role-syncthing`](https://github.com/mother-of-all-self-hosting/ansible-role-syncthing), and [`ansible-role-ntfy`](https://github.com/mother-of-all-self-hosting/ansible-role-ntfy). Generally, it is not recommended to create a role from the scratch as it can lack important variables required for the playbook. If you are not quite sure where to start, your best bet would be to copy the existing (and recently updated) role maintained by [MASH project](https://github.com/mother-of-all-self-hosting), and reuse it as a template.
30+
31+
💡 **Notes**:
32+
- Your role's file structure should be similar to this tree:
33+
```
34+
.
35+
├── defaults/
36+
│ └── main.yml
37+
├── docs/
38+
│ └── configuring-YOUR-SERVICE.md
39+
├── meta/
40+
│ └── main.yml
41+
├── tasks/
42+
│ ├── main.yml
43+
│ ├── install.yml
44+
│ ├── uninstall.yml
45+
│ └── validate_config.yml
46+
├── templates/
47+
│ ├── env.j2
48+
│ ├── labels.j2
49+
│ └── systemd/
50+
│ └── YOUR-SERVICE.service.j2
51+
├── justfile
52+
├── LICENSE
53+
└── README.md
54+
```
55+
- You will also need to decide on a licence. Otherwise ansible-galaxy won't work. We recommend AGPLv3, as all roles of the MASH playbook.
56+
- If you are committed to free software, you might probably be interested in publishing the role based on [REUSE](https://reuse.software/), an initiative by [FSFE](https://fsfe.org/).
57+
58+
### 3. Update the MASH playbook to support your created Ansible role
4859
4960
There are a few files that you need to adapt:
61+
5062
```
5163
.
5264
├── docs/
5365
│ ├── supported-services.md -> Add your service
5466
│ └── services/
55-
│ └── YOUR-SERVICE.md -> document how to use it
67+
│ └── YOUR-SERVICE.md -> Add documentation about how to configure it
5668
├── templates/
57-
│ ├── group_vars_mash_servers -> Add default config
58-
│ └── requirements.yml -> add your Ansible role
59-
│ └── setup.yml -> add your Ansible role
69+
│ ├── group_vars_mash_servers -> Add default configuration
70+
│ └── requirements.yml -> Add your Ansible role
71+
│ └── setup.yml -> Add your Ansible role
6072
```
73+
74+
💡 Make sure to edit configuration files inside `templates` — These are source files to be optimized and used when running [`just`](just.md) commands to install, configure, or uninstall services.
75+
76+
#### Add the role to `group_vars_mash_servers` in `templates` directory
77+
78+
On `group_vars_mash_servers` you need to wire your role with the rest of the services of the playbook — integrating with the service manager or potentially with other roles.
79+
80+
When adding the role, replace `YOUR-SERVICE` with yours, and also mind the place to add the role, as the roles are (mostly) sorted alphabetically for other developers' sanity.
81+
82+
See below for details about what to configure. Note that not all roles require to be wired to anything other than `systemd_service_manager`.
83+
6184
<details>
85+
<summary>Wire the role to systemd_service_manager</summary>
86+
87+
You have to add the role to `mash_playbook_devture_systemd_service_manager_services_list_auto_itemized` so that it is wired to `systemd_service_manager`.
6288
63-
<summary> file: templates / group_vars_mash_servers </summary>
64-
In this file you wire your role with the rest of the playbook — integrating with the service manager or potentially with other roles.
89+
See below for an example:
6590
6691
```yaml
6792
# role-specific:systemd_service_manager
@@ -89,8 +114,14 @@ mash_playbook_devture_systemd_service_manager_services_list_auto_itemized:
89114
```
90115
</details>
91116

117+
**Optional**:
118+
119+
Please wire your role to other services than `systemd_service_manager` if necessary.
120+
92121
<details>
93-
<summary>Support Postgres</summary>
122+
<summary>Wire the role to Postgres / MariaDB</summary>
123+
124+
On this playbook Postgres is enabled by default (see [`examples/vars.yml`](../examples/vars.yml)), and you can wire your role to Postgres by adding it to the configuration for Postgres as below:
94125

95126
```yaml
96127
# role-specific:postgres
@@ -136,8 +167,8 @@ mash_playbook_postgres_managed_databases_auto_itemized:
136167
# role-specific:postgres
137168
YOUR-SERVICE_database_hostname: "{{ postgres_identifier if postgres_enabled else '' }}"
138169
YOUR-SERVICE_database_port: "{{ '5432' if postgres_enabled else '' }}"
139-
YOUR-SERVICE_database_password: "{{ '%s' | format(mash_playbook_generic_secret_key) | password_hash('sha512', 'db.authentik', rounds=655555) | to_uuid }}"
140-
YOUR-SERVICE_database_username: "{{ authentik_identifier }}"
170+
YOUR-SERVICE_database_password: "{{ '%s' | format(mash_playbook_generic_secret_key) | password_hash('sha512', 'db.yourservice', rounds=655555) | to_uuid }}"
171+
YOUR-SERVICE_database_username: "{{ YOUR-SERVICE_identifier }}"
141172
# /role-specific:postgres
142173

143174
YOUR-SERVICE_container_additional_networks_auto: |
@@ -152,10 +183,20 @@ YOUR-SERVICE_container_additional_networks_auto: |
152183
########################################################################
153184
# /role-specific:YOUR-SERVICE
154185
```
155-
</details><details>
156-
<summary>Support exim-relay</summary>
157186

158-
The [exim-relay](https://github.com/devture/exim-relay) is an easy way to configure for all services a way for outgoing mail.
187+
💡 If your role requires MySQL, you can instead wire it to MariaDB on this playbook via `mash_playbook_mariadb_managed_databases_auto_itemized` in a similar way. See the [service documentation](services/mariadb.md) for details about managing a MariaDB instance.
188+
189+
</details>
190+
191+
<details>
192+
<summary>Wire the role to exim-relay (mailer)</summary>
193+
194+
This playbook implements [exim-relay](https://github.com/devture/exim-relay), a SMTP mailer service.
195+
196+
Various services need to send out email, and exim-relay gives you a centralized place for configuring email-sending.
197+
198+
To wire the role to exim-relay, add the configuration for it as below:
199+
159200
```yaml
160201
[...]
161202

@@ -190,12 +231,16 @@ YOUR-SERVICE_config_mailer_protocol: "{{ 'smtp' if exim_relay_enabled else '' }}
190231
########################################################################
191232
# /role-specific:YOUR-SERVICE
192233
```
193-
</details><details>
234+
</details>
235+
236+
<details>
237+
<summary>Wire the role to Hubsite (static site for services overview)</summary>
238+
239+
[Hubsite](https://github.com/moan0s/hubsite) is a service which provides you with a simple static site that shows an overview of the available services.
194240

195-
<summary>Support hubsite</summary>
241+
Adding the role to Hubsite is not a hard requirement to add the role to the playbook, but it is recommended to do so, so that you (and visitors of your services) can easily navigate to the services available on your server.
196242

197-
- Add the logo of your Service to [`ansible-role-hubsite/assets`](https://github.com/mother-of-all-self-hosting/ansible-role-hubsite/tree/main/assets) via a pull request.
198-
- configure the `group_vars_mash_servers` file:
243+
To wire the role to Hubsite, add the configuration for it as below:
199244

200245
```yaml
201246
[...]
@@ -214,9 +259,9 @@ YOUR-SERVICE_config_mailer_protocol: "{{ 'smtp' if exim_relay_enabled else '' }}
214259
# role-specific:YOUR-SERVICE
215260
# YOUR-SERVICE
216261
hubsite_service_YOUR-SERVICE_enabled: "{{ YOUR-SERVICE_enabled }}"
217-
hubsite_service_YOUR-SERVICE_name: Adguard Home
262+
hubsite_service_YOUR-SERVICE_name: "YOUR-SERVICE Name"
218263
hubsite_service_YOUR-SERVICE_url: "https://{{ YOUR-SERVICE_hostname }}{{ YOUR-SERVICE_path_prefix }}"
219-
hubsite_service_YOUR-SERVICE_logo_location: "{{ role_path }}/assets/YOUR-SERVICE.png"
264+
hubsite_service_YOUR-SERVICE_logo_location: "{{ role_path }}/assets/YOUR-SERVICE.svg"
220265
hubsite_service_YOUR-SERVICE_description: "YOUR-SERVICE Description"
221266
hubsite_service_YOUR-SERVICE_priority: 1000
222267
# /role-specific:YOUR-SERVICE
@@ -239,8 +284,14 @@ mash_playbook_hubsite_service_list_auto_itemized:
239284
[...]
240285
```
241286

287+
💡 **Notes**:
288+
- Setting a logo is optional.
289+
- If the service of your role distributes its logo under free licenses, you can add it to [`ansible-role-hubsite/assets`](https://github.com/mother-of-all-self-hosting/ansible-role-hubsite/tree/main/assets) via a pull request.
290+
242291
</details>
243292

244293
### Additional hints
245294

246-
- Add a line like `# Project source code URL: YOUR-SERVICE-GIT-REPO` to your Ansible role's `defaults/main.yml` file, so that [`bin/feeds.py`](/bin/feeds.py) can automatically find the Atom/RSS feed for new releases.
295+
Please consider to add a line like `# Project source code URL: YOUR-SERVICE-GIT-REPO` to your Ansible role's `defaults/main.yml` file, so that [`bin/feeds.py`](/bin/feeds.py) can automatically find the Atom/RSS feed for new releases.
296+
297+
If you have any questions, you are welcomed to join the Matrix room for the MASH playbook and free free to ask: https://matrix.to/#/%23mash-playbook:devture.com

0 commit comments

Comments
 (0)