From a73cebb48f0724b04aad46830206eb54a4c0f04d Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Tue, 19 Nov 2024 14:49:05 +0500 Subject: [PATCH] Start minecraft server --- minecraft.yml | 5 +++++ roles/minecraft/meta/argument_specs.yml | 17 +++++++++++++++ roles/minecraft/tasks/main.yml | 28 +++++++++++++++++++++++++ roles/minecraft/vars/main.yml | 7 +++++++ 4 files changed, 57 insertions(+) create mode 100644 minecraft.yml create mode 100644 roles/minecraft/meta/argument_specs.yml create mode 100644 roles/minecraft/tasks/main.yml create mode 100644 roles/minecraft/vars/main.yml diff --git a/minecraft.yml b/minecraft.yml new file mode 100644 index 0000000..72e2e8e --- /dev/null +++ b/minecraft.yml @@ -0,0 +1,5 @@ +--- +- hosts: webservers + roles: + - name: minecraft + server_name: Comfy Camp diff --git a/roles/minecraft/meta/argument_specs.yml b/roles/minecraft/meta/argument_specs.yml new file mode 100644 index 0000000..dc2369f --- /dev/null +++ b/roles/minecraft/meta/argument_specs.yml @@ -0,0 +1,17 @@ +argument_specs: + main: + options: + eula: + type: bool + server_type: + type: str + server_version: + type: str + online_mode: + type: bool + server_name: + type: str + difficulty: + type: str + tz: + type: str diff --git a/roles/minecraft/tasks/main.yml b/roles/minecraft/tasks/main.yml new file mode 100644 index 0000000..0dbf64b --- /dev/null +++ b/roles/minecraft/tasks/main.yml @@ -0,0 +1,28 @@ +- name: Create minecraft volume + become: true + community.docker.docker_volume: + name: minecraft +- name: Create minecraft container + become: true + community.docker.docker_container: + name: minecraft + image: itzg/minecraft-server:stable + ports: + - "25565:25565" + user: "1003:972" + env: + EULA: "{{ eula | string }}" + TYPE: "{{ server_type }}" + VERSION: "{{ server_version }}" + DIFFICULTY: "{{ difficulty }}" + ONLINE_MODE: "{{ online_mode | string }}" + SERVER_NAME: "{{ server_name }}" + TZ: "{{ tz }}" + volumes: + - minecraft:/data + healthcheck: + test: ["CMD", "mc-health"] + interval: 30s + start_period: 2m + retries: 2 + restart_policy: unless-stopped diff --git a/roles/minecraft/vars/main.yml b/roles/minecraft/vars/main.yml new file mode 100644 index 0000000..412df2a --- /dev/null +++ b/roles/minecraft/vars/main.yml @@ -0,0 +1,7 @@ +eula: true +server_type: PAPER +server_version: "1.21" +online_mode: false +server_name: Minecraft Server +difficulty: hard +tz: Asia/Yekaterinburg