Initial minecraft role
Paper/Java via itzg/minecraft-server in docker compose; whitelist and ops synchronized from Ansible, RCON on localhost only, explicit EULA flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
7e2cc273a0
9 files changed
+172
No files matched your search
@@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) <year> <copyright holders>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# cloud-minecraft
|
||||||
|
|
||||||
|
Ansible role to setup a Minecraft Java Edition server (Paper by default) via docker compose,
|
||||||
|
based on the `itzg/minecraft-server` image.
|
||||||
|
|
||||||
|
- the game port is public, RCON listens on `127.0.0.1` only
|
||||||
|
- whitelist and operators are managed from Ansible (`minecraft_whitelist`, `minecraft_ops`);
|
||||||
|
the whitelist is enforced and synchronized on every start
|
||||||
|
- `minecraft_eula` must be set to `true` explicitly (Minecraft EULA: https://aka.ms/MinecraftEULA)
|
||||||
|
- world data lives in `minecraft_data_location`; for a consistent backup run
|
||||||
|
`rcon-cli save-off` and `rcon-cli save-all flush` before copying, `rcon-cli save-on` afterwards
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
cloud_apps: /opt
|
||||||
|
cloud_storage: /opt/storage
|
||||||
|
cloud_stage: prod
|
||||||
|
cloud_update: false
|
||||||
|
cloud_tzdata: Europe/Berlin
|
||||||
|
|
||||||
|
|
||||||
|
#Minecraft EULA has to be accepted explicitly: https://aka.ms/MinecraftEULA
|
||||||
|
minecraft_eula: false
|
||||||
|
|
||||||
|
minecraft_image: itzg/minecraft-server
|
||||||
|
minecraft_image_tag: java25
|
||||||
|
minecraft_type: PAPER
|
||||||
|
minecraft_version: "26.3"
|
||||||
|
minecraft_memory: 4G
|
||||||
|
|
||||||
|
minecraft_port: 25565
|
||||||
|
minecraft_rcon_port: 25575
|
||||||
|
minecraft_rcon_password: MyRconPassword!
|
||||||
|
|
||||||
|
minecraft_data_location: "{{ cloud_storage }}/minecraft-data"
|
||||||
|
|
||||||
|
minecraft_motd: "A Minecraft Server"
|
||||||
|
minecraft_difficulty: normal
|
||||||
|
minecraft_mode: survival
|
||||||
|
minecraft_max_players: 10
|
||||||
|
minecraft_view_distance: 10
|
||||||
|
minecraft_pvp: true
|
||||||
|
|
||||||
|
#player names (Java Edition)
|
||||||
|
minecraft_whitelist: []
|
||||||
|
minecraft_ops: []
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: restart minecraft
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ minecraft_inst }}"
|
||||||
|
state: present
|
||||||
|
pull: missing
|
||||||
|
recreate: always
|
||||||
|
remove_orphans: yes
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
role_name: minecraft
|
||||||
|
namespace: hahn-cloud
|
||||||
|
author: Lars Hahn
|
||||||
|
company: OpenDevChain
|
||||||
|
license: MIT
|
||||||
|
description: Role to setup a Minecraft Java Edition server
|
||||||
|
min_ansible_version: 2.7
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- 13
|
||||||
|
galaxy_tags:
|
||||||
|
- minecraft
|
||||||
|
dependencies:
|
||||||
|
- docker
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
---
|
||||||
|
- name: check minecraft eula acceptance
|
||||||
|
assert:
|
||||||
|
that: minecraft_eula | bool
|
||||||
|
fail_msg: "Set minecraft_eula: true to accept the Minecraft EULA (https://aka.ms/MinecraftEULA)."
|
||||||
|
|
||||||
|
- name: setup minecraft directories
|
||||||
|
file:
|
||||||
|
state: directory
|
||||||
|
path: "{{ item }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0750
|
||||||
|
loop:
|
||||||
|
- "{{ minecraft_dir }}"
|
||||||
|
- "{{ minecraft_inst }}"
|
||||||
|
|
||||||
|
# the container runs as uid/gid 1000
|
||||||
|
- name: setup minecraft data directory
|
||||||
|
file:
|
||||||
|
state: directory
|
||||||
|
path: "{{ minecraft_data_location }}"
|
||||||
|
owner: "1000"
|
||||||
|
group: "1000"
|
||||||
|
mode: 0750
|
||||||
|
|
||||||
|
- name: template minecraft compose file
|
||||||
|
template:
|
||||||
|
src: opt/minecraft/docker-compose.yml.j2
|
||||||
|
dest: "{{ minecraft_inst }}/docker-compose.yml"
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
notify: restart minecraft
|
||||||
|
|
||||||
|
- name: template minecraft environment
|
||||||
|
template:
|
||||||
|
src: opt/minecraft/.env.j2
|
||||||
|
dest: "{{ minecraft_inst }}/.env"
|
||||||
|
mode: 0640
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
notify: restart minecraft
|
||||||
|
|
||||||
|
- name: start minecraft
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ minecraft_inst }}"
|
||||||
|
state: present
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
### BASIC ###
|
||||||
|
EULA={{ minecraft_eula | bool | upper }}
|
||||||
|
TYPE={{ minecraft_type }}
|
||||||
|
VERSION={{ minecraft_version }}
|
||||||
|
MEMORY={{ minecraft_memory }}
|
||||||
|
TZ={{ cloud_tzdata }}
|
||||||
|
ONLINE_MODE=TRUE
|
||||||
|
|
||||||
|
### GAME ###
|
||||||
|
MOTD={{ minecraft_motd }}
|
||||||
|
DIFFICULTY={{ minecraft_difficulty }}
|
||||||
|
MODE={{ minecraft_mode }}
|
||||||
|
MAX_PLAYERS={{ minecraft_max_players }}
|
||||||
|
VIEW_DISTANCE={{ minecraft_view_distance }}
|
||||||
|
PVP={{ minecraft_pvp | bool | lower }}
|
||||||
|
|
||||||
|
### ACCESS ###
|
||||||
|
ENABLE_WHITELIST=TRUE
|
||||||
|
ENFORCE_WHITELIST=TRUE
|
||||||
|
EXISTING_WHITELIST_FILE=SYNCHRONIZE
|
||||||
|
WHITELIST={{ minecraft_whitelist | join(',') }}
|
||||||
|
EXISTING_OPS_FILE=SYNCHRONIZE
|
||||||
|
OPS={{ minecraft_ops | join(',') }}
|
||||||
|
|
||||||
|
### RCON ###
|
||||||
|
ENABLE_RCON=TRUE
|
||||||
|
RCON_PASSWORD='{{ minecraft_rcon_password }}'
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
name: minecraft
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
image: {{ minecraft_image }}:{{ minecraft_image_tag }}
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
ports:
|
||||||
|
- "{{ minecraft_port }}:25565"
|
||||||
|
- "127.0.0.1:{{ minecraft_rcon_port }}:25575"
|
||||||
|
volumes:
|
||||||
|
- {{ minecraft_data_location }}:/data
|
||||||
|
# give the server time to save the world on stop
|
||||||
|
stop_grace_period: 60s
|
||||||
|
tty: true
|
||||||
|
stdin_open: true
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
minecraft_dir: "{{ cloud_apps }}/minecraft"
|
||||||
|
minecraft_inst: "{{ minecraft_dir }}/inst"
|
||||||
Reference in new issue
Block a user