Skip to content

Commit c19de41

Browse files
authored
Add PrivateBin (#451)
1 parent 311967d commit c19de41

File tree

5 files changed

+269
-0
lines changed

5 files changed

+269
-0
lines changed

docs/services/privatebin.md

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2020 - 2024 MDAD project contributors
3+
SPDX-FileCopyrightText: 2020 - 2024 Slavi Pantaleev
4+
SPDX-FileCopyrightText: 2020 Aaron Raimist
5+
SPDX-FileCopyrightText: 2020 Chris van Dijk
6+
SPDX-FileCopyrightText: 2020 Dominik Zajac
7+
SPDX-FileCopyrightText: 2020 Mickaël Cornière
8+
SPDX-FileCopyrightText: 2022 François Darveau
9+
SPDX-FileCopyrightText: 2022 Julian Foad
10+
SPDX-FileCopyrightText: 2022 Warren Bailey
11+
SPDX-FileCopyrightText: 2023 Antonis Christofides
12+
SPDX-FileCopyrightText: 2023 Felix Stupp
13+
SPDX-FileCopyrightText: 2023 Julian-Samuel Gebühr
14+
SPDX-FileCopyrightText: 2023 Pierre 'McFly' Marty
15+
SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
16+
17+
SPDX-License-Identifier: AGPL-3.0-or-later
18+
-->
19+
20+
# PrivateBin
21+
22+
The playbook can install and configure [PrivateBin](https://privatebin.info) for you.
23+
24+
PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data.
25+
26+
See the project's [documentation](https://github.com/PrivateBin/PrivateBin/tree/master/doc) to learn what PrivateBin does and why it might be useful to you.
27+
28+
For details about configuring the [Ansible role for PrivateBin](https://codeberg.org/acioustick/ansible-role-privatebin), you can check them via:
29+
- 🌐 [the role's documentation](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md) online
30+
- 📁 `roles/galaxy/privatebin/docs/configuring-privatebin.md` locally, if you have [fetched the Ansible roles](../installing.md)
31+
32+
## Dependencies
33+
34+
This service requires the following other services:
35+
36+
- [Traefik](traefik.md) reverse-proxy server
37+
- (optional) MySQL / [MariaDB](mariadb.md) database
38+
- (optional) [Postgres](postgres.md) database — required on the default configuration
39+
- (optional) [YOURLS](yourls.md)
40+
41+
## Adjusting the playbook configuration
42+
43+
To enable this service, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process:
44+
45+
```yaml
46+
########################################################################
47+
# #
48+
# privatebin #
49+
# #
50+
########################################################################
51+
52+
privatebin_enabled: true
53+
54+
privatebin_hostname: mash.example.com
55+
privatebin_path_prefix: bin
56+
57+
########################################################################
58+
# #
59+
# /privatebin #
60+
# #
61+
########################################################################
62+
```
63+
64+
### Configure a storage for pastes (optional)
65+
66+
PrivateBin instance requires a storage backend to work. The available options: PostgreSQL (default), local filesystem, MySQL, SQLite, Google Cloud Storage, and Amazon S3.
67+
68+
As the playbook enables the [PostgreSQL service](postgres.md) on `vars.yml` by default, it is configured to use it as the default backend. If it is fine for you, you do not have to add configuration for the storage.
69+
70+
See below for the instruction to use one of the others.
71+
72+
#### Local filesystem
73+
74+
To use local filesystem database for a storage, you need to add a Docker volume to mount in the container, so that the directory for storing files is shared with the host machine.
75+
76+
To add the volume, prepare a directory on the host machine and add the following configuration to your `vars.yml` file, setting the directory path to `src`:
77+
78+
```yaml
79+
privatebin_container_additional_volumes:
80+
- type: bind
81+
src: /path/on/the/host
82+
dst: /srv/data
83+
options:
84+
```
85+
86+
Make sure permissions of the directory specified to `src`. If not correctly specified, the service returns a permission error while trying to put data to it.
87+
88+
#### MySQL
89+
90+
To use MySQL for a storage, add the following configuration to your `vars.yml` file:
91+
92+
```yaml
93+
privatebin_config_model: MySQL
94+
```
95+
96+
See [here](mariadb.md) on the role's documentation for details about how to configure a MariaDB instance with the playbook.
97+
98+
#### Google Cloud Storage / Amazon S3
99+
100+
See [this section](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md#configure-a-storage-for-pastes) on the role's documentation for details about how to configure a storage at Google Cloud Storage or Amazon S3.
101+
102+
### Configure a URL shortener (optional)
103+
104+
It is possible to have the PrivateBin instance use a URL shortener such as Bit.ly and a [YOURLS](https://yourls.org) instance, so that users can shorten a URL of a paste with it. **It is recommended to use a self-hosted shortener only and set a password to a paste, as the shortener will leak the paste's encryption key.**
105+
106+
YOURLS is available on the playbook. See [here](yourls.md) for details about how to install it.
107+
108+
**Notes**
109+
- YOURLS requires a MariaDB instance (see [here](mariadb.md) for details about configuring it with the playbook); if PostgreSQL is going to be used for PrivateBin (or other services), you need to use both of them.
110+
- If you are going to install PrivateBin and YOURLS at the same time, **you need to complete installation of YOURLS at first** by visiting its admin UI available at the specified hostname with `/admin/` such as `yourls.example.com/admin/`. Otherwise the function to shorten a paste's URL does not work. See [here](yourls.md#usage) for the instruction to complete instalation.
111+
112+
#### Use a private YOURLS instance with API access key
113+
114+
If you are using the private YOURLS instance, you might probably want to disallow a third party to use it without credentials. You can configure authentication by adding the following configuration to your `vars.yml` file:
115+
116+
```yaml
117+
privatebin_config_yourlsapi_enabled: true
118+
119+
# Set the "signature" (access key) issued by the YOURLS instance for using the account
120+
privatebin_config_yourlsapi_signature: ''
121+
122+
# Set URL of the YOURLS instance's API, called to shorten a paste URL
123+
privatebin_config_yourlsapi_url: https://yourls.example.com/yourls-api.php
124+
```
125+
126+
You can find the "signature" and API's URL on the "Tools" page of the YOURLS instance.
127+
128+
### Extending the configuration
129+
130+
There are some additional things you may wish to configure about the component.
131+
132+
Take a look at:
133+
134+
- [PrivateBin](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin)'s [`defaults/main.yml`](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/defaults/main.yml) for some variables that you can customize via your `vars.yml` file.
135+
136+
See its [configuration sample file](https://github.com/PrivateBin/PrivateBin/blob/master/cfg/conf.sample.php) and the [documentation](https://github.com/PrivateBin/PrivateBin/wiki/Configuration) for a complete list of PrivateBin's config options such as [discussion](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md#configure-the-discussion-feature-optional), [password](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md#configure-the-password-feature-optional), [file upload](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md#configure-the-file-upload-feature-optional), and [default theme](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md#configure-the-default-template-optional) features.
137+
138+
## Usage
139+
140+
After running the command for installation, PrivateBin becomes available at the specified hostname with the prefix (`mash.example.com/bin`).
141+
142+
## Troubleshooting
143+
144+
See [this section](https://github.com/mother-of-all-self-hosting/ansible-role-privatebin/blob/main/docs/configuring-privatebin.md#troubleshooting) on the role's documentation for details.

docs/supported-services.md

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
9494
| [Postgis](https://postgis.net/) | A spatial database extender for PostgreSQL object-relational database | [Link](services/postgis.md) |
9595
| [Postgres](https://www.postgresql.org) | A powerful, open source object-relational database system | [Link](services/postgres.md) |
9696
| [Postgres Backup](https://github.com/prodrigestivill/docker-postgres-backup-local) | A solution for backing up PostgresSQL to local filesystem with periodic backups. | [Link](services/postgres-backup.md) |
97+
| [PrivateBin](https://privatebin.info/) | Minimalist, open source online pastebin where the server has zero knowledge of pasted data. | [Link](services/privatebin.md) |
9798
| [Prometheus](https://prometheus.io/) | A metrics collection and alerting monitoring solution | [Link](services/prometheus.md) |
9899
| [Prometheus Blackbox Exporter](https://github.com/prometheus/blackbox_exporter) | Blackbox probing of HTTP/HTTPS/DNS/TCP/ICMP and gRPC endpoints | [Link](services/prometheus-blackbox-exporter.md) |
99100
| [Prometheus Node Exporter](https://github.com/prometheus/node_exporter) | Exporter for machine metrics | [Link](services/prometheus-node-exporter.md) |

templates/group_vars_mash_servers

+116
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ mash_playbook_devture_systemd_service_manager_services_list_auto_itemized:
511511
{{ ({'name': (postgres_backup_identifier + '.service'), 'priority': 5000, 'groups': ['mash', 'backup', 'postgres-backup']} if postgres_backup_enabled else omit) }}
512512
# /role-specific:postgres_backup
513513

514+
# role-specific:privatebin
515+
- |-
516+
{{ ({'name': (privatebin_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'privatebin']} if privatebin_enabled else omit) }}
517+
# /role-specific:privatebin
518+
514519
# role-specific:prometheus
515520
- |-
516521
{{ ({'name': (prometheus_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'metrics', 'prometheus']} if prometheus_enabled else omit) }}
@@ -1050,6 +1055,17 @@ mash_playbook_postgres_managed_databases_auto_itemized:
10501055
}}
10511056
# /role-specific:plausible
10521057

1058+
# role-specific:privatebin
1059+
- |-
1060+
{{
1061+
({
1062+
'name': privatebin_database_postgres_name,
1063+
'username': privatebin_database_postgres_username,
1064+
'password': privatebin_database_postgres_password,
1065+
} if privatebin_enabled and privatebin_database_postgres_hostname == postgres_identifier else omit)
1066+
}}
1067+
# /role-specific:privatebin
1068+
10531069
# role-specific:prometheus_postgres_exporter
10541070
- |-
10551071
{{
@@ -3281,6 +3297,16 @@ hubsite_service_peertube_description: "Watch and upload videos"
32813297
hubsite_service_peertube_priority: 1000
32823298
# /role-specific:peertube
32833299

3300+
# role-specific:privatebin
3301+
# PrivateBin
3302+
hubsite_service_privatebin_enabled: "{{ privatebin_enabled }}"
3303+
hubsite_service_privatebin_name: PrivateBin
3304+
hubsite_service_privatebin_url: "{{ privatebin_scheme }}://{{ privatebin_hostname }}{{ privatebin_path_prefix }}"
3305+
hubsite_service_privatebin_logo_location: ""
3306+
hubsite_service_privatebin_description: "Minimalist, open source online pastebin where the server has zero knowledge of pasted data."
3307+
hubsite_service_privatebin_priority: 1000
3308+
# /role-specific:privatebin
3309+
32843310
# role-specific:radicale
32853311
# Radicale
32863312
hubsite_service_radicale_enabled: "{{ radicale_enabled }}"
@@ -3741,6 +3767,19 @@ mash_playbook_hubsite_service_list_auto_itemized:
37413767
}}
37423768
# /role-specific:peertube
37433769

3770+
# role-specific:privatebin
3771+
- |-
3772+
{{
3773+
({
3774+
'name': hubsite_service_privatebin_name,
3775+
'url': hubsite_service_privatebin_url,
3776+
'logo_location': hubsite_service_privatebin_logo_location,
3777+
'description': hubsite_service_privatebin_description,
3778+
'priority': hubsite_service_privatebin_priority,
3779+
} if hubsite_service_privatebin_enabled else omit)
3780+
}}
3781+
# /role-specific:privatebin
3782+
37443783
# role-specific:radicale
37453784
- |-
37463785
{{
@@ -4619,6 +4658,17 @@ mash_playbook_mariadb_managed_databases_auto_itemized:
46194658
}}
46204659
# /role-specific:authelia
46214660

4661+
# role-specific:privatebin
4662+
- |-
4663+
{{
4664+
({
4665+
'name': privatebin_database_mysql_name,
4666+
'username': privatebin_database_mysql_username,
4667+
'password': privatebin_database_mysql_password,
4668+
} if privatebin_enabled and privatebin_database_mysql_hostname == mariadb_identifier else omit)
4669+
}}
4670+
# /role-specific:privatebin
4671+
46224672
# role-specific:wordpress
46234673
- |-
46244674
{{
@@ -5688,6 +5738,72 @@ postgis_managed_databases_auto: |
56885738

56895739

56905740

5741+
# role-specific:privatebin
5742+
########################################################################
5743+
# #
5744+
# privatebin #
5745+
# #
5746+
########################################################################
5747+
5748+
privatebin_enabled: false
5749+
5750+
privatebin_identifier: "{{ mash_playbook_service_identifier_prefix }}privatebin"
5751+
5752+
privatebin_uid: "{{ mash_playbook_uid }}"
5753+
privatebin_gid: "{{ mash_playbook_gid }}"
5754+
5755+
privatebin_base_path: "{{ mash_playbook_base_path }}/{{ mash_playbook_service_base_directory_name_prefix }}privatebin"
5756+
5757+
privatebin_systemd_required_services_list_auto: |
5758+
{{
5759+
([mariadb_identifier ~ '.service'] if mariadb_enabled | default(false) and privatebin_database_mysql_hostname == mariadb_identifier else [])
5760+
+
5761+
([postgres_identifier ~ '.service'] if postgres_enabled | default(false) and privatebin_database_postgres_hostname == postgres_identifier else [])
5762+
}}
5763+
5764+
privatebin_container_additional_networks_auto: |
5765+
{{
5766+
([mash_playbook_reverse_proxyable_services_additional_network] if mash_playbook_reverse_proxyable_services_additional_network else [])
5767+
+
5768+
([mariadb_container_network] if mariadb_enabled | default(false) and privatebin_database_mysql_hostname == mariadb_identifier and privatebin_container_network != mariadb_container_network else [])
5769+
+
5770+
([postgres_container_network] if postgres_enabled | default(false) and privatebin_database_postgres_hostname == postgres_identifier and privatebin_container_network != postgres_container_network else [])
5771+
}}
5772+
5773+
privatebin_container_labels_traefik_enabled: "{{ mash_playbook_traefik_labels_enabled }}"
5774+
privatebin_container_labels_traefik_docker_network: "{{ mash_playbook_reverse_proxyable_services_additional_network }}"
5775+
5776+
# Note that valid values for "privatebin_config_model" are Filesystem, GoogleCloudStorage, MySQL, SQLite, PostgreSQL, and S3, meaning neither MySQL (MariaDB) nor Postgres would be a must.
5777+
privatebin_config_model: PostgreSQL
5778+
5779+
# role-specific:mariadb
5780+
# This is activated only if MariaDB is enabled and "privatebin_config_model" is set to "MySQL".
5781+
privatebin_database_mysql_hostname: "{{ mariadb_identifier if mariadb_enabled | default(false) and privatebin_config_model == 'MySQL' else '' }}"
5782+
privatebin_database_mysql_username: "{{ privatebin_identifier }}"
5783+
privatebin_database_mysql_password: "{{ '%s' | format(mash_playbook_generic_secret_key) | password_hash('sha512', 'db.privatebinm', rounds=655555) | to_uuid }}"
5784+
# /role-specific:mariadb
5785+
5786+
# role-specific:postgres
5787+
# This is activated only if Postgres is enabled and "privatebin_config_model" is set to "PostgreSQL".
5788+
privatebin_database_postgres_hostname: "{{ postgres_identifier if postgres_enabled | default(false) and privatebin_config_model == 'PostgreSQL' else '' }}"
5789+
privatebin_database_postgres_username: "{{ privatebin_identifier }}"
5790+
privatebin_database_postgres_password: "{{ '%s' | format(mash_playbook_generic_secret_key) | password_hash('sha512', 'db.privatebinp', rounds=655555) | to_uuid }}"
5791+
# /role-specific:postgres
5792+
5793+
# role-specific:traefik
5794+
privatebin_container_labels_traefik_entrypoints: "{{ traefik_entrypoint_primary }}"
5795+
privatebin_container_labels_traefik_tls_certResolver: "{{ traefik_certResolver_primary }}"
5796+
# /role-specific:traefik
5797+
5798+
########################################################################
5799+
# #
5800+
# /privatebin #
5801+
# #
5802+
########################################################################
5803+
# /role-specific:privatebin
5804+
5805+
5806+
56915807
# role-specific:prometheus
56925808
########################################################################
56935809
# #

templates/requirements.yml

+4
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@
335335
version: v17-3
336336
name: postgres_backup
337337
activation_prefix: postgres_backup_
338+
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-privatebin.git
339+
version: v1.7.6-1
340+
name: privatebin
341+
activation_prefix: privatebin_
338342
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-prometheus.git
339343
version: v2.55.1-3
340344
name: prometheus

templates/setup.yml

+4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@
371371
- role: galaxy/postgis
372372
# /role-specific:postgis
373373

374+
# role-specific:privatebin
375+
- role: galaxy/privatebin
376+
# /role-specific:privatebin
377+
374378
# role-specific:prometheus
375379
- role: galaxy/prometheus
376380
# /role-specific:prometheus

0 commit comments

Comments
 (0)