remove!(minecraft): unused

This commit is contained in:
Saibotk 2025-01-20 00:20:55 +01:00
parent 1eae2bf0df
commit 42b72a6764
Signed by: saibotk
GPG key ID: 67585F0065E261D5
9 changed files with 0 additions and 610 deletions

View file

@ -1,24 +0,0 @@
---
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
- name: Install & configure Minecraft
hosts: minecraft
roles:
- docker
- docker_cleanup
- minecraft

View file

@ -1,37 +0,0 @@
Minecraft
=========
Setup a Minecraft server container (https://github.com/itzg/docker-minecraft-server) with an optional RCON interface.
Requirements
------------
You will need to have docker, docker-compose and optionally traefik installed or declared as dependencies with their respective roles.
**This role assumes that (if your are using the RCON webinterface) you have setup traefik with an endpoint called `websecure`.**
Role Variables
--------------
**Please look at the [defaults/main.yml](defaults/main.yml) for all available variables and their description.**
**Note: Lines that are commented out via `#` are usually still valid/used variables, but they are not defined by default, so they might enable a feature, when uncommenting/defining them!**
### Global variables, that are used:
**Only when the webinterface is enabled:**
- `proxy_network`: Defined by the local traefik installation, this is the shared proxy network used by traefik to reach the containers. (optional)
- `proxy_hiddenservice`: Defined by the local traefik installation, this is used to generate the alt-svc header for the alternative Tor domain. (optional)
Dependencies
------------
- docker
- docker-compose
- traefik (optional, only when enabling the webinterface)
License
-------
GPL-3.0-only

View file

@ -1,89 +0,0 @@
---
# Default variables for the minecraft role
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# The install locations
minecraft_install_location: "/srv/minecraft"
minecraft_data_location: "{{ minecraft_install_location }}/data"
minecraft_rcon_location: "{{ minecraft_install_location }}/rcon"
minecraft_backup_location: "{{ minecraft_install_location }}/worlds"
minecraft_telegraf_location: "{{ minecraft_install_location }}/telegraf"
# renovate: depName=docker.io/itzg/minecraft-server
minecraft_image_version: "2024.10.2"
# Container versions
minecraft_image_tag: "{{ minecraft_image_version }}"
# renovate: depName=docker.io/library/telegraf
minecraft_telegraf_version: "1.26.1"
# Changing this image may also require changing the UID / GID below,
# to set the correct permissions
minecraft_telegraf_image_version: "{{ minecraft_telegraf_version }}-alpine"
# Telegraf config user & group id
# This is used for the config folder that is mounted to the container
minecraft_telegraf_config_uid: 100
minecraft_telegraf_config_gid: 101
# The minecraft server port that should be exposed
minecraft_server_port: 25565
# The certresolver traefik should use for the domain
minecraft_rcon_certresolver: letsencrypt_http
# The domain under which the rcon web console/websocket is reachable (used by traefik)
minecraft_rcon_domain: minecraft.example.com
# Should RCON be enabled on the minecraft server?
minecraft_enable_rcon: true
# Should the RCON webinterface be deployed?
minecraft_enable_rcon_web: false
# The RCON password
minecraft_rcon_password: "CHANGEME"
# The minecraft container configuration as environment variables (see https://github.com/itzg/docker-minecraft-server)
minecraft_config: []
# This config allows to add new portbindings to the minecraft server, eg. for voicechat.
#
# Example entry:
# - 24454:24454/udp
minecraft_additional_ports: []
# IPv6 ULA config for the bridge network used by docker-ipv6-nat
minecraft_ipv6:
enabled: false
subnet: "fd9e:21a7:a92c:2325::/64"
# Minecraft telegraf configuration, allows to configure a monitoring setup for the minecraft server
minecraft_telegraf:
enabled: false
influxdb_database: "telegraf"
# Your influxDB hosts
influxdb_endpoints:
- "influxdb.example.com"
influxdb_username: telegraf
influxdb_password: ""
influxdb_retention_policy: "minecraft"
influxdb_retention_policy_tag: ""
plugins: []

View file

@ -1,25 +0,0 @@
---
# Handlers for the minecraft role
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2021 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
- name: Restart telegraf
community.docker.docker_compose_v2:
services: "telegraf"
project_src: "{{ minecraft_install_location }}"
state: restarted
become: true

View file

@ -1,43 +0,0 @@
galaxy_info:
author: saibotk
description: "Deploys a minecraft server with docker and an optional RCON webinterface."
license: GPL-3.0-only
min_ansible_version: "2.9"
standalone: true
platforms:
- name: EL
versions:
- all
- name: GenericUNIX
versions:
- all
- name: Fedora
versions:
- all
- name: opensuse
versions:
- all
- name: GenericBSD
versions:
- all
- name: FreeBSD
versions:
- all
- name: Ubuntu
versions:
- all
- name: SLES
versions:
- all
- name: GenericLinux
versions:
- all
- name: Debian
versions:
- all
galaxy_tags: []
dependencies:
- role: docker

View file

@ -1,118 +0,0 @@
---
# Tasks file for the minecraft role
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
- name: Update default SELinux contexts
community.general.sefcontext:
target: "{{ item }}(/.*)?"
setype: "container_file_t"
state: present
with_items:
- "{{ minecraft_data_location }}"
- "{{ minecraft_backup_location }}"
- "{{ minecraft_rcon_location }}"
- "{{ minecraft_telegraf_location }}"
become: true
- name: Create install directory
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0700"
owner: "root"
group: "root"
with_items:
- "{{ minecraft_install_location }}"
become: true
tags:
- minecraft
- name: Create data directories
ansible.builtin.file: # noqa risky-file-permissions # Container manages permissions on its own
path: "{{ item }}"
state: directory
setype: "container_file_t"
with_items:
- "{{ minecraft_data_location }}"
- "{{ minecraft_backup_location }}"
- "{{ minecraft_rcon_location }}"
become: true
tags:
- minecraft
- name: Create telegraf config directory
ansible.builtin.file:
path: "{{ item }}"
mode: "0700"
owner: "{{ minecraft_telegraf_config_uid }}"
group: "{{ minecraft_telegraf_config_gid }}"
state: directory
setype: "container_file_t"
with_items:
- "{{ minecraft_telegraf_location }}"
become: true
- name: Deploy telegraf.conf
ansible.builtin.template:
src: telegraf.conf
dest: "{{ minecraft_telegraf_location }}/telegraf.conf"
mode: "0600"
owner: "{{ minecraft_telegraf_config_uid }}"
group: "{{ minecraft_telegraf_config_gid }}"
notify: "Restart telegraf"
tags:
- telegraf
- minecraft
become: true
when:
- minecraft_telegraf.enabled
- name: Deploy docker-compose.yml
ansible.builtin.template:
src: docker-compose.yml
dest: "{{ minecraft_install_location }}/docker-compose.yml"
mode: "0600"
owner: "root"
group: "root"
validate: docker compose -f %s config -q
tags:
- docker
- minecraft
become: true
- name: Install minecraftctl CLI
ansible.builtin.template:
src: minecraftctl.sh
dest: "/usr/local/bin/minecraftctl"
mode: "0755"
owner: "root"
group: "root"
tags:
- minecraft
become: true
- name: Compose minecraft
community.docker.docker_compose_v2:
state: present
project_src: "{{ minecraft_install_location }}"
pull: always
remove_orphans: true
tags:
- minecraft
become: true

View file

@ -1,119 +0,0 @@
{{ ansible_managed | comment }}
# Infrastructure
# Ansible instructions to deploy the infrastructure
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
# Copyright (C) 2020 Saibotk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
version: '2.1'
services:
minecraft:
image: docker.io/itzg/minecraft-server:{{ minecraft_image_tag }}
ports:
- "{{ minecraft_server_port }}:25565"
{% for item in minecraft_additional_ports %}
- "{{ item }}"
{% endfor %}
volumes:
- "{{ minecraft_data_location }}:/data"
security_opt:
- no-new-privileges
environment:
EULA: "TRUE"
ENABLE_RCON: "{{ minecraft_enable_rcon | bool | lower }}"
RCON_PASSWORD: "{{ minecraft_rcon_password }}"
RCON_PORT: 28016
# enable env variable replacement
REPLACE_ENV_VARIABLES: "TRUE"
# define an optional prefix for your env variables you want to replace
ENV_VARIABLE_PREFIX: "CFG_"
{% for key, value in minecraft_config.items() %}
{{ key | upper }}: "{{ value }}"
{% endfor %}
networks:
minecraft-backend:
restart: always
{% if minecraft_enable_rcon_web %}
rcon:
image: docker.io/itzg/rcon
labels:
- "traefik.enable=true"
- "traefik.http.routers.minecraft-websocket.rule=Host(`{{ minecraft_rcon_domain }}`) && PathPrefix(`/rcon-websocket`)"
- "traefik.http.routers.minecraft-websocket.entrypoints=websecure"
- "traefik.http.routers.minecraft-websocket.tls.certresolver={{ minecraft_rcon_certresolver }}"
- "traefik.http.routers.minecraft-websocket.middlewares=minecraft,compress,minecraft-websocket-stripprefix"
- "traefik.http.routers.minecraft-websocket.service=minecraft-websocket"
- "traefik.http.services.minecraft-websocket.loadbalancer.server.port=4327"
- "traefik.http.middlewares.minecraft-websocket-stripprefix.stripprefix.prefixes=/rcon-websocket"
- "traefik.http.routers.minecraft.rule=Host(`{{ minecraft_rcon_domain }}`) && PathPrefix(`/`)"
- "traefik.http.routers.minecraft.entrypoints=websecure"
- "traefik.http.routers.minecraft.tls.certresolver={{ minecraft_rcon_certresolver }}"
- "traefik.http.routers.minecraft.middlewares=minecraft,compress"
- "traefik.http.routers.minecraft.service=minecraft"
- "traefik.http.services.minecraft.loadbalancer.server.port=4326"
- "traefik.http.middlewares.minecraft.headers.sslredirect=true"
- "traefik.http.middlewares.minecraft.headers.stsSeconds=63072000"
- "traefik.http.middlewares.minecraft.headers.referrerPolicy=no-referrer"
{% if proxy_network is defined %}
- "traefik.docker.network={{ proxy_network }}"
{% endif %}
volumes:
- "{{ minecraft_rcon_location }}:/opt/rcon-web-admin/db"
networks:
minecraft-backend:
{% if proxy_network is defined %}
{{ proxy_network }}:
{% endif %}
restart: always
{% endif %}
{% if minecraft_telegraf.enabled %}
telegraf:
image: docker.io/library/telegraf:{{ minecraft_telegraf_image_version }}
restart: always
mem_limit: 256mb
memswap_limit: 384mb
read_only: false # TODO: Switch to self-made container
networks:
minecraft-backend:
volumes:
- {{ minecraft_telegraf_location }}:/etc/telegraf/:ro
{% endif %}
networks:
minecraft-backend:
driver: bridge
{% if minecraft_ipv6 is defined and minecraft_ipv6.enabled %}
ipam:
driver: default
config:
- subnet: {{ minecraft_ipv6.subnet }}
enable_ipv6: true
{% endif %}
{% if proxy_network is defined and minecraft_enable_rcon_web %}
{{ proxy_network }}:
external: true
{% endif %}

View file

@ -1,100 +0,0 @@
#!/bin/bash
MINECRAFT_PATH="{{ minecraft_data_location }}"
COMMAND=${1:-help}
cd "$MINECRAFT_PATH"
usage() {
cat <<EOF
$0 up
Starts the minecraft server
$0 restart
Restarts the minecraft server
$0 down
Stops the minecraft server
$0 logs
Show the logs of the minecraft server
$0 status
Show the status of all minecraft containers
$0 mod-ls
Lists all installed mod packages in the mods directory of the minecraft server
$0 mod-cp <some mod jar file>
Copies a mod package to the mods directory of the mincraft server
$0 mod-rm <file name from mod-ls output>
Removes a mod package from the mods directory of the minecraft server
$0 world-ls
Lists backed up worlds
$0 world-rm <time reference>
Removes a world backup
$0 world-backup
Creates a backup of the current world
$0 world-restore <time reference>
Restores a world from the backup
$0 world-destroy
Destroys the current world of the server.
Warning: Stop the server before using this.
EOF
}
case "$COMMAND" in
"restart")
docker-compose restart
;;
"up")
docker-compose up -d
;;
"down")
docker-compose down
;;
"logs")
docker-compose logs minecraft
;;
"status")
docker-compose ps
;;
"mod-cp")
if [ ! -e "$OLDPWD/$2" ]; then
echo "file \"$OLDPWD/$2\" not found"
exit 1
fi
cp "$OLDPWD/$2" "$MINECRAFT_PATH/data/mods/"
chown -R root:root "$MINECRAFT_PATH/data/mods/"
;;
"mod-rm")
if ls "$MINECRAFT_PATH/data/mods/" | grep "$2"; then
rm "$MINECRAFT_PATH/data/mods/$2"
fi
;;
"mod-ls")
ls "$MINECRAFT_PATH/data/mods/"
;;
"world-ls")
ls "$MINECRAFT_PATH/worlds/"
;;
"world-rm")
if ls "$MINECRAFT_PATH/worlds/" | grep "$2"; then
rm -Ir "$MINECRAFT_PATH/worlds/$2"
fi
;;
"world-backup")
mkdir "$MINECRAFT_PATH/worlds/$(date +%Y-%m-%dT%H:%M)"
cp -r "$MINECRAFT_PATH/data/"{world,world_the_end,world_nether} "$MINECRAFT_PATH/worlds/$(date +%Y-%m-%dT%H:%M)/"
;;
"world-restore")
if [ -e "$MINECRAFT_PATH/data/world" ]; then
echo "Please destroy the world before restoring"
exit 1
fi
if ls "$MINECRAFT_PATH/worlds/" | grep "$2"; then
cp -Ir "$MINECRAFT_PATH/worlds/$2/*" "$MINECRAFT_PATH/data/"
fi
;;
"world-destroy")
rm -Ir "$MINECRAFT_PATH/data/"{world,world_the_end,world_nether}
;;
*)
usage
;;
esac

