refactor(web-app-mybb): remove obsolete Installation.md, introduce schema for secret_pin, and rework task/vars handling

- Removed outdated Installation.md (manual plugin instructions no longer needed)
- Added schema/main.yml with validation for secret_pin
- Added config.php.j2 template to manage DB + admin config
- Refactored tasks/main.yml to deploy config.php instead of legacy docker-compose
- Removed setup-domain.yml (TLS/domain handling moved to core roles)
- Updated docker-compose.yml.j2 to mount config.php and use new vars
- Cleaned up vars/main.yml: standardized MYBB_* variable names, added MYBB_SECRET_PIN, config paths, and container port

See ChatGPT conversation: https://chatgpt.com/share/68b0ae26-93ec-800f-8785-0da7c9303090
This commit is contained in:
2025-08-28 21:29:58 +02:00
parent 58c17bf043
commit 92f5bf6481
7 changed files with 68 additions and 116 deletions

View File

@@ -1,55 +0,0 @@
# Installation
## Multi Domain Installation
If you want to access your mybb over multiple domains, keep the following in mind:
- Set Cookie Domain to nothing
- Access mybb for installation via mybb.<PRIMARY_DOMAIN>
- Set the Board Url to mybb.<PRIMARY_DOMAIN>
## Manual Installation of MyBB Plugins
This guide describes the process of manually installing MyBB plugins in your Docker-MyBB environment. This can be useful if you want to quickly test plugins or do not wish to execute the Ansible role.
### Steps for Manual Installation
1. **Prepare Plugin Files:**
- Download the desired MyBB plugin zip files.
2. **Copy plugin to host:**
- ```bash scp <plugin> administrator@<server>:/opt/docker/mybb/plugins```
3. **Unzip Plugin Files on the Host:**
- Unzip the plugin zip files in the host's plugin directory:
```bash
unzip /opt/docker/mybb/plugins/<plugin-file>.zip -d /opt/docker/mybb/plugins/
```
- Replace `<plugin-file>.zip` with the name of the plugin zip file.
- Repeat this step for each plugin.
4. **Access the Docker Container:**
- Open a terminal or SSH session on the server where the Docker container is running.
5. **Copy Unzipped Plugin Files to the Container:**
- Copy the unzipped plugin files from the host directory to the Docker container:
```bash
docker compose cp /opt/docker/mybb/plugins/<unzipped-plugin-folder> application:/var/www/html/inc/plugins/
```
- Replace `<unzipped-plugin-folder>` with the name of the unzipped plugin folder.
6. **Restart the Container:**
- Execute the following command to restart the MyBB container:
```bash
docker-compose -p mybb up -d --force-recreate
```
- This ensures all changes take effect.
7. **Activate Plugins in the MyBB Admin Panel:**
- Open the MyBB admin panel in your web browser.
- Navigate to the plugin settings and activate the newly installed plugins.
### Important Notes
- Ensure you use the correct paths and filenames.
- Do not forget to regularly back up your MyBB database and files before making changes.
- If encountering issues, refer to the MyBB documentation or specific instructions from the plugin author.

View File

@@ -0,0 +1,8 @@
credentials:
secret_pin:
description: >
Optional secret PIN required for accessing the MyBB Admin Control Panel.
If set, administrators must enter this PIN in addition to their username
and password when logging into the ACP.
algorithm: "sha256"
validation: "^[a-f0-9]{64}$"

View File

@@ -1,36 +1,25 @@
- block:
- name: Include dependency 'srv-proxy-core'
include_role:
name: srv-proxy-core
when: run_once_srv_proxy_core is not defined
- include_tasks: utils/run_once.yml
when: run_once_web_app_mybb is not defined
- name: "load docker, db and proxy for {{ application_id }}"
include_role:
name: cmp-db-docker-proxy
vars:
docker_compose_flush_handlers: false
proxy_extra_configuration: "sub_filter '{{MYBB_DOMAIN}}' '{{ MYBB_DOMAIN }}';"
- name: "include tasks setup-domain.yml with {{ domains | get_domain(application_id) }}"
include_tasks: setup-domain.yml
loop: "{{ mybb_domains + [source_domain] }}"
loop_control:
loop_var: domain
- name: "load docker and db for {{ application_id }}"
include_role:
name: cmp-db-docker
- name: "create {{docker_compose_instance_confd_directory}} and parent directories"
- name: "create {{ MYBB_NGINX_CONF_DIR_HOST }} and parent directories"
file:
path: "{{docker_compose_instance_confd_directory}}"
path: "{{ MYBB_NGINX_CONF_DIR_HOST }}"
state: directory
mode: "0755"
recurse: yes
- name: "create {{docker_compose_instance_confd_defaultconf_file}}"
- name: "Deploy {{ MYBB_NGINX_DEFAULT_CONF_HOST }}"
template:
src: "default.conf.j2"
dest: "{{docker_compose_instance_confd_defaultconf_file}}"
dest: "{{ MYBB_NGINX_DEFAULT_CONF_HOST }}"
notify: docker compose up
- name: add docker-compose.yml
- name: "Deploy {{ MYBB_CONFIG_HOST_PATH }}"
template:
src: "docker-compose.yml.j2"
dest: "{{ docker_compose.directories.instance }}docker-compose.yml"
notify: docker compose up
src: "config.php.j2"
dest: "{{ MYBB_CONFIG_HOST_PATH }}"
mode: '0644'

