homelab/roles/minecraft/tasks/main.yml

31 lines
889 B
YAML

- 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: "{{ user }}"
env:
EULA: "{{ eula | string }}"
MOTD: "{{ motd }}"
TYPE: "{{ server_type }}"
VERSION: "{{ server_version }}"
DIFFICULTY: "{{ difficulty }}"
ONLINE_MODE: "{{ online_mode | string }}"
SERVER_NAME: "{{ server_name }}"
MAX_PLAYERS: "{{ max_players | string }}"
USE_SIMD_FLAGS: "{{ use_simd_flags | string }}"
volumes:
- minecraft:/data
- /etc/timezone:/etc/timezone:ro
healthcheck:
test: ["CMD", "mc-health"]
interval: 30s
start_period: 2m
retries: 2
restart_policy: unless-stopped