View file

@ -1,55 +0,0 @@
{{ ansible_managed | comment }}
[global_tags]
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 1000000
collection_jitter = "5s"
flush_interval = "10s"
flush_jitter = "5s"
precision = ""
hostname = "{{ ansible_fqdn }}"
omit_hostname = false
[[outputs.influxdb]]
urls = ["https://{{ minecraft_telegraf.influxdb_endpoints | join('","https://') }}"]
database = "{{ minecraft_telegraf.influxdb_database }}"
timeout = "5s"
retention_policy = "{{ minecraft_telegraf.influxdb_retention_policy }}"
retention_policy_tag = "{{ minecraft_telegraf.influxdb_retention_policy_tag }}"
username = "{{ minecraft_telegraf.influxdb_username }}"
password = "{{ minecraft_telegraf.influxdb_password }}"
{% if minecraft_telegraf.plugins is defined and minecraft_telegraf.plugins is iterable %}
{% for item in minecraft_telegraf.plugins %}
[[inputs.{{ item.plugin }}]]
{% if item.interval is defined %}
interval = "{{ item.interval }}s"
{% endif %}
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tags is defined and item.tags is iterable %}
[inputs.{{ item.plugin }}.tags]
{% for items in item.tags %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[inputs.{{ item.plugin }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[inputs.{{ item.plugin }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}