Updated role

This commit is contained in:
Kevin Veen-Birkenbach 2023-12-05 22:17:47 +01:00
parent 4d38a79a3a
commit 16d04d3c62
5 changed files with 65 additions and 21 deletions

View File

@ -1,7 +1,42 @@
# role mybb
## install plugins
Extract the plugins to /mnt.
Execute:
# Docker MyBB Role
This README documents the Ansible role for setting up a MyBB forum using Docker. The role automates the deployment of MyBB, a free and open-source forum software, using Docker containers and manages the necessary configurations and dependencies.
## Role Name: Docker MyBB
### Dependencies
- nginx-docker-reverse-proxy
### Variables
- `docker_compose_instance_directory`: The directory where Docker Compose files for MyBB are stored.
- `conf_d_docker_directory`: Directory for Docker Nginx configuration.
- `default_conf_server_file`: The default Nginx configuration file for the server.
- `conf_d_server_directory`: The Nginx server's configuration directory.
### Tasks
1. **Domain Certificate Retrieval:** Automates the process of obtaining SSL certificates for the specified domain using Certbot.
2. **Nginx Configuration:** Handles the configuration of Nginx for the MyBB domain.
3. **Directory Creation:** Ensures the creation of necessary directories including parent directories as required.
4. **MyBB and Nginx Configuration:** Manages the configuration for MyBB and Nginx, including setting up the `default.conf` file.
5. **Docker Compose Setup:** Adds and manages the `docker-compose.yml` file necessary for running MyBB with Docker.
### Usage
#### Install Plugins
To install MyBB plugins, extract them to a mounted volume and sync using the provided `docker run` command
```bash
docker run --rm -v mybb-data:/target/ -v /mnt/:/origin/ "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv /origin/inc/plugins/ /target/"
```
#### Running the Role
Execute the Ansible playbook containing this role to set up MyBB in a Docker environment.
### Docker Compose Configuration
The `docker-compose.yml.j2` template outlines the services required for MyBB, including the application server, Nginx web server, and database (MariaDB).
### Additional Information
- For detailed configuration and customization, refer to the contents of the `default.conf` template and the `docker-compose.yml.j2` template.
- Ensure that the environment variables and paths are correctly set as per your system's configuration.
### Created with ChatGPT
This README was created with the assistance of ChatGPT, based on a conversation held at this [link](https://chat.openai.com/share/83828f9a-b817-48d8-86ed-599f64850b4d). ChatGPT provided guidance on structuring this document and outlining the key components of the Docker MyBB role.

View File

@ -2,7 +2,7 @@
- name: recreate mybb
command:
cmd: docker-compose -p mybb up -d --force-recreate
chdir: "{{path_docker_compose_files}}mybb/"
chdir: "{{docker_compose_instance_directory}}"
environment:
COMPOSE_HTTP_TIMEOUT: 600
DOCKER_CLIENT_TIMEOUT: 600

View File

@ -3,20 +3,26 @@
command: certbot certonly --agree-tos --email {{administrator_email}} --non-interactive --webroot -w /var/lib/letsencrypt/ -d {{domain}}
- name: configure {{domain}}.conf
template: src=roles/nginx-docker-reverse-proxy/templates/domain.conf.j2 dest=/etc/nginx/conf.d/{{domain}}.conf
template:
src: "roles/nginx-docker-reverse-proxy/templates/domain.conf.j2"
dest: "/etc/nginx/conf.d/{{domain}}.conf"
notify: restart nginx
- name: create data folder
- name: "create {{conf_d_docker_directory}} and parent directories"
file:
path: "{{conf_d_docker_path}}"
path: "{{conf_d_docker_directory}}"
state: directory
mode: 0755
recurse: yes
- name: "create {{default_conf_docker_path}}"
template: src="default.conf" dest="{{default_conf_docker_path}}"
- name: "create {{default_conf_server_file}}"
template:
src: "default.conf"
dest: "{{default_conf_server_file}}"
notify: recreate mybb
- name: add docker-compose.yml
template:
src: "docker-compose.yml.j2"
dest: "{{docker_compose_instance_directory}}docker-compose.yml"
notify: recreate matomo
notify: recreate mybb

View File

@ -1,14 +1,16 @@
services:
application:
log_driver: journald
logging:
driver: journald
image: mybb/mybb:latest
restart: always
links:
- database
volumes:
- mybb-data:/var/www/html
- data:/var/www/html
server:
log_driver: journald
logging:
driver: journald
links:
- application
image: nginx:mainline
@ -16,15 +18,17 @@ services:
ports:
- "127.0.0.1:{{http_port}}:80"
volumes:
- "{{conf_d_docker_path}}:{{conf_d_path}}"
- "mybb-data:/var/www/html:ro"
- "{{conf_d_server_directory}}:{{conf_d_docker_directory}}:ro"
- "data:/var/www/html:ro"
database:
log_driver: journald
logging:
driver: journald
image: mariadb
environment:
MYSQL_DATABASE: "mybb"
MYSQL_USER: "mybb"
MYSQL_PASSWORD: "{{mybb_database_password}}"
MARIADB_ROOT_PASSWORD: "{{mybb_database_password}}"
MARIADB_AUTO_UPGRADE: "1"
volumes:
- database:/var/lib/mysql

View File

@ -1,6 +1,5 @@
---
docker_compose_instance_directory: "{{path_docker_compose_files}}mybb/"
conf_d_path: "/etc/nginx/conf.d/"
conf_d_docker_path: "/etc/docker/applications/mybb{{conf_d_path}}"
default_conf_docker_path: "{{conf_d_docker_path}}default.conf"
conf_d_server_directory: "{{docker_compose_instance_directory}}conf.d/"
default_conf_server_file: "{{conf_d_docker_directory}}default.conf"
conf_d_docker_directory: "/etc/nginx/conf.d/"