Minecraft
Note
This page has been archived and kept for reference.
The Minecraft playbook is used to deploy Minecraft servers on Ubuntu Server 22.04 LTS in my Homelab.
Ansible Playbook
The playbook configures two Minecraft servers, minecraft01
and minecraft02
; each with different configuration. Both Minecraft servers are deployed using the itzg/minecraft-server container image.
Vanilla Server
The minecraft01
server is deployed with Paper MC. Server specific settings are located in ansible/vars/paper_minecraft.yml
.
Modded Server
The minecraft02
server is deployed with the All the Mods 9 (ATM9) modpack. Server specific settings are located in ansible/vars/modded_minecraft.yml
.
Staging the Modpack Server ZIP File
To run ATM9 on the minecraft02
server, the modpack server ZIP file must be staged on the server prior to running the Ansible playbook.
-
Download the modpack server ZIP file from CurseForge.
-
SCP the modpack server ZIP file to
minecraft02
:ssh [email protected] mkdir -pv ~/modpacks scp /path/to/Server-Files-0.2.41.zip minecraft02.net.dbren.uk:~/modpacks/
-
Update the
ansible/vars/modded_minecraft.yml
file with the correct modpack server ZIP file name:
Server Files & World Backup
The Ansible playbook is configured to deploy the itzg/mc-backup container image which will backup the Minecraft server files and world to a Backblaze B2 S3 bucket. This occurs every 24 hours.
See dbrennand | home-ops Backblaze for more information on how to configure the Backblaze B2 S3 bucket.
itzg/mc-backup - Removing Stale Locks
You may come across the following error in the logs. This occurs when the server is shut down unexpectedly during a backup and the restic lock file is not removed:
Remove the lock file by running restic unlock
:
Tailscale
Tailscale is used on the server to allow friends to connect to the server remotely.
OpenTofu
Both servers are deployed using OpenTofu.
Usage
-
Clone the repository:
-
Create the Python virtual environment and install Ansible dependencies:
-
Verify Ansible can connect to the server:
-
Run the playbook: