mirror of
https://github.com/mother-of-all-self-hosting/mash-playbook
synced 2024-11-10 06:14:17 +00:00
Add support for MongoDB
This commit is contained in:
parent
aed234aace
commit
2d64c76397
5 changed files with 131 additions and 0 deletions
98
docs/services/mongodb.md
Normal file
98
docs/services/mongodb.md
Normal file
|
@ -0,0 +1,98 @@
|
|||
# MongoDB
|
||||
|
||||
[MongoDB](https://www.mongodb.com/) is a source-available cross-platform document-oriented (NoSQL) database program.
|
||||
|
||||
Some of the services installed by this playbook require a MongoDB database.
|
||||
|
||||
Enabling the MongoDB database service will automatically wire all other services which require such a database to use it.
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
To enable this service, add the following configuration to your `vars.yml` file and re-run the [installation](../installing.md) process:
|
||||
|
||||
```yaml
|
||||
########################################################################
|
||||
# #
|
||||
# mongodb #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
mongodb_enabled: true
|
||||
|
||||
# Put a strong password below, generated with `pwgen -s 64 1` or in another way
|
||||
mongodb_root_password: ''
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /mongodb #
|
||||
# #
|
||||
########################################################################
|
||||
```
|
||||
|
||||
## Importing
|
||||
|
||||
### Importing an existing MongoDB database from another installation (optional)
|
||||
|
||||
Follow this section if you'd like to import your database from a previous installation.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
The playbook supports importing **gzipped** MongoDB database dumps (created with `mongodump --gzip -o /directory`).
|
||||
|
||||
Before doing the actual import, **you need to upload your MongoDB dump file to the server** (any path is okay).
|
||||
|
||||
|
||||
### Importing a dump
|
||||
|
||||
To import, run this command (make sure to replace `SERVER_PATH_TO_POSTGRES_DUMP_FILE` with a file path on your server):
|
||||
|
||||
```sh
|
||||
just run-tags import-mongodb \
|
||||
--extra-vars=mongodb_server_path_dump=SERVER_PATH_TO_MONGODB_DUMP_DIRECTORY
|
||||
```
|
||||
|
||||
**Note** that `SERVER_PATH_TO_MONGODB_DUMP_DIRECTORY` must be a path to a **gzipped** MongoDB dump directory on the server (not on your local machine!)
|
||||
|
||||
|
||||
## Maintenance
|
||||
|
||||
This section shows you how to perform various maintenance tasks related to the MongoDB database server used by various components of this playbook.
|
||||
|
||||
Table of contents:
|
||||
|
||||
- [Getting a database terminal](#getting-a-database-terminal), for when you wish to execute SQL queries
|
||||
|
||||
### Getting a database terminal
|
||||
|
||||
You can use the `/mash/mongodb/bin/cli` tool to get interactive terminal access using the MongoDB Shell [mongosh](https://www.mongodb.com/docs/mongodb-shell/).
|
||||
|
||||
By default, this tool puts you in the `admin` database, which contains nothing.
|
||||
|
||||
To see the available databases, run `show dbs`.
|
||||
|
||||
To change to another database (for example `infisical`), run `use infisical`.
|
||||
|
||||
To see the available tables in the current database, run `show tables`.
|
||||
|
||||
You can then proceed to write queries. Example: `db.users.find()`
|
||||
|
||||
**Be careful**. Modifying the database directly (especially as services are running) is dangerous and may lead to irreversible database corruption.
|
||||
When in doubt, consider [making a backup](#backing-up-mongodb).
|
||||
|
||||
|
||||
### Backing up MongoDB
|
||||
|
||||
To make a one-off back up of the current MongoDB database, make sure it's running and then execute a command like this on the server:
|
||||
|
||||
```bash
|
||||
# Prepare the backup directory
|
||||
mkdir /path-to-some-directory
|
||||
chown mash:mash /path-to-some-directory
|
||||
|
||||
# Back up
|
||||
/mash/mongodb/bin/dump-all /path-to-some-directory
|
||||
```
|
||||
|
||||
Restoring a backup made this way can be done by [importing it](#importing).
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
| [Lago](https://www.getlago.com/) | Open-source metering and usage-based billing | [Link](services/lago.md) |
|
||||
| [MariaDB](https://mariadb.org/) | A powerful, open source object-relational database system | [Link](services/mariadb.md) |
|
||||
| [Matrix Rooms Search API](https://gitlab.com/etke.cc/mrs/api) | A fully-featured, standalone, matrix rooms search service. | [Link](services/mrs.md) |
|
||||
| [MongoDB](https://www.mongodb.com/) | A source-available cross-platform document-oriented (NoSQL) database program. | [Link](services/mongodb.md) |
|
||||
| [Miniflux](https://miniflux.app/) | Minimalist and opinionated feed reader. | [Link](services/miniflux.md) |
|
||||
| [Mobilizon](https://joinmobilizon.org/en/) | An ActivityPub/Fediverse server to create and share events. | [Link](services/mobilizon.md) |
|
||||
| [Navidrome](https://www.navidrome.org/) | [Subsonic-API](http://www.subsonic.org/pages/api.jsp) compatible music server | [Link](services/navidrome.md)
|
||||
|
|
|
@ -141,6 +141,8 @@ devture_systemd_service_manager_services_list_auto: |
|
|||
+
|
||||
([{'name': (miniflux_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'miniflux']}] if miniflux_enabled else [])
|
||||
+
|
||||
([{'name': (mongodb_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'mongodb']}] if mongodb_enabled else [])
|
||||
+
|
||||
([{'name': (mrs_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'mrs']}] if mrs_enabled else [])
|
||||
+
|
||||
([{'name': (navidrome_identifier + '.service'), 'priority': 2000, 'groups': ['mash', 'navidrome']}] if navidrome_enabled else [])
|
||||
|
@ -1620,6 +1622,31 @@ mobilizon_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certRes
|
|||
|
||||
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# mongodb #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
mongodb_enabled: false
|
||||
|
||||
mongodb_identifier: "{{ mash_playbook_service_identifier_prefix }}mongodb"
|
||||
|
||||
mongodb_uid: "{{ mash_playbook_uid }}"
|
||||
mongodb_gid: "{{ mash_playbook_gid }}"
|
||||
|
||||
mongodb_base_path: "{{ mash_playbook_base_path }}/{{ mash_playbook_service_base_directory_name_prefix }}mongodb"
|
||||
|
||||
mongodb_managed_databases_auto: []
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
# /mongodb #
|
||||
# #
|
||||
########################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
########################################################################
|
||||
# #
|
||||
|
|
|
@ -97,6 +97,9 @@
|
|||
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-mobilizon.git
|
||||
version: v3.1.0-1
|
||||
name: mobilizon
|
||||
- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-mongodb.git
|
||||
version: v6.0.6-0
|
||||
name: mongodb
|
||||
- src: git+https://gitlab.com/etke.cc/mrs/ansible-role-mrs.git
|
||||
version: v0.0.0-9
|
||||
name: mrs
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
|
||||
- role: galaxy/com.devture.ansible.role.postgres_backup
|
||||
|
||||
- role: galaxy/mongodb
|
||||
|
||||
- role: galaxy/com.devture.ansible.role.container_socket_proxy
|
||||
|
||||
- role: galaxy/com.devture.ansible.role.traefik
|
||||
|
|
Loading…
Reference in a new issue