View File

@@ -1,13 +0,0 @@
- name: "include role receive certbot certificate"
include_role:
name: srv-tls-core
vars:
domain: "{{ domains | get_domain(application_id) }}"
- name: configure {{ domains | get_domain(application_id) }}.conf
template:
src: "roles/srv-proxy-core/templates/vhost/basic.conf.j2"
dest: "{{ NGINX.DIRECTORIES.HTTP.SERVERS }}{{ domains | get_domain(application_id) }}.conf"
notify: restart openresty
vars:
proxy_extra_configuration: "sub_filter '{{source_domain}}' '{{ domains | get_domain(application_id) }}';"

View File

@@ -0,0 +1,13 @@
<?php
$config = array();
$config['database']['type'] = 'mysqli';
$config['database']['database'] = '{{ database_name }}';
$config['database']['table_prefix'] = 'mybb_';
$config['database']['hostname'] = '{{ database_host }}';
$config['database']['port'] = '{{ database_port }}';
$config['database']['username'] = '{{ database_username }}';
$config['database']['password'] = '{{ database_password }}';
$config['database']['encoding'] = 'utf8mb4';
$config['super_admins'] = '{{ MYBB_ADMIN_USER_ID }}';
$config['secret_pin'] = '{{ MYBB_SECRET_PIN }}';
$config['admin_dir'] = 'admin';

View File

@@ -1,11 +1,8 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %}
application:
logging:
driver: journald
options:
tag: "mybb_application"
image: {{ mybb_image }}:{{ mybb_version }}
container_name: {{ mybb_name }}
{% include 'roles/docker-container/templates/base.yml.j2' %}
image: {{ MYBB_IMAGE }}:{{ MYBB_VERSION }}
container_name: {{ MYBB_CONTAINER }}
restart: {{ DOCKER_RESTART_POLICY }}
volumes:
- data:/var/www/html
@@ -13,21 +10,20 @@
{% include 'roles/docker-container/templates/networks.yml.j2' %}
server:
logging:
driver: journald
options:
tag: "mybb_server"
{% include 'roles/docker-container/templates/base.yml.j2' %}
image: nginx:mainline
restart: {{ DOCKER_RESTART_POLICY }}
ports:
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}"
volumes:
- "{{docker_compose_instance_confd_directory}}:{{target_mount_conf_d_directory}}:ro"
- "{{ MYBB_NGINX_CONF_DIR_HOST }}:{{ MYBB_NGINX_CONF_DIR_DOCK }}:ro"
- "{{ MYBB_CONFIG_HOST_PATH }}:{{ MYBB_CONFIG_DOCK_PATH }}:ro"
- "data:/var/www/html:ro"
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data:
name: {{ mybb_volume }}
name: {{ MYBB_VOLUME }}
{% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -1,11 +1,25 @@
---
application_id: "web-app-mybb"
docker_compose_instance_confd_directory: "{{ docker_compose.directories.instance }}conf.d/"
docker_compose_instance_confd_defaultconf_file: "{{docker_compose_instance_confd_directory}}default.conf"
target_mount_conf_d_directory: "{{ NGINX.DIRECTORIES.HTTP.SERVERS }}"
source_domain: "mybb.{{ PRIMARY_DOMAIN }}"
database_type: "mariadb"
mybb_version: "{{ applications | get_app_conf(application_id, 'docker.services.mybb.version', True) }}"
mybb_image: "{{ applications | get_app_conf(application_id, 'docker.services.mybb.image', True) }}"
mybb_name: "{{ applications | get_app_conf(application_id, 'docker.services.mybb.name', True) }}"
mybb_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) }}"
# General
application_id: "web-app-mybb"
database_type: "mariadb"
container_port: 80
# MyBB
## Credentials
MYBB_SECRET_PIN: "{{ applications | get_app_conf(application_id, 'credentials.secret_pin') }}"
## Server
MYBB_NGINX_CONF_DIR_HOST: "{{ docker_compose.directories.instance }}conf.d/"
MYBB_NGINX_CONF_DIR_DOCK: "{{ NGINX.DIRECTORIES.CONFIGURATION }}"
MYBB_NGINX_DEFAULT_CONF_HOST: "{{ MYBB_NGINX_CONF_DIR_HOST }}default.conf"
## Application
MYBB_ADMIN_USER_ID: 1
MYBB_DOMAIN: "{{ domains | get_domain(application_id) }}"
MYBB_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.mybb.version') }}"
MYBB_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.mybb.image') }}"
MYBB_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.mybb.name') }}"
MYBB_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}"
MYBB_CONFIG_HOST_PATH: "{{ [docker_compose.directories.instance, 'config.php'] | path_join }}"
MYBB_CONFIG_DOCK_PATH: "/var/www/html/inc/config.php"